# Area Selection Example

Ever feel the need to be able to select specific parts of your game? Well now you can with this simple Area Select tool! I thought of making this a while ago but never got around to doing it until now, but it only took me a couple of minutes to make and I think it will be quite useful for some people. I will probably update this later with a few of the ideas I have, but for now, it is fully functional.

# How to set up Area Select

• Copy and Import the code in the â€śSelected Areaâ€ť object.
• Make sure that the sprite is 32x32 (The sprite can be a different size, but I would just need to add an input for that)

# How it work

• I first do â€śObjectX-MouseXâ€ť. This is to find the distance between them on the X plane. (This value will now be referred to as DistX)
• I then do â€śMath.abs(DistX*3.125)â€ť. I find the Absolute value because I do not want a negative number. The *3.125 is that specific number because 100/32 = 3.125. (This value is used for the â€śXâ€ť input on the Size behavior)
• Doing this alone will not work because the sprite expands in both directions equally, so I must account for this and adjust the objectâ€™s position
• I do â€śObjectX+DistX*(-1)/2â€ť. DistX*(-1) is required to move the object in the direction of the hand. The /2 is to get half of the distance between the object and the mouse because I only need to transfer half of the sprite in that direction. I then + the original X position to keep the corner in the correct sport.
• I then repeat the process fo the objectâ€™s Y as well.

If you have any bug reports, suggestions, or thoughts, let me know.
And yes, I did just copy and paste the format JR used for the Camera+ example, but only because I really liked the layout of it and thought it was quite effective.
https://flowlab.io/game/play/2177293

8 Likes

alpaca right here

2 Likes

Sadly I have to type :llama : to get it, grazer should change it to :alpaca:

2 Likes

# Update

Added an example in the 2nd level in how it could be used

2 Likes

pretty sure itâ€™s discourse that controls the emojis

2 Likes