How do I use multiple individually selectable objects?

0 favourites
  • 5 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • I’m working on a management game, and there are going to be, on a map, 60 or 70 different purchasable buildings. Each one will have different information. I don’t want to make each one a separate sprite, and am using instance variables. I want to be able to click on each building from the map, and have a bar on the side that shows whether or not it’s been purchased or not, as well as its name and other information about it. Is there a way to link objects to local variables? Each of my buildings has a name, as a local variable, and I want it displayed on the side of the screen when I click on the building. Is there a way I can automatically have it set the text on the side of my screen to match the local variable of each building when I click on it, like I might with a global variable? I know I could have a separate event for every single building set the text as the name of that building when I click on it, but that seems like an unnecessary hassle. I’ve run into another problem. As I said before, I want each building to be individually purchasable, but how do I tell Construct what building is selected. I thought that I would just add a “selected” local variable to the buildings that would be 0 by default, and would be set to 1 if it was clicked on, and to zero again after you clicked on another building (and then that other building would be 1) so it would only let you purchase the building when the value was 1, and then it would know which building to change the “purchased” local variable of. The problem is, I can’t figure out how to trigger an event to set the “selected” variable back to zero. If I click on a couple of buildings, and then the purchase button, it will purchase all of them. How do I keep just one building selected at one?



  • I meant instance variables. Replace all of the times I referred to local variables with instance variables.

  • 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 on the building it should be the only picked building, so just set your text object to building.Name, or whatever your instance variable is. An alternative for the Selected instance variable is a Global that is set to the UID of the currently selected building. Then whenever you need to do something with that building, you can pick it by UID, with that global. Using an instance variable can be done, but you need a Pick all buildings first, so you can set the value to 0, then when you pop back to the top level you set the selected value to 1.

    It would be easier if you posted a CAPX. It will save time for any further questions.

  • How might I provide you with a CAPX? And, while I'm replying, how might I set a Global to the UID of a currently selected building, and what do you mean by selected?


  • Use a service like, to upload a CAPX file (Save as Single File...).

    You said you click on a building, so you should have something like "On touched object X", so X is selected at that point, and you can save it's UID to a global: gvar = X.UID

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