Hello, the problem seems to be kinda complicated but im sure its something simple, I just cant come up with the solution.
I have a sheet, with two animations, one for the walking of the enemy, and one for the falling, so I coded this:
local NormalEnemyOptions = {
width = 200;
height = 200;
numFrames = 14;
–The image is 2800x200, there are 14 frames
}
local NormalEnemySheet = graphics.newImageSheet(“NormalEnemySheet .png”, NormalEnemyOptions );
local WalkingEnemySecuence= {
name = “Walking”;
start = 1;
count = 8;
time = 550;
loopCount = 0;
loopDirection = “forward”;
}
local FallingEnemySecuence = {
name = “Falling”;
start = 9;
count = 14;
time = 550;
loopCount = 1;
loopDirection = “forward”;
}
So then I set the walking sequence and start playing it:
local self = display.newSprite(NormalEnemySheet , WalkingEnemySecuence);
self.width = 30; self.height = 45; self.xScale = 0.35; self.yScale = 0.35;
self:play();
physics.addBody(self, “kinematic”, {friction = 0.5, bounce = 0.2});
(The Scale, width and height thing is just to adjust it to the game, dont mind it.)
But when I shoot the enemy, I want it to change the animation, so I made a function (Which is called from the main file, because the enemy is a completly apart class)
The function is the following one:
function self:ChangetoFalling()
self:setSequence(“Falling”);
print(“The sprite has been changed”)
self:play();
print(“PLAAAAAY”)
end
I put those prints there to see if the code its executed, and it is, I just dont know why the animation doesnt change, it is still the same, not a single change, I dont know what else to do, I have been looking everywhere but nobody seems to have this problem.
THANKS A LOT FOR YOUR HELP!
PS:The names of everything are traducted to English so you can understand better, but they are coded in Spanish, so if you find a spanish word its because I forgot to translate it, its not in the code.