May I dynamically scale a sprite?

Hi guys.
Having an animated sprite, I’m trying to resize it when his y-position is changed.
I’ve included these lines into the “update” function:

...
	local p = go.get_position()
	if  not self.dir.y == 0 then
		local s = 128 *( 2 - p.y / 800)
		go.set("#sprite", "scale.x", s)
		go.set("#sprite", "scale.y", s)
	end
...

but did not work.
Any idea ?

Parent the sprite to a game object and then scale the game object.

1 Like

Got it ! Thanks.

1 Like