Hello there.
My character will only play animation after my character stop moving.
Here the sample of code:
elseif action_id == hash(“right”) then
self.input.x = 1
msg.post("#sprite", “play_animation”, {id = hash(“right”)})
end
Hello there.
My character will only play animation after my character stop moving.
Here the sample of code:
elseif action_id == hash(“right”) then
self.input.x = 1
msg.post("#sprite", “play_animation”, {id = hash(“right”)})
end
Could it be that you’re playing the animation every frame, thus restarting it?
What if you check for the action.pressed
too?
elseif action.pressed and action_id == hash(“right”) then
self.input.x = 1
msg.post("#sprite", “play_animation”, {id = hash(“right”)})
end
thanks for the reply. After tried it, my character only move a little. So i need to press right continuously to move to the right.
Btw, I tried new if statement. If the speed ==250, play_animation. The problem still there. The animation will only be played after the character stop moving.
I think it continuously restart the animation when i pressed the button, just like u said.
Fix it!
I need to separate it.
elseif action_id == hash("right") then
self.input.x = 1
if action.pressed then
msg.post("#sprite", "play_animation", {id = hash("right")})
end
end
Good to hear that you solved it! I have any example showing how to deal with animation and key states here: https://github.com/britzl/publicexamples/tree/master/examples/play_animation