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
well to change the layer of each viewport use
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 >___>
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.
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?
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.
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.