0 Favourites

Check if all instances are a certain frame (SOLVED)

  • Hi guys

    I need to loop through all the instances of a sprite on the stage, and test whether the instances current frame, is equal to a frame preset in the instances "instance variable".

    All of the instance on the stage must pass this before the level is solved.

    ***

    Example - instance1 has its variable set to 2, and instance2 has its variable set to 4.

    This is just mockup code ...

    if instance1.frame == instance1.instanceVariable (2)

    and instance2.frame == instance2.instanceVariable (4)

    then

    do something...

    ***

    Could someone help me to get this working as a loop?

    Thank you very much in advance!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I would ...

    Add a instance boolean 'Solved'.

    Besides the instance variable 'Frame2Solve' (number)

    Then

    Event blok 1

    System > For each Sprite

    Sprite > Compare frame .... = ? .. 'Frame2Solve'

    _________Sprite > Set boolean 'Solved' to true

    Event blok 2

    Sprite > Is boolean instance variable set 'Solved'

    System > Compare 2 values ... Sprite.count ... =? ... Sprite.PickedCount

    ................................. Actions ... if true ... things are solved/

    Additional:

    The first event block is not needed IF you set the boolean 'Solved' on the moment that the player solves a frame.

    Better for performance.

  • Hi 99Instances2Go

    Thanks heaps for your help! I've tried this but still can't get it working. Even after I unscramble all the letters, nothing happens.

    I know it's something to do with the loop, as it's one area of C2 which I still don't completely understand.

    Not really sure how to event this properly. If you have any more suggestions that would be awesome

    *** EDIT ***

    Scratch that! I managed to figure it out

    There was a small issue with my events, but now it's working perfectly.

    Thank you again for your help!

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