Python: refer to instance from event

This forum is currently in read-only mode.
  • Let's say I have multiple instances of a sprite object called box. I want each one to be destroyed when the user clicks on it. This is not difficult. I just make the event "On Left Clicked on box" and the action "box: Destroy". But what if I want to use a Python script in the place of the action? "box.Destroy()" doesn't work because it thinks I'm referring to box[0] no matter which box I clicked. So how do I specifically refer to the instance that triggered the event? I'm hoping for a solution that I can apply to any event or action, not just this particular example.

    Thanks in advance.

  • To destroy the first picked "box" Sprite use "SOL":

    To destroy all the picked "box" Sprites:

    for obj in

    "SOL" stands for Selected Object List.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you, that's perfect. Can you refer me to a more in-depth explanation of the SOL and what goes in it and when?

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