Animation starts at wrong character.x value [SOLVED]

Started by derrikk88, Mon 02/10/2017 18:44:03

Previous topic - Next topic

derrikk88

Hello guys,

i really dont know, why my animation starts if my player.x is < 300, because I wrote if player.x >300. What am I doing wrong? :confused:

Code: ags

function room_RepExec()
{
   // animation zombie
if (player.x >=300) {
  oZombieFenster.SetView(13, 0);
  oZombieFenster.Animate(0, 5, eRepeat, eNoBlock, eForwards);
}


If I turn the code to player.x <300, the animation is right. But it makes no sense :/

I am using the current beta 3.4.1 - Thanks so far

derrikk

Matti

#1
The problem might be that you trigger the animation every game loop (normally 40 times a second). So the animation can only proceed when the player walks off the area that is > 300 (and the animation is not triggered again).

Does this work?:
Code: ags
if (player.x >= 300 && !oZombieFenster.Animating) {
  oZombieFenster.SetView(13, 0);
  oZombieFenster.Animate(0, 5, eRepeat, eNoBlock, eForwards);
}

derrikk88

hey,

thank u very much for ur reply. Yes that works perfect! If i understand this correctly, the problem was that i didnt tell ags to start animation only if its not animated already?

Thanks again.

Matti

Exactly, !oZombieFenster.Animating is the same as oZombieFenster.Animating == false.

With (player.x >=300) as the only condition and the animation being non-blocking, the animation just keeps getting started and is never able to be played, unless player.x is < 300.

derrikk88

wow thank u so much for ur help, I really appreciate it. Now it makes sense again :-D

SMF spam blocked by CleanTalk