• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Animation happens so fast that I can't see it on screen

T

Tchangla

Guest
I'm trying that at a certain point of the code trigger an animation of an attack.

In the draw code, i have this

Code:
if(batAnimationOn==1){
    draw_sprite( attack, batAnimation,42, 80);
}
and in the step, this

Code:
if(arrayTurn>=3 && arrayTurn<=5){
            if(random(1) > 0.5){target=2}else{target=1}
            damage=battle_stats[arrayTurn,10]-battle_stats[target,12];
            if(damage<=0){damage=0;}
            battle_stats[target,4]-=damage;
            batAnimationOn=1;
            {
                var i;
                for (i = 0; i < 4; i += 1)
                {
                    batAnimation=i;
                }
            }
            batAnimationOn=0;
            showDamage=1;
            doAction=0;
But the animations seems to go too fast and don't show on screen. Are better ways out there to trigger an animation from code? (ah, also I need that until the animation isn't done, the following code isn't executed).
 
R

rui.rosario

Guest
Two things:

1st, you are making a loop in the code to assign the animation step. This means the code following that loop won't execute until that loop is finished, and the Draw Event happens on a totally different place after the step event, so in fact you are never actually animating.

2nd, look at the Animation End event, it triggers code when the animation is finished playing, which means you can change that logic to something like:

Code:
/// Step event ///

// Do stuff
if (shouldAnimate) {
    image_speed = 1; // Set the image speed to animate
}

/// Animation End ///
image_speed = 0; // Stop animation
image_index = 0; // You might want to do this, just as an extra step to ensure the image_index you need

// Do remaining logic for the animation end
 
T

Tchangla

Guest
This would work with any animations? Because my problem here is that it isn't the object animation for itself (like it would be a character obj changing its animations), but it is the battle engine for the game (that will trigger different animations depending on what is happening, like, action1 will do X animation, and so on).
 
R

rui.rosario

Guest
Then you can see it in two different ways (depending on how you have your battle animations set up one can be easier to use than the other, or it can give you an idea to come up with a system yourself).

1st option would be to rely on the Animation End event, but this would trigger at the end of a Sprite animation, so you would have to make sure the sprite animations were in sync with the battle animations (not the best option out there).

2nd option, and the one I would consider more extensible / easy to maintain, was associate one animation with one timeline and this timeline can then run arbitrary code in certain moments. However, you wouldn't actually need to associate one timeline per animation, if you had X battle animations that had the same timings / the same movement / the same actions, you could then maybe reuse the timelines among those similar battle animations, but this would have to be tested by you.

The 2nd option is by far the best one in long term, in my opinion, but it depends on how you currently have your battle animations set up. If they already use timelines, then it becomes easy to alter. If not, you have to see if you can use timelines in parallel with your current battle animation system or even change your current battle animation system to support it.

Hope this gives you some idea of how to get around the problem

EDIT: I interpreted your reply as not being different sprite animations for the same object but as being a set of actions (movement, attack, etc) that together make a battle animation
 
S

Snail Man

Guest
Yeah, that should work for any animation on any object. If it's still too fast, you can set image_speed to a slightly lower number like 0.5 to ensure that its seen.

Edit: Ninja'd
 
T

Tchangla

Guest
I've managed to fix this. I have created an object for every animation ( any animation attack trigger an specific sound too).

Thanks for everything, your explanations gave me some ideas.
 
Top