Chain of Sprites in an Object

B

buhalda

Guest
The catapult has a create event which makes the loading animation play ( sprite_index = spr_catapult_load; image_index = 0;, image_speed = 0.25;) Thats it. In the step event, it goes like : if sprite_index = spr_catapult_load { if image_index = 15 (which is the last subimage) {sprite_index = spr_catapult_fire; image_index = 0; }}

But for some reason the same loading animation keeps playing and the step event doesnt want to change the sprite of the object when it reaches the last subimage of the loading animation.

My code looks like this:
Create:
sprite_index = spr_catapult_load;
image_index = 0;
image_speed = 0.25;

Step:
if sprite_index = spr_catapult_load
{
if image_index = 15
{
sprite_index = spr_catapult_fire;
(and it should have executed this code above, but for some reason it doesnt do it even when its on the last subimage 15 )
}
}
 

kburkhart84

Firehammer Games
One, isn't there an event for when an animation ends called "animation end?" You could use that event and either check the sprite index, or use a state variable to say it is currently loading, and then change the sprite in that event.

Also, I understand that image indices start at zero. You are using the value 15, which assumes that you have 16 frames. Is that correct? If you only have 15 frames, then image_index will never reach the value, rather back to 0 again.
 
J

JFitch

Guest
It's either what kburkhart84 said about the number of the last subimage, or it's a problem with the code that changes it back to the load sprite. Also, you can simplify the two "if" statements

Code:
if sprite_index = spr_catapult_load && image_index = 15
{
...
}
 

sp202

Member
Never use exact comparisons with image_index, chances are it'll never be exactly 15. Round the image_index for comparisons.
 
Top