Check if all instances are a certain frame (SOLVED)

Discussion and feedback on Construct 2

Post » Sat Feb 04, 2017 9:05 am

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!
Last edited by Ninjadoodle on Sun Feb 05, 2017 10:14 am, edited 1 time in total.
B
44
S
22
G
9
Posts: 142
Reputation: 9,053

Post » Sat Feb 04, 2017 11:11 am

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Feb 05, 2017 9:46 am

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!
B
44
S
22
G
9
Posts: 142
Reputation: 9,053


Return to Construct 2 General

Who is online

Users browsing this forum: Sockratease and 4 guests