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

GML Sprite animations within the step event

Chaser

Member
Hi, i have been working with 'States' and enums and i think i have got a pretty good hold of it. 1 object instead of many of the different behaviours, is very good way of working. i have my scripts, and yeah i'm pleased with where i'm going, however, that is until i come to the sprites and animations. oh dear, because the states switch when something happens within the step event to change the player state which has a different animation. like walking, running, its not playing the full animation, because obviously its been done every second in the step event.
example:
Enums: Idle,Run, walk.

so object starts being in the state.idle

step_event:
if keyboard_check(vk_right) || keyboard_check(vk_left)
{ states = state.walk }

state walk runs the script to move and also tells what sprite animation to be.

you get the idea, so how does one combat this? is there a way to run a script only once within the step event? like you can with an instance, if !instance_exists do whatever, if not then......

i thought about a variable but that's not going to work coz it will be the same result, so i'm beginning to think that i have gone about this the wrong way and maybe i should have an object for every state/behaviour and using the states for the wrong things, i dunno, my logic is not right is it. :) or i was trying to be a clever dick.

thoughts on this would be great, cheers. :)
 

Spam1985

Member
In the create event, set image_speed to 0
create a new variable called animation_speed (if you want)

then do something like:

//step
if state = walk { image_index += animation_speed }


I'm not sure I understand your issue exactly, but maybe that helps somehow ^
 
Top