Spawn from click

I’d like to be able to drop an object (a rectangle is fine) anywhere I tap/click. Bonus points for tapping a placed object to remove it from screen.


Welcome to the ready community @bubbafrye!

This is a really good question.

To do what you wish for dropping an object anywhere, try this -

  • Create a Rectangle
  • Create a Circle (turn solid OFF and set opacity to 0%)
  • Set Rectangles physics and gravity on
  • Create a Variable and set it to be a Coordinate Variable

Use this code:

If you want a player to hold an object, you can use this reference:

  • Create a Solid Circle
  • Create a Solid Rectangle
  • Allow the Rectangle to have a “Join” Behavior to the Circle
  • Allow the Rectangle to have Physics & Gravity on

Use this code once you’ve done what’s above:

The Rectangle should then just fall off the screen normally

To receive points for clicking an object, try this -

  • Create a “Score” Variable
  • Set “Score” Variable to 0

Use this code for reference:

  • When Rectangle, Sensing, Clicked Down - “Score Variable,” Add 1 AND Recatangle, Appearance, Set Hidden - Yes

Thanks for the quick reply @Network5. Nice solution.

I can’t seem to figure out how to configure the variable. When I tap the ‘choose a behavior ‘ button, a ‘Configure the event…’ window appears, but there isn’t anything to do. Any suggestions?


Oh! I found it under the globe button. Global variable - got it.



Not a problem! Glad to help! :grinning:


Ok - 1 more thing. I am able to place rectangles fine, and I am able to hide them too. The problem is, I keep dropping a new tile on screen every time I remove one because both actions are tied to the tap.

Is there a way to add a conditional statement, like “if there is a square I tap, remove it, otherwise place a square”?

Thanks again.


To stop them from spawning, try this-

  • Keep everything from what I said before about tapping the screen to spawn rectangles, however -
  • Create a Variable called “Drop”
  • Add A Button and name it “Stop Dropping” (turn solid off)

Code this:

When you tap the button, the spawning should stop.

There is many other ways you can do this but this is just one example!


Cool code advice you gave.
Might be able to use your code to measure the difference in value between a touch coordinate and a sprites coordinate. A proper way to measure distances by minusing a variable from another variable