How do I check the animation frame of 10 instances

Get help using Construct 2

Post » Thu Oct 20, 2016 10:30 am

I want to check if the frame of 10 instances is the same at an event and if they are greater than 0 in another.

I am trying:

- to check if all the instances or some of them have the same frame:
pick all sprite
sprite is on-screen
for each sprite
sprite animation frame = sprite.animationframe

- to check if the frame of all the instances are greater than 0:
pick all sprite
sprite is on-screen
sprite animation frame > 0
Last edited by Braus on Thu Oct 20, 2016 1:17 pm, edited 1 time in total.
B
4
S
2
Posts: 123
Reputation: 846

Post » Thu Oct 20, 2016 12:16 pm

For each (Object)
Sprite is on-screen
Sprite Animation Frame > 0
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,461

Post » Thu Oct 20, 2016 12:25 pm

Whiteclaws wrote:For each (Object)
Sprite is on-screen
Sprite Animation Frame > 0


It's not working. If I change the frame of one of the instances, I get the answer.
B
4
S
2
Posts: 123
Reputation: 846

Post » Thu Oct 20, 2016 3:52 pm

'mFrame' being max count of frames.

Local variable 'OnScreen'
Top level event : is on screen
action ... set variable OnScreen to Sprite.pickedcount
Sub event : Same event: System > For "i" = 0 to mFrame
sub event : Sprite > Compare frame > frame = loopindex("i")
In same event : System > compare 2 values .. 1st 'OnScreen' ... = .. 2nd Sprite.pickedcount
action > stop loop
action > whatever you like, because if this condition is true, they all have the same animation frame, set a local variable or so

The other
Local variable 'OnScreen'
Top level event : is on screen
action ... set variable OnScreen to Sprite.pickedcount
sub event : sprite animation frame > 0
sub event : system compare 2 values ... 1st OnScreen ... = .. 2nd Sprite.pickedcount
action ... when this actions run, there is no sprite on screen with frame = zero
B
33
S
18
G
27
Posts: 2,441
Reputation: 20,346

Post » Fri Oct 21, 2016 4:59 pm

1: I need to check if two or more instances are showing the same frame. if not the game goes ahead.

2: It works well. Thanks :D
B
4
S
2
Posts: 123
Reputation: 846

Post » Fri Oct 21, 2016 6:28 pm

Instance variable 'ConfessColor'
'mFrame' being max count of frames.

Top event :Is on screen.
(might need an action here ... set Sprite.ConfessColor to zero .. but i dont think it is needed)
Sub event: System > For "i" = 0 to mFrame
Same event : Sprite > Compare frame = frame = loopindex("i")
action set instance variable Sprite.ConfessColor to Sprite.pickedcount

Sub event under top parent : System > Pick highest .... Sprite.ConfessColor
same event : system compare 2 values > Sprite.ConfessColor .. greater than ... 1
action ... whatever you need, because if those actions run there are at least 2 sprites with the same frame. Understand that at this point only the sprites with Sprite.ConfessColor .. greater than ... 1 are picked. If you need to adress more sprites, you need a new top level event to start with.Preferable a function.
B
33
S
18
G
27
Posts: 2,441
Reputation: 20,346

Post » Fri Oct 21, 2016 9:03 pm

Great! It works like a charm. Thank you very much.
B
4
S
2
Posts: 123
Reputation: 846


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests