destroy with certain instance variable

0 favourites
  • 7 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I've searched but I can't find anything with this particular thing I'm trying to do so I hope you can help me!

    I have a trash can button, and when I press that I want to destroy instances with a certain instance variable. I know how to do it if it's just one object with different instances, but I don't know how to do it with different objects at the same time.

    Hope you understand!

  • Put everything in a Family, with that variable, then you can just do Pick Family.Var = X -> Family.Destroy

  • Thanks! Could you explain just a bit more how I do that, I mean, do I add a condition to when the trash can sprite is being clicked? Do I choose Pick by Comparison there? I'm just so confused. When I choose Pick by comparison, it says "expression" and I cant find the variable I've created there so I don't get it.

    As you can hear, I'm still learning hehe. Not used to using variables.

  • You can simply do Family > Compare Variable. The actions will only apply to the objects of the family that fulfill that condition

    See How events work

  • Ok but hm.. The thing I'm trying to do is, (it's an interior decorating game) create a bunch of sprites here and there. And then you can select one sprite (you click on it and a small menu appears). Then you can rotate it and so on, and also delete it.

    So if the user has created multiple instances of a table for example, I only want the selected table to be destroyed and not all instances.

    When I tried to put all furniture sprites in a family and add a variable to the family, then it destroys all the furniture :/

    Here is an test version so you can see https://dl.dropboxusercontent.com/u/624 ... utton.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't work with both object types, just the one. 'selected' is accessible from each object now. You can do this either way: use only Family, or use only each object type:

    On tap furniture -> furniture:selected=1

    OR

    On tap chair -> chair:selected=1

    Event 2 is correct.

    (I'd suggest using 'On touched object' - 'On tap' is a specific gesture, and doesn't always work as you'd expect, for simple selections).

  • Read about Families here. You can't mix families and the objects they contain. If you have a condition that uses a family, the action also has to use the family, and not a single object from it

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