Hi,
I am pretty new to Game Maker, and I am having this problem. It is probably easy to fix, but I cant figure it out. I need a sprite to play an animation, which I figured out how to do with a timeline, but I need the sprite to not be able to move while the animation is playing. How could I do this? Coding and blocking are both desired since I need to learn GML anyway.
Thanks!!
In the sprite editor, if you open up a sprite and before you go into it to edit, you can copy and paste/add a new 'frame'. So you do you first frame, then when you're finished editing, copy it and paste another frame and edit that one etc until you have your animation. I'm just checking this is infact how you're doing it because if so - you won't need a timeline.
Now if you assign that sprite to an object, and put it in the room, the animation should play.. If you don't want it to play at the start in the animated objects Create Event put:
image_single = 0
That will set it to the first image of the animation. Now when you want it to play the animation you can put on say key press right arrow:
image_single = -1
This will make it start animating. To stop it, just put the first code on a key release.
To not have it able to move while the animation is playing make a variable that you can toggle to true/false in the create event.
So say.. Adding to objects Create Event you would now have:
image_single = 0
animating = false
Then when you use your
image_single = -1 code to animate it change the
animating = true variable to true. Then when you want to stop the animation you'd put:
image_single = 0
animating = false
Now that you have that set up you can do a check before you move your object, so say:
if animating = false{
//movement code here
} You can also check the
animating variable in Drag&Drop by using that purple hexagon icon, I believe..
Swifty
Edited by Swifty, 26 June 2012 - 04:12 PM.