Hi,
I've always been used to GetViewport but it seems Camera is the new way.
Ok. You get into a lift. Press floor button (gui) Lift and Char rises/lowers to the floor chosen. The lift arrives at the floor with character inside but the room top is not visible because the character is low in the room.... i need to the screen to show whole room with the char at the bottom in lift. Room scrollable is 300wide x 820high....
Hope you understand my issue.
Thank you..
Quote from: Slasher on Tue 20/09/2022 14:12:54i need to the screen to show whole room with the char at the bottom in lift. Room scrollable is 300wide x 820high....
Do you mean that you need to move the camera up, or zoom camera out to show more of the room at once?
Regarding old functions (GetViewport and so on), if you search for them in the manual, their description has a note that tells which functions to use instead.
Also, there's a table of outdated functions, which tells the replacements:
https://adventuregamestudio.github.io/ags-manual/ObsoleteScriptAPI.html
You use
Camera.SetAt(int x, int y);
the same way you'd previously use
SetViewport(int x, int y);
In this case you'd probably want to scroll it up so Camera y=0.
Cheers guys but...
GlobalScript.asc(1094): Error (line 1094): must have an instance of the struct to access a non-static member
Afaik you need
Game.Camera.SetAt(...);
We need better code examples in the manual... because currently it has none.
Also I just realized that Camera's article does not mention the Game.Camera object, so there's no obvious connection.
Thanks a lot guys (nod)
I thin you can also follow up the lift movement also and follow with x y the camera I use it for panning the room while on cutscenes.
int i=0;
while ( i<=53 ){
i++;
Game.Camera.SetAt(Game.Camera.X - 6, Game.Camera.Y);
Wait(4);
}
Strictly speaking, the above code may be simplified, as you already have X coordinate that you may use in a condition:
while ( Game.Camera.X > X_DESTINATION ){
Game.Camera.SetAt(Game.Camera.X - 6, Game.Camera.Y);
Wait(4);
}
Or simplified even more:
while ( Game.Camera.X > X_DESTINATION ){
Game.Camera.X -= 6;
Wait(4);
}
Naturally, vertical movement will require changing Y instead; and moving in opposite direction will require adding instead of subtracting and testing for (Camera.X < X_DESTINATION).
I expanded the Camera and Viewport articles with practical examples and minor additions; they are not published in the official manual yet, but may be read in the wiki source:
https://github.com/adventuregamestudio/ags-manual/wiki/Camera
https://github.com/adventuregamestudio/ags-manual/wiki/Viewport
If you aren't already. Use the tweenmodule, it works great for elevators and all kinds of camera movements. (nod)