[SOLVED] Troubles to setup Viewport in AGS 3.5.0

Started by Empress Owl, Mon 20/04/2020 23:45:01

Previous topic - Next topic

Empress Owl

Hi everybody !

I am trying to get this "Viewport" fonction work, but I feel like I'm going nowhere... :-[
If I understood well, the new AGS release (3.5.0) has changed the way to make it (?) ; but I can't find a good script anywhere...

My game resolution is 320x200.
My character is entering the room from the right edge.
I'd like them to stop at around x = 250 (which they actually does).
There is another character on the left edge of the screen, who starts talking ;
But since the camera is still centered on the player's character,  we can't see them.
I'd like the camera to keep scrolling on the left (until the x = 0 point) when the player's character stops, so we can see both characters on the screen...
Any idea, please ?

:)

Crimson Wizard

Quote from: Empress Owl on Mon 20/04/2020 23:45:01
I am trying to get this "Viewport" fonction work, but I feel like I'm going nowhere... :-[
If I understood well, the new AGS release (3.5.0) has changed the way to make it (?) ; but I can't find a good script anywhere...

Hello, there's a page in the manual that explains new system and how to change from old functions to new ones: https://github.com/adventuregamestudio/ags-manual/wiki/UpgradeTo35#new-viewportcamera-system

(If you prefer to keep using old functions, you may set General Settings - Backwards Compatibility - Script compatibility level to 3.4.1, that will return old functions back, although I still recommend learning new ones :))

With the new functions you move the camera around your room by using Game.Camera.X, Game.Camera.Y and Game.Camera.SetAt(x,y) function.

Empress Owl

Thank you for your help, Crimson Wizard !

I had a look at the manual... I tried this :

Code: ags
  player.Walk(250, 220, eBlock, eAnywhere);
  Game.Camera.AutoTracking = false;
  while (Game.Camera.X > 0)
  {
    Game.Camera.SetAt(Game.Camera.X-1, Game.Camera.Y);
  }


in the "function room_FirstLoad()" section, but it doesn't scroll, the camera gets instantly to X=0...
What am I doing wrong ?  :confused:

Crimson Wizard

#3
You need to add "Wait(1);" in your loop. Wait function allows engine to redraw the game in the midst of a script function. Otherwise you just move camera in one go before anything could be put on screen.

You may have to experiment, adjusting number of pixels added to coordinate and delay of Wait, to achieve good results.

Empress Owl

It works ! great
Thank you very much !!  ;-D

SMF spam blocked by CleanTalk