Instances and criteria

This forum is currently in read-only mode.
  • How do I let an event know which instance to choose, from a sprite object?

    Background info:

    • 1 sprite object creates every second an instance.
    • when an instance collides, it adds 1 to a global variable.
    • event created saying: if global variable = 2, start action.

    But the action then takes place involving all instances, even the ones that didn't trigger the event.

    An undesirable situation...

    Hopefully this description and my wish to select which instance I want to be affected by the action is clear enough.

  • No, that's not really clear enough. Type your event using pseudocode, or post a screenshot of your event, or better yet upload a .cap.

  • My second attempt to explain it:

    <img src="http://www.yoshimi.nl/images/instances.PNG">

  • Ah, I see. You have no condition that specifies which yellow block you want to change opacity on in event 18. Defining your condition based solely on a global variable doesn't give you any control over which object is picked.

    You'll need some extra conditions in there that specify your yellow block instances:

    +Is global variable 'Rij1 Counter' equal to 2
       +BlockYellow.Y is less than 420
       +OR
       +BlockYellow is overlapping Block1
       +OR
       +BlockYellow is overlapping Block2
          ->BlockYellow: Set opacity to 50
    [/code:35tfesr9]
    
    Though honestly I don't understand what you're using the global variable for so I don't know if that's necessary.
  • aha, it worked! Thanks.

    Also, I found out that when I entered two conditions (at 18), meant for two different instances (of the same sprite object), it didn't respond to "opacity yellow stone -50%".

    I created 18 twice, with 2 conditions within 1 event and it does what I want.

    ps: I typed earlier "the criteria is", but I of course I meant "the criteria are".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use private variables instead of a global variable. There is only one value of a global value. Each instance gets its own unique value with private variables.

  • Ok.

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