• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Programming Animation Hell. Please help :)

Hello! So I've been working on an enemy for my game that will run away from the player and then teleport back to the center of the map if they reach the end. The whole time, they shoot projectiles which must be dodged. (Think Wizrobes from Zelda)

The problem: I have it set to where if the object reaches the x and y of the level's wall, it'll change sprites to look like it's teleporting. Works fine. They appear at the center, buuuut the only problem is that I can't seem to make the animation end after the final frame and then change back into the sprite before. It's probably an easy fix. I'll just post my code for the teleportation and animations here. Any help is much appreciated :)

The teleportation code works fine, but may be related to the problem. This is a step event:
Code:
if position_meeting(Fence.x, Fence.y, Fence) {
    sprite_index = spr_cleric_teleport;
}

if sprite_index = spr_cleric_teleport {
    if image_index = 5 {
        action_move_to(obj_teleport.x, obj_teleport.y);
    }      
}
This is the animation end event (initially had it in step):
Code:
if (sprite_index = spr_cleric_teleport) {
    if (image_index=10) {
        sprite_index = spr_cleric;
    }
}
I've been stuck trying to figure this out for longer than I should be haha so I'm turning to the community once again!
 

Mick

Member
In the animation end event, you shouldn't do this check at all: "if (image_index=10)". so:

animation end event:
Code:
if (sprite_index = spr_cleric_teleport) {
  sprite_index = spr_cleric;
  image_index = 0; // optional
}
 
just tried that and it hasn't worked yet. But the amount of images in the sprite was equal to the number used to teleport (5 total images, teleporting on image 5) so maybe that caused an issue? I changed the image count to 10 now, gonna try it again :confused: Does it reset the sprite image everytime it jumps to a new position perhaps? Because that would be a problem considering there's 10 images and it teleports on image 5. If so, then it's never getting to its animation end
 
Top