• 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!

image index glitch

L

Latch

Guest
I keep all my characters actions confined within one sprite, I then call upon them when needed, however, I have hit a slight hiccup that I can't quite fix.

For ease I have removed several cases and just stuck with one, each facing resembles the direction of the character, 4 is down:

Code:
if attacking = false
{
if moved = false//Standing still
{
    image_speed = 0.1/2+0.05;//Have a slower animation speed when stood still
    switch(facing)
    {
        case 4: if image_index >= 3  {image_index = 0;}  if image_index < 0  {image_index = 0;}  break
    }
}
else if moved = true
{
    image_speed = playerspeed/8;//The players sprites animate the faster or slower that he player moves
    switch(facing)
    {
        case 4: if image_index >= 19 {image_index = 15;} if image_index < 15 {image_index = 15;} break
    } 
}
}
  
else //if attacking = true
{
    image_speed = playerspeed/8;//The players sprites animate the faster or slower that he player moves
    switch(facing)
{      
        case 4: if image_index >= 39 {image_index = 35; attacking = false;} if image_index < 35 {image_index = 35;} break    
}
    }
This works as intended, when the player stands still it loops the resting animation, if they move, it transitions perfectly into the walking one and when punching, it transitions nicely into the punching one.

However, right when the cycle has ended for the punching animation the sprite flickers before transitioning into the resting animation.

I used the debug runner (With VERY limit knowledge of it) I double clicked on the line for the attacking animation and spammed the green play button as it cycled the punch animation. It worked fine and as soon as it ran that bit of code, it flickered, which leaves me to believe it has something to do with the resting animation loop.

But, with the fact the resting loop works flawlessly with the walking animation, I have no idea what has happened. Can anyone see anything?
 
Last edited by a moderator:
How many frames are in your sprite? Are the attacking sprites at the end? By default, Studio will automatically loop the value of image_index if it goes over the value of the last sprite frame. This might be part of the problem.
 
Top