Scroll blocking

Started by Peegee, Sun 25/09/2022 09:41:19

Previous topic - Next topic

Peegee

Hello. For a beginning of level, I blocked the scrolling of the camera in x . The character could therefore move in x and y, but the auto tracking only worked in y, in height; Then I unlocked the auto tracking. I used this code for that:


Code: ags

function room_Load()
{
  Game.Camera.AutoTracking=false; 
}


function late_repeatedly_execute_always()
{
   if (!Game.Camera.AutoTracking)
   Game.Camera.SetAt(800, player.y - 300);
}

For a new level, I want to do the same thing, but in y. That is to say that I want the camera to follow the character in x, so horizontally from left to right, but not in height. I try different parameters but it doesn't work, the auto tracking is not done in x. Someone would have any idea ?

Code: ags
function late_repeatedly_execute_always()
{
   if (!Game.Camera.AutoTracking)
 

   Game.Camera.SetAt(0, player.x + 940);
   
}


I risk being slapped with a wet trout but I can't get a nice display of codes in brown, yet I use
Code: ags
 and 
.


eri0o

When you use Game.Camera.SetAt, it already will turn off auto tracking. But if you want to "follow in X", means the X position of the camera has to be a function of the player X position. And not following in Y, means the Y position is a function of something that isn't the player Y position.

Khris

You're supposed to pass first x then y, so you probably need

Code: ags
  Game.Camera.SetAt(player.x - 940, 0);

Peegee

Yes !
It works (the character is at the bottom left of the screen), I don't really know how, I don't really understand these commands... But it works as I wanted, thank you !!

Code: ags

function late_repeatedly_execute_always()
{
   if (!Game.Camera.AutoTracking)

     Game.Camera.SetAt(player.x - 320, 930); 
}

SMF spam blocked by CleanTalk