How do I get clicked instance variable value?

0 favourites
  • 12 posts
From the Asset Store
Click! Click! 136 click sounds for your video games or media projects
  • I have 10 same sprites, some with same value of variable "Name" (string), and some with different value.

    I need to get "Name" of clicked sprite to change all sprites with same "name".

  • If you use the mouse object condition 'on object clicked' it will pick the instance you are clicking, then as an action you can set a variable to object.name and you have it stored.

  • If you use the mouse object condition 'on object clicked' it will pick the instance you are clicking, then as an action you can set a variable to object.name and you have it stored.

    I dont need to set variable, i need to get variable.

    For example i have 10 bushes, 5 roses and 5 daisies.

    I click for random buch and need to destroy all bushes of the same type.

  • When you click the bush it gets the variable from it but you need to store it somewhere to compare later. Then you can pick all instances again and limit them by where name = variable and destroy them.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When you click the bush it gets the variable from it but you need to store it somewhere to compare later. Then you can pick all instances again and limit them by where name = variable and destroy them.

    Yes. And that is my question - how to get variable to store... or... ahh, im starting to understand - when i clicked an object i already get all variables from it and just need to store that i need.

    Many thanks!

  • Nope. Still dont get how to do it.

    I have Mouse - On button Clicked... and then im stuck.

    Ok, I have "Console" text area... I know I can to add text to it.

    But which expression i have to use?

    There isn't something like Object.Get("Name")

  • Or Object.Name or similar.

  • When you click on the instance you are getting all of its data, but you must store it somewhere as I mentioned so on the actions right-side of the event sheet you can set a variable to object.name which will be the name variable of the one you just clicked.

  • Ok, finally get it =(

    It's ObjectName.VariableName

    Double sorry =)

    And triple thanks.

  • Aaaaaaand still im doing something wrong.

    I have object BUSH and 10 copies of it on Layout.

    BUSH have variables Key and Value. Key of each instance is the same, for example Rose, value is sequential number and different for each instance. And of course UID each unique.

    I have text area Debug.

    I have events:

    Mouse on Left button Clicked

    Sub-event:

    Text Name "Debug" -> Append BUSH.Key, Append BUSH.Value, Append BUSH.UID

    And output is always the same (from the first copie of BUSH on Layout - Rose 1 16) no matter which instance was clicked.

  • On button clicked is for a click anywhere, you need to use on object clicked and select the bush object.

  • I owe you a beer... >_>

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