View doesn't show all the frames.

Started by PERXEO, Fri 26/05/2023 12:02:22

Previous topic - Next topic

PERXEO

I want to make a cutscene animation, in which my character uses a skateboard to go from one side of a room to the other. During this movement (that I'm going to do with programming as you can see in my snippet of code), I want a view to be shown in which the character goes "swinging his arms" as if he were surfing. In a repeatedly_executed I have created this function
Code: ags
 int frame=0;
  if(GamePerxeo.SkatingActive)
  {
    player.UnlockView();
    //player.ChangeView(8);
    player.LockView(8);
    frame+=1;
    //player.Animate(8, 0);
    if(frame>=24)
    {
      frame=0;
    }
    player.Frame=frame;
    posPlayerx+=10;
    player.x=posPlayerx;
    skate.Visible=true;

view 8 is the view where the player is over the skateboard in a loop waving their arms.
skate is an object with represents the skateboard.

With the previous code the player is moving from a side to the other but only shows the firts frame of the view. I want to show all the frames of this view in a loop...until my player comes to the end.

Thanks for your help!!

Snarky

#1
As a useful rule of thumb: if you are a beginner, and you are putting code in repeatedly_execute(), you are almost certainly doing something wrong.

From your description, the better way to do this would be, from wherever you start the cutscene:

Code: ags
  player.ChangeView(8);
  player.SetWalkSpeed(10,10);
  player.AnimationSpeed = 0;
  player.MovementLinkedToAnimation = false;
  player.Walk(DEST_X, DEST_Y); // Where DEST_X/Y are where you want the character to go

This simply tells it to play the animation you want while "walking" where the character needs to go, at the correct speed, and "gliding" along the way (movement not linked to animation, though with the animation delay set to 0, that shouldn't matter).

Then afterwards you'd need to reset all the settings to what they were.

PERXEO

#2
Thanks for the answer ... ill'l try to do it!!

SMF spam blocked by CleanTalk