How to NOT click 2 objects at once?

Ganu

  • Posts: 224
Hi, I found a bug in my early phase game, there are round objects on the scene you can click on them drag and release button to shoot them, but when there are 2 objects really close to each other you can click them at once... Ahh my english is a bit weird these days... Look at the picture...
Currently waiting for joints in stencylworks.

Ryusui

  • Posts: 827
Two possibilities.

1. The cheap and dirty way: use a circular collision shape.

2. Use a Boolean Game Attribute. Check whether it's set when a shape is clicked; if it's not, set it. When the player releases the mouse, unset it.

In pseudocode:

Code: [Select]
When mouse is pressed on circle:
if not circle clicked?:
circle clicked? = true
(do whatever we need to with the circle)

When mouse is released:
circle clicked? = false
In the event of a firestorm, the salad bar will remain open.

Ganu

  • Posts: 224
But I`m using circular collision shape, but it registers clicks even out side of the objects collision shape, it registers clicks on whole sprite image.
Currently waiting for joints in stencylworks.

saulochina

  • Posts: 214
use "follow drag and drop" from the pre shiped behaviors. when configuring the behavior check the "moving on realese option" it's a good behavior and do not let you take two actors at same time.
Finding the fun!
Squib Wars. Now complete, and avaible for free on App Store! http://bit.ly/LxJ62L
https://www.facebook.com/twoheadedgames
Twitter: @saulochina
MSN: sauloj.china@hotmail.com

applaud

  • Posts: 370
Use the attribute solution then. You could even use some maths to determine which is closest to the click/tap in order to ascertain which the player was likely clicking. Then set the boolean attribute to true so the second actor doesn't get clicked.

Ganu

  • Posts: 224
Use the attribute solution then. You could even use some maths to determine which is closest to the click/tap in order to ascertain which the player was likely clicking. Then set the boolean attribute to true so the second actor doesn't get clicked.
That`s the best solution.
Currently waiting for joints in stencylworks.