How do I cycle through animations sequentially?

Get help using Construct 2

Post » Thu Dec 10, 2015 4:16 am

So I have two groups that basically start when the last one finishes. I would like for part of this process to go to the next animation in a sprite everytime the next group is active. Here is an idea:

Say their are 100 animations; Animation1, Animation2, Animation3, etc...
When the next group activates it would go from Animation1 to Animation2 and so forth.

Remember, their are only two groups so I cannot call each animation by name.
For everytime the next event triggered, the pseudocode I was thinking of went like this:

Global Variable: "BossNum = 1"
Set variable: BossNum = BossNum +1
Set animation to "Animation+BossNum"

In conclusion, is there another way to load the next animation without calling it by name,
OR
can the animations name be manipulated by a variable as listed in the pseudocode?
B
4
Posts: 6
Reputation: 212

Post » Thu Dec 10, 2015 9:02 am

Maybe I understand this wrong, but you postet the solution already.
If you named all of your animation like Animation1, Animation2, ....
Use ' Set animation to "Animation"&BossNum '
This will give you: Animation1, Animation2 ...
B
24
S
3
G
1
Posts: 454
Reputation: 2,171

Post » Fri Dec 11, 2015 12:17 pm

!!!!!!!! DOH! The "&" symbol!! Totally forgot about that. Ima try that when i get home tonight. Thanx!
B
4
Posts: 6
Reputation: 212

Post » Mon Dec 14, 2015 4:11 am

So the "&" sign didnt work :( So how about this,

how can an event trigger a random pick out of a list of animations in a sprite?


for instance:
If "event" then set animation to "random animation".
B
4
Posts: 6
Reputation: 212

Post » Mon Dec 14, 2015 4:17 am

Using concatenation(&) to programatically build an animation name should work fine. What's the exact expression you used to set the animation? A screenshot of the relevant events would also be helpful.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Mon Dec 14, 2015 5:45 pm

Alright so here is the list of animations within the sprite:

Image

Each animation represents a new "Boss".

The "Boss" stats such as speed, power, strength, etc... are controlled by the procedural manipulation of the base stat every time the "Boss" dies and the next event starts.

Image

I know the animations name is in quotation marks so the concatenation needs to be somehow enclosed in the quotations, ... i think?

Their are only 2 events, each placed in its own group.

I guess what I am struggling with is how to properly write the concatenation to get it to work

Image
Last edited by Yorksir on Tue Dec 15, 2015 12:15 am, edited 2 times in total.
B
4
Posts: 6
Reputation: 212

Post » Mon Dec 14, 2015 6:06 pm

Your images aren't visible for me..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 14, 2015 7:12 pm

I can't see your images either, but it sounds like you're doing the concatenation wrong. Concatenation(&) works like any other binary operator, such as + or -, with two operands.

Code: Select all
<expression> & <expression>

Where <expression> represents any expression, such as a string -- encased in quotes -- or a number -- no quotes. Note, however, that at least one of the expression must be a string to get a string result. So to concatenate a string with a variable, an example expression would be:

Code: Select all
"Some String " & Variable1

Assuming the value of Variable1 is 5, the resulting string would be "Some String 5".

Note that the concatenation operator is not encased in quotes, as it is an operator and not part of an operand.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Tue Dec 15, 2015 12:10 am

Thanks linkman2004! Your explanation was exactly it!

I wrote:

"Animation"&BossNum

BossNum is a global variable set to 1 and everytime the boss dies: BossNum = BossNum+1. Thus it consistently goes to the next animation. Lol, I didnt even think that would work since the variable lie's outside the quotation marks :)

Thanks again!

P.S. I just changed some settings, even though linkman2004 had the solution, let me know if you guys can see the pics (wanna make sure images work for future reference).
B
4
Posts: 6
Reputation: 212

Post » Tue Dec 15, 2015 12:24 am

Glad you got it working! And yeah, I can see the pictures now.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 30 guests