First animation not playing (SOLVED)

Sorry in advance, this must be a really dumb thing i’m missing…

When the user clicks on the screen, a sprite should appear.
Tonight i added an animation that makes the sprite (a little sphere) “popup” … basically:

create the game object
set scale to 0.01
animate scale to 1

and i noticed that at the first click, and only the first, the animation is not played, the sprite just appears at scale 1.
Subsequent clicks are ok.

M.createOrb = function(tile, orbType, time, easing)
	local orbPos = M.getTileCenterPosition(tile)
	local orb = factory.create("#orb_factory", orbPos, nil, nil)
        -- this is a single frame animation (i use several single frame animations of different colors and i switch color this way)
	sprite.play_flipbook(orb, C.ORBS[orbType])
	if(time ~= nil) then
		if(easing == nil) then
			easing = go.EASING_OUTELASTIC
		end
		print(time .. "   " .. easing)
		go.set_scale(0.01)
		go.animate(orb, "scale", go.PLAYBACK_ONCE_FORWARD, 1, easing, time, 0)
	end
	return orb
end

time and easing are always the same for all clicks.
Ideas?

Issue can be seen here:

mmm… that “if” block i recently added is also causing side effects when the method is called with a nil value for the parameter time: the sprite does not appear at all…

now i’m brain overloaded…bedtime

This should be go.set_scale(0.01, orb). If you don’t pass in a game object id as second argument the go.set_scale() function will operate on the game object that the script is attached to.

1 Like

yes! that’s the bug.

… too much object oriented programming side effect :sweat:

1 Like