Object keeps getting resized

I have a movePlatform function in my code and when ever i finish moving the platform I call a resize function this is the code:

elseif event.phase == "ended" or event.phase == "cancelled" and moving == true then if(platformTouched.x \>= 72) then timer.performWithDelay( 0, blockExpand, 1 ) end end

This is my blockExpand function:

function blockExpand() block:scale( 5.0, 1.0 ) end

My problem is, every time I tap and then release, the block scales up, and then if i repeat it again, it scales up again, so as long as i keep tapping and releasing, the block keeps scaling infinitely.

What i want to achieve is, no matter how many times i tap and release, the block only scales up ONCE and stays the same size. Is there any code to set the size of it instead?

Hi @frostyvb14,

The :scale() function will always scale an object by the ratio you define, no matter if it has been scaled before. If you want a one-time scale that’s based on the object’s original size, you should use the .xScale and .yScale properties:

http://docs.coronalabs.com/api/type/DisplayObject/xScale.html

http://docs.coronalabs.com/api/type/DisplayObject/yScale.html

Best regards,

Brent

Thanks Brent, it seems to have worked, i should have done a little more research and found those links.

Hi @frostyvb14,

The :scale() function will always scale an object by the ratio you define, no matter if it has been scaled before. If you want a one-time scale that’s based on the object’s original size, you should use the .xScale and .yScale properties:

http://docs.coronalabs.com/api/type/DisplayObject/xScale.html

http://docs.coronalabs.com/api/type/DisplayObject/yScale.html

Best regards,

Brent

Thanks Brent, it seems to have worked, i should have done a little more research and found those links.