I have many sprites with different sizes, and I have an object in which I set those sprites, but this object gets resized by the currently displayed sprite.

How can I set a fixed size for the object so that it can no longer change size?

Thanks for any help.


2 Answers 2


When you load the sprite:

image_xscale = (image_xscale/sprite_get_width(your_sprite))*SIZE_YOU_WANT_WIDTH

image_yscale =(image_yscale/sprite_get_height(your_sprite))*SIZE_YOU_WANT_HEIGHT

I can't check if the functions i've used there are the good ones, be sure to check in the doc (press F1 in the GameMaker interface, and look for xscale and sprite_get_width by example)

Basically what you do is that you consider that your sprite is only a 1*1 pixel, and then strectch it to the value you have fixed.


Assuming that by "size" you mean the size of its collision shape, this is governed by the mask_index variable, to which you should assign the index of the sprite that will always be used for collision.

  • \$\begingroup\$ No, I'm not using colliders, I mean when I change the sprite of my object to another, this object takes the size of the new sprite, I do not want it to resize when changing its sprite. \$\endgroup\$ Dec 1, 2016 at 17:00
  • \$\begingroup\$ @RetanaClarke Why are your sprites not the same size to begin with ? \$\endgroup\$
    – Quentin
    Dec 1, 2016 at 17:14
  • \$\begingroup\$ Because I'm not using sprite made by me, and by modifying its size with the sprites editor they lose image quality. Do you know in any way so that they do not lose quality? Are pixelated gba style sprites \$\endgroup\$ Dec 1, 2016 at 17:55
  • \$\begingroup\$ @RetanaClarke Well, setting a "fixed size" for your object would mean stretching its new sprite to fit the requested size, with the same results as the sprite editor. Could you maybe provide two of your sprites that have that issue, as I have trouble understanding how you've ended up with two sprites of the same thing but wildly different sizes, especially if they're pixel art ? \$\endgroup\$
    – Quentin
    Dec 1, 2016 at 18:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .