Selection Example - CodeAlpaca

Area Selection Example

Selection Tool


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. :llama:


alpaca right here


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



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


pretty sure it’s discourse that controls the emojis