Hello-world level question about Sprite:setImage

Hi, there!

I am new here and learning from the beginning right now, with little understanding about the principle of Sprite.

Now I want to scale up the sprite 2x whenever the button is clicked. Following the SDK, I use setscale and setimage. However, it turns out the sprite can only be scaled once. Please help me out about the mechanism. Thanks very much!

    if playdate.buttonIsPressed( playdate.kButtonA ) then

Howdy Guan! The scale factor is relative to the source image, not the previous scaling--in other words, the calls don't multiply each other.

    playerSprite:setScale(2 * playerSprite:getScale())

will scale the sprite to twice its current scale. Also note that you can use playerSprite:setScale(1) to restore the sprite to the original unscaled image.

Got it! Thanks very much~