Issue with animating a character while moving it

Started by johanvepa, Fri 30/09/2016 23:34:57

Previous topic - Next topic

johanvepa

Last one for the evening (roll)

At a certain point in my game, I'd like a certain character to animate while moving towards another character. Not the walk command, since the animation is to be done only once (if it repeats it'll look silly). The animation is that of disappearing into the other character.

trash is a Character variable. itemcarried determines if the relevant other character is currently in position. This all works.

Code: ags
function catchtrash()
{
  if ((trash != null) && (trash.Frame == 0) && (itemcarried != cTrashbin))
  {
    trash.ChangeView(2);
    trash.Animate(1, 4, eOnce, eNoBlock, eForwards); //nÃ¥r animation er bagved move, vil den ikke move
    trash.Move(cTrashbin.x, cTrashbin.y, eNoBlock, eAnywhere); //nÃ¥r move er bagved animation, sker der noget med animation
    cTrashbintimer = 0;
    GiveScore(1);
    bScore.Text = String.Format("%d", game.score);
  }
}


If trash.animate is set to operate after trash.move, then it animates but doesn't move. This is explained in the manual that the move command is stopped by the animate command. So that makes sense. I try to get around it by putting trash.animate before trash.move.

The strange things:
If trash.animate is set to operate before trash.move, then the trash moves and animates, but it animates twice. First it animates while moving, then it animates again.

There are several characters that can be the variable trash. If the function operates first on one of these characters, then another, then the first character to be 'trash' will operate as described, moving but animating twice. If another character is then subject to being 'trash', then the animation first plays without moving, then it moves while animating again, and finally it animates a third time.

Any thoughts?

Khris

Did you try calling .Animate non-blocking, then .Move blocking?

SMF spam blocked by CleanTalk