[Question] Setting a Sprite on the Events Viewport?

hi there..


(my 3rd topic here... uh..)


Situation:


I created a small animation system that shows a sprite in a rect and updates its SX coordinate to animate it.


works very well and i´m happy with the result.


Only problem: The sprite is shown above tiles too.


So my question: How can i set a sprites viewport equal to the events viewport, so it can get overlapped by tiles too?
it's in the naming of the spritesheets filename.


By default, the sprite is displayed a few pixel higher than the grid to have it appear as if the character walks on that field instead of on the borders.


To disable that displacement (for door events for example), you place a ! at the beginning of the filename.


Just open any sprite selection screen in the editor and compare how ! (displacement) and $ (single sprite) are used for the different spritefiles provided by the RTP.
You don´t get it..

When i have a tile, that is overlapping the player

Now i´m creating a new Sprite over the player´s position:

$bruchanimation[$bruchanimation.size-1].bitmap = Cache.picture("Zusammenbruch_1") $bruchanimation[$bruchanimation.size-1].ox = $bruchanimation[$bruchanimation.size-1].bitmap.width/2 $bruchanimation[$bruchanimation.size-1].oy = 0 $bruchanimation[$bruchanimation.size-1].x = ($destroy_map[0][0]*32) - (($game_map.display_x-2)*32) $bruchanimation[$bruchanimation.size-1].y = ($destroy_map[0][1]*32) - ($game_map.display_y*32) $bruchanimation[$bruchanimation.size-1].src_rect.set(0, 0, 32, 64)This sprite is shown completely - cause the overlapping effect has no effect on the sprite.

BUT, i want the sprite being overlapped too - like events or the player.
In that case, you need something like a z-level-script.


RM has a specific ordering of the Z-Level, and there are only minimal ways to change that (for example, in case of pictures the picture number is used to order the Z-Level for pictures, but pictures only)


I've seen a script a long time ago that can be used to change the Z-Levels for other things, but I don't remember where I've seen that or how it worked. If someone can find that, you could check how it was done there.
The problem is - the Sprites Viewport is different vom the Events Viewport - so it doesn´t matter what Z value i give em - it always stays above the events..

That is my problem.. how to set the sprites viewport, to the events
I don't understand what you mean by "sprites viewport is different from events viewport"


Events do not have a viewport. Character sprites are used to represent events. All sprites are drawn above the map tile sprites.
okay then:

hot to set a sprite on the same Z value as events, so they are overlapped by tiles too?

i tried every Z value between -100 and 32000... and its always shown above everything in the view.
Create your new sprite inside Sprite_Character so you can use its viewport and z values.
yeees..
that´s a thing i don´t want to - edit standard scripts...
But i think i´ll try to att_accessor the viewports to create my sprites external with.
I think if you set the sprite's z coordinate to 100, and the viewport to @viewport1, it will have the same priority as the player. So tiles marked * will be displayed over the sprite, and the sprite will be displayed over events with 'below characters' priority and under events with 'above characters' priority.
From the help file:

The z-coordinate of each sprite used to create a tilemap is fixed to a specific value.


A tile that should be displayed under the character has a Z coordinate of 0.


A tile that should be displayed over the character has a Z coordinate of 200.


Keep these rules in mind when setting the z-coordinates of any map characters.
Events' sprites (Sprite_Character) and the Tilemap are all associated with @viewport1 within Spriteset_Map. In order for a sprite to layer correctly with either of them, it must be associated with the same viewport and given the correct z coordiante within that Viewport. However, the examples you have given for sprites you want to associate are all referenced by global variables - and you aren't showing us any of the context they are used in, or how you are handling the sprites updates and disposal (which, given that you are associating them with a Viewport that will definitely be disposed, is very important, see my sig thread), I think you should share some more information so other options can be explored.
yes

i think with

class Sprite_Character ... attr_accessor :viewport1endi should be able to create a sprite within that viewport within my Scene_Map alias 🙂

thx for your help @all

Original thread: https://forums.rpgmakerweb.com/threads/question-setting-a-sprite-on-the-events-viewport.21832/