GameMaker How do I center an imported sprite?

M

MetroidFan

Guest
I'm currently working on my first game in Game Maker and I'm trying to put an imported sprite into the center of the image, is there any way I can do this in Game Maker itself?
 

RangerX

Member
You can draw a sprite anywhere on screen. However, the origin might be automatically set to X0,Y0 when you import.
If its the case you simply draw it with an offset. Every sprite is having useful variables available like "sprite_height" and "sprite_width".
 

Hyomoto

Member
Something to keep in mind, you should know something about the imported asset. As @RangerX points out, you can use an offset, but I'd like to add you have to code the method to know what offset to use. You could use a text file to define the loaded sprite's attributes, or just know what it is you are loading and hard code them in. But it'll be up to you as the software designer to apply what you know so the program can make use of it.
 

PlayerOne

Member
You can just center the origin of the imported sprite in the editor without the need to use code. Just double click on the sprite and you will see origin above the the image (top left, top center, top right, etc). Unless you want to for some specific reason or another.
 
Top