[SOLVED] Undefined token 'SetViewport'

Started by TheNewSon, Tue 28/07/2020 15:00:22

Previous topic - Next topic

TheNewSon

Hello! I'm trying to use SetViewport to manually scroll a room rightwards, but in the room script, as I start typing set, I get no suggestions related to that function (same for ReleaseViewport). I've tried running it anyway, but then I get the message: Undefined token 'SetViewport'. Can someone kindly help me please? Suggestions are also welcome! Thanks in advance! :)

Wrong code:
Spoiler
Code: ags

function room_AfterFadeIn()
{
  for(int i = 0; i < 240; i++)
  {
    SetViewport(i,  0);
    Wait(1);
  }
  ReleaseViewport;
}
[close]
Correct code:
Code: ags

function room_AfterFadeIn()
{
  for(int i = 0; i < 240; i++)
  {
    Game.Camera.SetAt(i,  0);
    Wait(1);
  }
  Game.Camera.AutoTracking = true;
}

Crimson Wizard

#1
These functions are deprecated in 3.5.0. There's an article in the manual called "Upgrading to AGS 3.5" which explains the changes.

Instead of old Viewport use Game.Camera instead:
https://github.com/adventuregamestudio/ags-manual/wiki/UpgradeTo35#new-viewportcamera-system

Also, if you search for these functions (SetViewport, ReleaseViewport) in the manual, their pages will notify you of which functions to use instead.

TheNewSon

Crimson Wizard
Thank you very much! Looks like I've been reading an old version of the manual... My bad, sorry!  :-[

Crimson Wizard

Quote from: TheNewSon on Tue 28/07/2020 15:11:29
Crimson Wizard
Thank you very much! Looks like I've been reading an old version of the manual... My bad, sorry!  :-[

Yes, unfortunately that one had not been updated yet.
The wiki pages I've linked above is a "source" from which the manual is now generated.

But you also have an up-to-date manual with your Editor, you can bring it up with F1, or from start up menu too.

SMF spam blocked by CleanTalk