SOLVED Drawing sprite as it is on room editor

Hi there,
this might be a very stupid question but... here I am lol

I have an object that has a image_angle=direction code in the step event.

When I draw it with draw_self() or draw_sprite_ext(sprite_index,-1,x,y,1,1,image_angle,c_white,1) everything works fine... until I rotate it in the room editor.
If I rotate that object 180° (for example) in the room editor and then start the game, the rotation is still set to default, the object isn't rotated as I did in the room editor "offline".

How am I supposed to have my object rotated as I place it even if it has to rotate in-game?
 

Mr Magnus

Viking King
the issue is that "rotating" it in the room_editor simply instructs gamemaker to set image_angle to the angle specified in the editor, which is then instantly undone the first time the game encounters image_angle = direction in the step event.

If you are using the room editor to create a sort of "offset" to act as a baseline angle you'll need to capture that value in the create event of the instance, and then add it to the image angle whenever you set it.

so for instance something in the like of

GML:
/// Create event

offset = image_angle;

/// Step event if you want it to affect the direction you're travelling in

image_angle = direction + offset;

/// OR, if you just need the image to be rotated but have direction be unaffected

draw_sprite_ext(sprite_index, image_index, x,y,image_xscale, image_yscale, image_angle + offset, image_blend, image_alpha)
 
When you are rotating in the room, you are setting image_angle to the rotational value. Then, the step event runs in-game and sets your image_angle to the direction, nullifying the room rotation. One solution could be to set the direction of your instance to the image_angle in the create event.
 
I solved by setting the direction as image_angle is when creating the object.
I can't believe I got stuck on this even if I realized that the room editor just change the image_angle lol
Thank you guys
 
Top