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.

Steps:

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.

Image

2. Create a new object and assign the sprite to it.

Image

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 Image 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.

Image

You can download the source file from here. If you are interested in learning Game maker then you can checkout my book.

Sujit Yadav

Sujit Kumar Yadav is a tech savvy who loves to explore about new technology. He is also passionate about animation and game development. He loves to write poems and to draw. He is a learner of life who loves travelling, meeting new people and dancing.

Leave a reply