How do I check if the current animation is one in a list?

Get help using Construct 2

Post » Thu Oct 09, 2014 2:00 am

As part of my state system, I need to check if one of a couple different animations are playing, and if so set the player's state accordingly. I can figure out which animation is playing, but how do I check if it's one on the list? How do I make that list in the first place? And then setting the state I think can be handled by just setting it to the animation name, which I can already do. Thanks for the help!

tldr; How do I make a list of animation names that I can access in the event sheet, and how do I check if the current animation is in said list?
B
5
S
1
Posts: 59
Reputation: 497

Post » Thu Oct 09, 2014 5:16 am

Would just putting all your animation conditions in an OR block work?
Image
B
35
S
9
G
4
Posts: 201
Reputation: 5,170

Post » Thu Oct 09, 2014 8:51 am

For the list, learn up on arrays (1D array=list).
For checking if it's one in the list (array), use a For each loop to compare the animation name that's playing with each array item.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Oct 09, 2014 1:01 pm

Codah, thanks, but I already knew that was pretty much what I needed to do. I guess I should clarify I'm asking about the specifics of where in Construct do I find an array to put into an event sheet and then how exactly do I set up the for loop?
B
5
S
1
Posts: 59
Reputation: 497

Post » Fri Oct 10, 2014 10:14 am

ChefSeth wrote:Codah, thanks, but I already knew that was pretty much what I needed to do. I guess I should clarify I'm asking about the specifics of where in Construct do I find an array to put into an event sheet and then how exactly do I set up the for loop?


Yes specifics help. People asking the same question can mean very different things.

Right click on Object Types, choose Add new Object and choose "Array". You can add more than one. You can rename it. It will default to a 'list' length of 10 (i.e. Width of 10) if you look at its properties under Object Types Properties. Now read https://www.scirra.com/manual/108/array. Basically "Array:Set value VAL at POS" will set an item in the list.

Use Array:For each element to go through the array, comparing CurX with your value. Again, read the above section for details of using For Each. There's no need for me to retype the manual :) After reading, ask if you have any problems.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Oct 11, 2014 5:22 am

Thanks codah, this worked great. Reaaally speeds up writing the animation system
B
5
S
1
Posts: 59
Reputation: 497

Post » Sat Oct 11, 2014 9:58 am

ChefSeth wrote:Thanks codah, this worked great. Reaaally speeds up writing the animation system


Glad to hear it :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Buddhika, R0J0hound and 16 guests