0 Favourites

Instance deletion - by user

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

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

  • 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?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Here I made an example, left click the image to select then click the delete button to delete the selected instance.

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

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

    Your example proved to be most helpful.

  • Glad to help, good luck with your game

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