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.

Comment ( 1 )
  1. Tamie
    July 1, 2018 at 5:16 am
    Reply

    Hello I am so grateful I found your site, I really found you
    by accident, while I was looking on Digg for something else, Nonetheless I am here now and would just like to say
    thank you for a incredible post and a all round interesting blog (I also love the theme/design),
    I don’t have time to read through it all at
    the moment but I have saved it and also added your RSS feeds, so when I have time I will be back to read more,
    Please do keep up the superb work.

Leave a reply