Legacy GM need help with alarm time

B

begjan

Guest
i want play attack animation every 2 seconds. And my attacking sprite animation have 4 frames. what is best alarm set i should use.
 

jo-thijs

Member
room_speed * 2

room_speed is the amount of steps the game performs inside a single second (if no lag occurs).
The alarm should be set to the amount of steps you want to wait before triggering its alarm event.
 
B

begjan

Guest
my game room speed is 60. in enemy step event i have code: image_speed=0.175; But my running animation have 8 frames, idle is 4 frames and attacking is 4 frames. i want trigger attack animation every 2 sec. but i having mess with attacking animation in room. like sometimes attack animation starts from 3rd frames 3,4,2,1 or 1,2,3,4,1 or 4,1,2,3 (image_index 1,2,3,4). what i should change?
 
W

wagyu_so_gud

Guest
+1 for what FrostyCat said: when you set the sprite_index to the attack, also set image_index = 0 so that it starts at the beginning of your animation.

Before you can do an attack, you want to make sure that the alarm is not active, meaning, it's == -1. If that is true, then you 'can attack'. Your attack sprite animates and once it has completed, you then set the alarm = room_speed*2, thus, delaying the attack until the alarm has countdown to == -1 before it executes again.
 
Top