How do I cycle through animations sequentially?

0 favourites
  • 10 posts
From the Asset Store
Perfect for your zombie game! Animated from motion capture data Left, Right, Top Down!
  • 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?

  • 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 ...

  • !!!!!!!! DOH! The "&" symbol!! Totally forgot about that. Ima try that when i get home tonight. Thanx!

  • 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".

  • 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.

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

    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.

    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

  • Your images aren't visible for me..

  • 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.

    <expression> & <expression>[/code:2oep78ns]
    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:2oep78ns]"Some String " & Variable1[/code:2oep78ns]
    Assuming the value of Variable1 is 5, the resulting string would be "Some String 5".
    
    Note that the concatenation operator is [i]not[/i] encased in quotes, as it is an [i]operator[/i] and not part of an [i]operand[/i].
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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).

  • Glad you got it working! And yeah, I can see the pictures now.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)