Animate a sprite
The base speed is the sprite fps, set in the sprite editor. In code, animSpeed multiplies that value.
function onSpawn(self) self.animSpeed = 2end
function onAnimationEnd(self) self:destroy()endvoid onSpawn() override { animSpeed = 2; }void onAnimationEnd() override { destroy(); }Variations
Section titled “Variations”self.animSpeed = 0self.frame = 1
self.sprite = self.hspeed ~= 0 and "player_andando" or "player_parado"
self.flipX = trueself.angle = 45animSpeed = 0;frame = 1;
sprite = hspeed != 0 ? "player_andando" : "player_parado";
flipX = true;angle = 45;animSpeed = 0stops the animation;framepicks the frame, starting at 0.- Changing
spritereturns the animation to frame 0. - With no fps on the sprite,
animSpeedcounts in frames per step:0.25= 15 frames per second. anglerotates only the drawing;flipXmirrors the drawing and the collision.
Reference: Objects and events.
