Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: PERXEO on Fri 26/05/2023 12:02:22

Title: View doesn't show all the frames.
Post by: PERXEO on Fri 26/05/2023 12:02:22
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
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!!
Title: Re: View doesn't show all the frames.
Post by: Snarky on Fri 26/05/2023 14:58:25
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) Select
  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.
Title: Re: View doesn't show all the frames.
Post by: PERXEO on Fri 26/05/2023 16:12:17
Thanks for the answer ... ill'l try to do it!!