Rotating any sprite in Game Maker Studio
Today we will learn how to rotate any sprite in Game Maker Studio. May be you want to create a rotating asteroid for your game. Possibilities are endless. So here is a quick way to do this.
1. Create a new sprite and load any sprite. You can name it anything. Here we are using an asteroid sprite. We called it spr_asteroid. Click on Center.
2. Create a new object and assign the sprite to it.
3. We want asteroid to keep rotating throughout the game. So we have to add this action in Step event. Add Step event and use Execute Code action in the actions list.
4. In the code window, write
image_angle += 5;
image_angle is the current angle at which the instance sprite is drawn. Here we are telling Game Maker to rotate the sprite by 5 degree. Since we used this code in Step event, it will keep rotating. Step event occurs continuously throughout the game. So the asteroid the will keep rotating.
5. Create a new room and place obj_asteroid in it. Run the game.