[Solved] Loop animation backwards and forwards

P

popjin

Guest
Hi, I have a question about how I would loop an animation backwards and forwards.
Here is the the code I am using:

Create Event:

image_speed = 0.75
image_xscale = 12
image_yscale = 12

cycle = 0
a_end = 0
time = 0
base = 20


Step Event:

if (cycle = 1 and a_end = 1)
{
if (time <= base)
{
time += 1
}
if (time >= base)
{
image_speed = -0.75
time = 0
a_end = 0
}
}

if (cycle = 0 and a_end = 1)
{
if (time <= base)
{
time += 1
}
if (time >= base)
{
image_speed = 0.75
time = 0
a_end = 0
}
}

Other Event: Animation End:

image_speed = 0
a_end = 1

if (cycle = 0)
{
cycle = 1
image_index -= 1
}
else
{
cycle = 0
image_index += 1
}


I will probably update this question with more information tomorrow.
Thanks in advance, any help would be appreciated
 
A

Aura

Guest
Code:
if (image_speed == -0.75 && image_index < 1) {
   image_index = 0;
   image_speed = 0.75;
}
else if (image_speed == 0.75 && image_index > image_number - 2) {
   image_index = image_number - 1;
   image_speed = -0.75;
}
 
Top