How do I detect selected (touched) object?

0 favourites
  • 5 posts
From the Asset Store
Surena Touch
$2.50 USD
A wrap from official Touch plugin to export touch/mouse input to other plugins.
  • I have many objects on the layout. When I touch one object, it should be selected (highlighted) to be handled by some control buttons, which I created to rotate and move the selected (touched) object.

    My buttons (Rotate - Mirror - Change Color) should apply the action to ONLY a selected object (by touch) on the layout! Is there a way to detect the selected or touched object? Any help please?

  • Several ways...

    Built into the touch and mouse objects are "On-object-touched" or "Is-touching-object" and "On-object-clicked" or you can do a Mouse-button-down&Cursor-over-object condition.

    Or you could use an instance variable inside all your objects for IsSelected=0 and change just the selected object to IsSelected=1 when you want it to be controlled and toggle off when out of control... your control events would just need to condition for "IsSelected=1".

  • Several ways...

    Built into the touch and mouse objects are "On-object-touched" or "Is-touching-object" and "On-object-clicked" or you can do a Mouse-button-down&Cursor-over-object condition.

    Or you could use an instance variable inside all your objects for IsSelected=0 and change just the selected object to IsSelected=1 when you want it to be controlled and toggle off when out of control... your control events would just need to condition for "IsSelected=1".

    Thank you chrisinfinger,

    Ok, in this case the "Control" buttons in the layout will look for an object which has the variable "IsSelected=1" to apply the action on it.

    So, the question is: Should all objects be evaluated to know which one has the variable "IsSelected=1"???

    Thanks

  • If you regroup all the possibly moving objects in a family and make the "IsSelected" (make it a boolean variable by the way) a family instance variable.

    This way, you check for the instance of the object type member of the family that "IsSelected" and in a single condition you are only picking one instance of one object type.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you regroup all the possibly moving objects in a family and make the "IsSelected" (make it a boolean variable by the way) a family instance variable.

    This way, you check for the instance of the object type member of the family that "IsSelected" and in a single condition you are only picking one instance of one object type.

    Thank you so much, Kyatric!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)