How do I delete created objects?

Get help using Construct 2

Post » Tue Jun 14, 2016 6:19 am

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.
Image

Now I want it to destroy the object behind the corresponding item from fakefam whenever I click on fakefam item again.
B
11
S
3
Posts: 44
Reputation: 713

Post » Tue Jun 14, 2016 6:27 am

Create a global variable (name it ObjectUID or osmething), and right after creating the object, put this in between Create Object and Set Position:
Code: Select all
int(ObjectName.UID)


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.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Tue Jun 14, 2016 6:36 am

LaDestitute wrote:Create a global variable (name it ObjectUID or osmething), and right after creating the object, put this in between Create Object and Set Position:
Code: Select all
int(ObjectName.UID)


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?
B
11
S
3
Posts: 44
Reputation: 713

Post » Tue Jun 14, 2016 6:45 am

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.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Tue Jun 14, 2016 7:04 am

LaDestitute wrote: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:
Image

As for now it destroy the red object right away.
B
11
S
3
Posts: 44
Reputation: 713

Post » Tue Jun 14, 2016 7:16 am

Yeah, it looks like you did it right.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Tue Jun 14, 2016 7:26 am

LaDestitute wrote: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:
Image
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
Image
Image
Hi, Hello and Hey are separated text objects that belong to Family1
B
11
S
3
Posts: 44
Reputation: 713

Post » Tue Jun 14, 2016 10:50 am

anyone got any suggestions, how can I overcome this issue?
B
11
S
3
Posts: 44
Reputation: 713

Post » Tue Jun 14, 2016 1:27 pm

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
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Jun 14, 2016 2:13 pm

99Instances2Go wrote: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?
B
11
S
3
Posts: 44
Reputation: 713

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests