Legacy GM How to change object origin snap by code?

B

Bhreno

Guest
The obj_x sprite has its origin point x and y in (16,16), but when it is created mid-game, this origin point needs to change to (0,0). How to do this by code? P.s: the object is physic!

In image: the aligned blocks I put manually. Those that are centered are created later, and need to make them also aligned.
In blue circle: aligned example.
In red circle: centered example (i need change her to aligned).
 

Attachments

marasovec

Member
Why not to make two sprites?
One with origin 16,16 and the other one with origin 0,0


sprite_set_offset(spr, origin_x, origin_y)
 
Last edited:

NightFrost

Member
Note that because sprite_set_offset affects sprite, instances aldeady in game that use the sprite will also be affected, so it might not be what you are looking for. But why not simply move the instance creation position? After all the [x,y] doesn't really matter to collisions, only the location of the bounding box. (The reason why those created during runtime are off is the sprite offset. Since the offset is centered, the creation position is not the upper left corner but centerpoint.)
 
Top