"Is Equal to Any From List" Condition

Get help using Construct 2

Post » Wed Mar 12, 2014 9:15 pm

Hello,

I've spent a bit of time searching Google and these forums for help with this issue, but haven't had much luck. Hopefully someone on here can help me. I'm having a bit of trouble creating a condition which requires an animation from be equal to any one number from a list.
Essentially, if the AnimationFrame is equal to any one of these numbers (0, 4, 8, 12, 16, or 20), then the event will occur. However, I can't seem to find the right expression or method for executing something like that. It doesn't seem like 'choose' or 'random' would work, because then the event wouldn't occur in every instance. I need something that would basically look like:
AnimationFrame = any(0, 4, 8, 12, 16, 20)

Any help you can offer would be appreciated. Feels like I'm missing something blatantly obvious, here.
B
3
Posts: 6
Reputation: 212

Post » Wed Mar 12, 2014 9:34 pm

You need to make an "Or" Block.

Then it looks like:

AnimationFrame = 0
OR
AnimationFrame = 4
OR
AnimationFrame = 8

... and so on.

Right click the condition, then choose "make OR block".
B
10
S
2
Posts: 135
Reputation: 1,090

Post » Wed Mar 12, 2014 9:38 pm

Ah, thanks. I was hoping there was a way around doing that. That's what I've been using for a while, but wanted to see if I could condense it with a couple of expressions. Thanks for your help!
B
3
Posts: 6
Reputation: 212

Post » Wed Mar 12, 2014 9:45 pm

Maybe there is an "easier" way for this. But I don't know a better solution, as this is already simple if you dont have hundrets of cases to check. :D
B
10
S
2
Posts: 135
Reputation: 1,090

Post » Wed Mar 12, 2014 9:56 pm

In your case you could compare (sprite.animationframe % 4) = 0

(x % 4 will return the rest of the division x/4)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Wed Mar 12, 2014 11:26 pm

@Aphrodite is right. % (mod) is a very useful operator I find myself using a lot in C2
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Thu Mar 13, 2014 12:09 am

@Aphrodite

Good to know. I wondered if such an operator existed.
B
10
S
2
Posts: 135
Reputation: 1,090


Return to How do I....?

Who is online

Users browsing this forum: Artcadev and 36 guests