Animation names as a number

Get help using Construct 2

Post » Thu Sep 13, 2012 1:28 am

In C2 I can name my animations anything as long as it has an alpha numeric number in it. Problem is, I want to name my animations "1", "2", "3", etc. so something like this is possible.

set animation to variable playerNumber

Variable playerNumber needs to be type "number" because mathematical operations are performed on it. Anyway to get around this so I dont' have to keep doing "if playerNumber = [X], set set animation to "player[X]Animation" over and over?
B
51
S
13
G
8
Posts: 194
Reputation: 7,311

Post » Thu Sep 13, 2012 1:33 am

Ahh, I just realized from my limited programming experience that the animation name is a string and the number is something akin to a float so they can't be compared, and not being able to put pure numbers as animation names was likely designed to prevent confusion.

I'll leave this thread up so it's searchable in case something else has the same question
B
51
S
13
G
8
Posts: 194
Reputation: 7,311

Post » Thu Sep 13, 2012 1:33 am

Name your animations "Animation1", "Animation2", "Animation3", etc.

Then use :

set animation to : "Animation" & str(playerNumber)
B
52
S
10
G
8
Posts: 44
Reputation: 9,097

Post » Thu Sep 13, 2012 3:28 am

Ahh don't know why I didn't think of that. Thanks Albatr.
B
51
S
13
G
8
Posts: 194
Reputation: 7,311

Post » Thu Sep 13, 2012 2:22 pm

[QUOTE=Albatr] Name your animations "Animation1", "Animation2", "Animation3", etc.

Then use :

set animation to : "Animation" & str(playerNumber)[/QUOTE]


[QUOTE=Mulkaccino] Ahh don't know why I didn't think of that. Thanks Albatr.[/QUOTE]


set animation to: "Animation" & randomNumber;

You don't need the str() there. So, you can make math to achieve what you need, like:

set animation to: "Animation" & randomNumber*randomNumber/randomNumber+randomNumber;

I tested this way and is working fine.TELLES08082012-09-13 14:23:52
ImageImageImageImageImageImage
B
93
S
20
G
13
Posts: 1,215
Reputation: 18,990


Return to How do I....?

Who is online

Users browsing this forum: BACLog, Kagubro and 17 guests