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.
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.