Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: Ryex on November 18, 2009, 07:28:39 pm

Title: how does the Viewport system work in RGSS?
Post by: Ryex on November 18, 2009, 07:28:39 pm
how does the Viewport system work in RGSS? ie. If I have a bunch of sprite in several different view ports how do I know the stack order of the sprites
Title: Re: how does the Viewport system work in RGSS?
Post by: G_G on November 18, 2009, 07:49:14 pm
well to change the layer of each viewport use
viewport.z

And I think they work the same way views do in game maker. Pretty much the x and y are the location of this view on screen. Of course width and height is well width and height.
I guess they're pretty much like Rects.

Cant really explain it. But I think they're used to follow something like the viewport1 in Spriteset_Map is used to draw the map where the player is which creates an effect that its following the player.

I think anyways...might wanna ask someone experienced with viewports >___>
Title: Re: how does the Viewport system work in RGSS?
Post by: fugibo on November 18, 2009, 07:57:51 pm
The Viewports are automatically drawn in ascending order of Z value, and within each the sprites are drawn the same way. It's just a way to collect sprites and limit where they're drawn.
Title: Re: how does the Viewport system work in RGSS?
Post by: Ryex on November 18, 2009, 10:20:36 pm
so
viewport 1: z=1
 sprite 1: z=1
 sprite 2: z=2
viewport 2: z = 2
 sprite 3: z = 1
 sprite 4: z = 4
viewport 3: z = 3
 sprite 5: z = 1

would be drawn

sprite 5 on top
then sprite 4
then 3
then 2
then 1?

not
sprite 4
2
and then 5, 3, and one depending on the order drawn?

so if i create a new viewport, and then pass it as an argument to several sprites, changing the z of said viewport would change the draw position for all of the sprites that have it as an argument?

Title: Re: how does the Viewport system work in RGSS?
Post by: fugibo on November 18, 2009, 10:35:46 pm
Quote from: Ryexander on November 18, 2009, 10:20:36 pm
so
viewport 1: z=1
 sprite 1: z=1
 sprite 2: z=2
viewport 2: z = 2
 sprite 3: z = 1
 sprite 4: z = 4
viewport 3: z = 3
 sprite 5: z = 1

would be drawn

sprite 5 on top
then sprite 4
then 3
then 2
then 1?

not
sprite 4
2
and then 5, 3, and one depending on the order drawn?

so if i create a new viewport, and then pass it as an argument to several sprites, changing the z of said viewport would change the draw position for all of the sprites that have it as an argument?




IIRC, yes. But I could be wrong.
Title: Re: how does the Viewport system work in RGSS?
Post by: Blizzard on November 19, 2009, 03:50:37 am
You're right, this is how it works. I think that it doesn't just limit where sprites are drawn, it can also increase performance if a sprite is out of the drawing view. Just remember that inside the viewport the coordinates are reset. That means that a sprite with x, y = 0, 0 is located in the upper left corner of the viewport, not the screen.