Instance deletion - by user

Get help using Construct 2

Post » Wed May 31, 2017 5:57 pm

Okay, long story short, I am creating a dress up game. For reasons. And so far, I have it set up that the user can go to the menu, and click on the thumbnail for an accessory which will spawn onto the layout as a drag and drop behavior object. The user has many to choose from, and can spawn more than one of that object.

My question: I want the user to be able to delete any of the instances that they desire. Maybe by clicking on it and then clicking a delete button? However, I don't want the button click to delete ALL instances of that object--just the desired one.

How would I go about doing this?

Thank you in advanced. :D
B
14
S
4
G
1
Posts: 24
Reputation: 1,609

Post » Wed May 31, 2017 6:04 pm

add an id to the instances as instance variable, also add a global variable ID, set the global one to 1 and the instance one to 0. When the player selects the dress set the global value to the instance variable value, then add event to check if object.ID == Global.ID and button1 pressed then as action destroy object.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Wed May 31, 2017 6:20 pm

imhotep22 wrote:add an id to the instances as instance variable, also add a global variable ID, set the global one to 1 and the instance one to 0. When the player selects the dress set the global value to the instance variable value, then add event to check if object.ID == Global.ID and button1 pressed then as action destroy object.


SUPER helpful answer. I think I'm just being dumb, and am sure that I am doing something wrong; because it's deleting all the instances of that object. Do you have a quick example?
B
14
S
4
G
1
Posts: 24
Reputation: 1,609

Post » Wed May 31, 2017 6:36 pm

Here I made an example, left click the image to select then click the delete button to delete the selected instance.

https://www.dropbox.com/s/1fxllo6elggld ... .capx?dl=0
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Wed May 31, 2017 6:42 pm

imhotep22 wrote:Here I made an example, left click the image to select then click the delete button to delete the selected instance.

https://www.dropbox.com/s/1fxllo6elggld ... .capx?dl=0


Ah-ha! I was trying to pull the wrong variable. I found my problem and have it working. Thank you so much. :D

Your example proved to be most helpful.
B
14
S
4
G
1
Posts: 24
Reputation: 1,609

Post » Wed May 31, 2017 6:45 pm

Glad to help, good luck with your game :D
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 33 guests