Legacy GM xscale & yscale based on distance to mouse

darijs1

Member
Since i recently figured out how to auto tile based on an objects xscale and yscale, i decided to try and make my own room editor within the game.

My problem is that i cant figure out how the get a perfect object scale from its original position to the mouse
Any ideas on how this can be done in code?
 

Attachments

Last edited:

Relic

Member
You can store and refer to variables that hold info about where the mouse was first clicked and where it is now.

In mouse down event:
orig_x=mouse_x

In mouse released event:
x_size= mouse_x-orig_x
image_xscale=x_size/sprite_width

That last line of code will perform the actual “perfect scaling” based on the size of the sprite and the size you want it to have. Repeat for y scaling too.
 

darijs1

Member
You can store and refer to variables that hold info about where the mouse was first clicked and where it is now.

In mouse down event:
orig_x=mouse_x

In mouse released event:
x_size= mouse_x-orig_x
image_xscale=x_size/sprite_width

That last line of code will perform the actual “perfect scaling” based on the size of the sprite and the size you want it to have. Repeat for y scaling too.
Thank you so much. This is what i was looking for.
 
Top