[Solved] Make a sprite copy a different sprite's size

M

MizzyV

Guest
I have a common death animation sprite that I want to use for every enemy that will be in my game, but the enemies will all be different sizes. Is there a way to make the death sprite's size match any enemy's size without having to make a new death sprite for each enemy?
 

Slyddar

Member
If you use sprite_get_width(sprite_index) and sprite_get_height(sprite_index) at death, you can then use those to scale the death sprite accordingly. You would just need to compare it to the original death sprite size to get the scale factor.
 
M

MizzyV

Guest
how do i go from a width and height to the scale factor needed for the death sprite?
 

Slyddar

Member
If your original death animation is 32 x 32, and you have an enemy that is 48 x 48, you need to scale the animation up. The scale factor is just the new size divided by the old size, so 48/32, which is 1.5. So when you create the death animation, you set it's image_xscale and image_yscale to 1.5.
 
M

MizzyV

Guest
Thanks it worked! although for the y scale factor it ended up being old size divided by new size while it was new/old for the x. it works now though, thanks!
 
Last edited by a moderator:
Top