How do I delete created objects?

0 favourites
  • 11 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello,

    I have a family named fakefam, it is a list of items, according to my event whenever I click on the fakefam items, it spawns an object (red) behind it.

    Now I want it to destroy the object behind the corresponding item from fakefam whenever I click on fakefam item again.

  • Create a global variable (name it ObjectUID or osmething), and right after creating the object, put this in between Create Object and Set Position:

    int(ObjectName.UID)[/code:1wbqwtjv]
    
    You can then refer back to this with objects you want to specifically manipulate or destroy by choosing Pick by UID and using the global variable as the UID.
  • Create a global variable (name it ObjectUID or osmething), and right after creating the object, put this in between Create Object and Set Position:

    int(ObjectName.UID)[/code:2q11up4f]
    
    You can then refer back to this with objects you want to specifically manipulate or destroy by choosing Pick by UID and using the global variable as the UID.
    

    Thank you for the suggestion, could you explain how to do the second part about the destroying by UID?

  • I forgot to mention to set the "int" thing to the global variable.

    As for the other thing, in add event, select the object you want, go down to "Misc", and select "Pick by unique ID", and enter the global variable's name as the UID. Then just put a Destroy action in the event, and it'll only act on said object that matches the UID and nothing else.

  • I forgot to mention to set the "int" thing to the global variable.

    As for the other thing, in add event, select the object you want, go down to "Misc", and select "Pick by unique ID", and enter the global variable's name as the UID. Then just put a Destroy action in the event, and it'll only act on said object that matches the UID and nothing else.

    Please, correct me if I'm wrong:

    As for now it destroy the red object right away.

  • Yeah, it looks like you did it right.

  • Yeah, it looks like you did it right.

    Unfortunately, it won't let me "toggle on/off" the red object.

    I guess there might be some misunderstanding, here is how the screen looks like:

    As you can see, that according to my event, whenever I press virus(1-12), red object shows up behind it.

    What I'm after is I want this object to be destroyed if I press on it again.

    For example, when I click on virus1, the red box shows up, when i click on it second time, it is being destroyed, while preserving other selections.

    For the sake of simplicity, I've created a new project with the following structure

    Hi, Hello and Hey are separated text objects that belong to Family1

  • anyone got any suggestions, how can I overcome this issue?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure why you want all diff. objects for those texts, instead of instances. That can give you troubles later on.

    But, here goes.

    https://drive.google.com/open?id=0B1SSu ... ElfaFA3azA

  • Not sure why you want all diff. objects for those texts, instead of instances. That can give you troubles later on.

    But, here goes.

    https://drive.google.com/open?id=0B1SSu ... ElfaFA3azA

    Thanks, that what I was aiming for. Later on I will be checking if the selection is correct, by comparing the selected text-items with the custom families of these text-items. Could you give me some information how similar effect can be achieved using instances?

  • Exactly the same way as with familys. Not pressing you to drop familys, just a bit afraid that making differend levels can get a bit complicated. But i can be wrong, because dunno where you gooing with this.

    Rule is, use instances when possible, coding gets easyer and slimmer. I think you got confused with the famely this problem (allready). Would you have used instances (and you pick them exactly the same way) i feel that you would have solved this by your own, not beeing confused by the family. Thats is the reason why i expressed my concerns.

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