GML How to make turning animation state?

Edwin

Member
I want to make an animation state that will turn the player and when finishing it'll changing his xscale to negative. I tried to make it, but always got errors and non working baloney.


My animation state system:
Code:
animIdle = 0;
animTurn = 1;
animRun = 2;

animState = animIdle;

My turning animation:
ezgif.com-resize.gif
 

NightFrost

Member
The base of your state system seems ok (though you could use an enum as well). The problem is probably in your state changer code (or as simple as setting the right sprites, you didn't specify what goes wrong).
 

Dandysius

Member
Animation you are using is bull****, if you want to change xscale.
use only half of animation (just like im sending you)

And let my comment be your player object...

CREATE event:
image_index=3;
image_xscale=1;
image_speed=0;
state=0; //state 0 = looking right,state 1 = looking left

STEP event:
if state=0
if !(image_xscale=1)
image_index--;
if state=1
if !(image_xscale=-1)
image_index--;

if state=0
if image_xscale=1
if image_index<3
image_index++;
if state=1
if image_xscale=-1
if image_index<3
image_index++;

if image_index<1
{
if state=0
image_xscale=1;
if state=1
image_xscale=-1;
}


LEFT arrow key event:
state=1;

RIGHT arrow key event:
state=0;
 

Attachments

Edwin

Member
Animation you are using is bull****, if you want to change xscale.
use only half of animation (just like im sending you)

And let my comment be your player object...

CREATE event:
image_index=3;
image_xscale=1;
image_speed=0;
state=0; //state 0 = looking right,state 1 = looking left

STEP event:
if state=0
if !(image_xscale=1)
image_index--;
if state=1
if !(image_xscale=-1)
image_index--;

if state=0
if image_xscale=1
if image_index<3
image_index++;
if state=1
if image_xscale=-1
if image_index<3
image_index++;

if image_index<1
{
if state=0
image_xscale=1;
if state=1
image_xscale=-1;
}


LEFT arrow key event:
state=1;

RIGHT arrow key event:
state=0;
I'd recommend using == instead of = if you comparing values.

Thanks for answering!
 
Top