Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to make an object scale equally from all sides?
Started by thindamitesh Jan 07 2020 01:50 PM

6 replies to this topic
scaling corona sdk
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

thindamitesh

[GLOBAL: userInfoPane.html]
thindamitesh
  • Observer

  • 3 posts
  • Corona SDK

Hi everyone, 

 

I am having trouble figuring out how I can scale a circle overlapping another circle of the same size, such that when it scales down it is in the center of the bigger circle. Currently, what is happening is that the circle scales more from the the top resulting in the smaller circle to be at below the center of the bigger circle. I have attached visuals to make it easier to understand what I am trying to say. 

function displayCircles() 
     
    outerCircle = display.newImageRect(mainGroup,circleObjectSheet,1,size,size)
    outerCircle.x=display.contentCenterX
    outerCircle.y=display.contentCenterY

    innerCircle = display.newImageRect(mainGroup,circleObjectSheet,2,196,196)
    innerCircle.x=display.contentCenterX
    innerCircle.y=display.contentCenterY
    
  
    transition.to(innerCircle,{time=1000,xScale=0.2,yScale=0.2})
 
    
end

Attached Files



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,675 posts
  • Enterprise

Can you share your code where you're making the circles? Please use code formatting (the blue <> button in the row with Bold, Italic, etc.) and paste your code in the popup window.

 

Rob



[TOPIC: post.html]
#3

thindamitesh

[GLOBAL: userInfoPane.html]
thindamitesh
  • Observer

  • 3 posts
  • Corona SDK

Hi Rob Thanks for the reply, I have added the code as requested



[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,666 posts
  • Corona SDK

That looks to me as if your images are not centered (visible part not centered in the texture).  Can you attach the two circle images here too?


  • thindamitesh likes this

[TOPIC: post.html]
#5

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,240 posts
  • Corona SDK

My first thoughts would be that the images are anchored at the bottom of the image instead of centre of the image, but the unevenness of the images themselves can also be the likely culprit, as @roaminggamer suggested.



[TOPIC: post.html]
#6

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 808 posts
  • Corona SDK

It looks like the inner and outer circles are not at the same coordinates to begin with.  Try making sure that both circles' coordinates match at the end. 

transition.to(innerCircle,{time=1000, x = outerCircle.x, y = outerCircle.y, xScale=0.2, yScale=0.2})

This will also reveal if your scaling size is not correct



[TOPIC: post.html]
#7

thindamitesh

[GLOBAL: userInfoPane.html]
thindamitesh
  • Observer

  • 3 posts
  • Corona SDK

Thank you everyone for the help, really appreciate. Roamingamer was right the images were not centered. I just had to make the contentWidth and contentHeight equal to the size of the actual image rather than the size of the Sprite sheet in the Sprite sheet options.


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: scaling, corona sdk