I hope that everyone is well, I come to you with what I hope is a super quick questions. I want my character to attack, this will have a factory create the projectile. This projectile has a flipbook animation showing it increase in size. When it is at full size (in other words, when it is done with the animation) I want to to then switch to another animation group. I couldn’t quite figure out how to do this with animation_done since the factory was created through the player script. Here is my code…
if message.id == hash("attack") and message.released and facingright and onground and canattack then
print("attack recieved")
print("attackright")
local pos = go.get_position() + vmath.vector3(160, 30, 0)
local id = factory.create("#attack", pos)
go.animate(id, "position.x", go.PLAYBACK_ONCE_FORWARD, pos.x + 1000, go.EASING_LINEAR, 0.8, 0, function()
go.delete(id)
end)
canattack = false
timer.delay(.5, false, function() canattack = true end)
end
Any insight would be appreciated, if I need to reword anything, please let me know!
I’m not entirely sure I understand what you mean by this.
A finished sprite flipbook animation will generate an animation_done message on the game object the sprite is attached to. You can also use sprite.play_flipbook() and use a callback function which will get invoked when the animation is finished:
I think that I will take a look into this, it seems a bit more straightforward for me needs. For future reference, what is the applicational difference between go.animate and sprite.play_flipbook?
go.animate() is used for property animations, which basically means animating a property such as position or rotation from one value to another over a period of time while applying an easing/tween function: