Drawing image into specific layer? [solved]

Status
Not open for further replies.
Joined
Jun 30, 2017
Messages
42
Reaction score
35
First Language
spanish
Primarily Uses
RMMV
Hi, I am trying to draw a image into the screen, with PIXI.
Currently using:

Code:
var img = PIXI.Sprite.fromImage('./img/pictures/logo.png');
SceneManager._scene.addChild(img);

That works, but the image is on the top layer, and I need to draw the image on the 'floor' layer, between tileset <-> events.
Maybe some container for each layer exists?

Thanks
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,826
Reaction score
14,021
First Language
English
Primarily Uses
RMMV
Yes, there is.

Spriteset_Map has a _baseSprite property that holds the tilemap, and the tilemap holds both the tiles and the characters.

Something like this might get you somewhere:

SceneManager._scene._spriteset._tilemap.addChildAt(img, x)

where x is 1, 2, 3, etc - just experiment until you get the right place.
 
Joined
Jun 30, 2017
Messages
42
Reaction score
35
First Language
spanish
Primarily Uses
RMMV
Thanks @Shaz for pointing me into the right direction, that seems to work but there are some strange Z position issues, sometimes the images change their z position while the character is moving, so instead of directly addiing images i used two containers with diferent z positions.

Code:
            // BOTTOM LAYER
            BlackLights.layer.bottom = new PIXI.Container();
            var map_width = ($gameMap.width() * $gameMap.tileWidth());
            var map_height = ($gameMap.height() * $gameMap.tileHeight());
            BlackLights.layer.bottom.width = map_width;
            BlackLights.layer.bottom.height = map_height;
            SceneManager._scene._spriteset._tilemap.addChild( BlackLights.layer.bottom );
            BlackLights.layer.bottom.z = 3;

            // TOP LAYER
            BlackLights.layer.top = new PIXI.Container();
            var map_width = ($gameMap.width() * $gameMap.tileWidth());
            var map_height = ($gameMap.height() * $gameMap.tileHeight());
            BlackLights.layer.top.width = map_width;
            BlackLights.layer.top.height = map_height;
            SceneManager._scene._spriteset._tilemap.addChild( BlackLights.layer.top );
            BlackLights.layer.top.z = 45;

Then i add the images as children's of one of the containers.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,033
Reaction score
5,334
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

I'm moving on from RMXP finally. I've been stuck in a difficult decision between XP and MZ, and I've given up and moved on to MZ. Overall I'm really liking it, I wish tilesets were easier to setup like XP, but it's actually not that bad!
Have you ever gone full 'Ship of Theseus' while frankenspriting? Because I just did.
I saw my new eye doctor today, he reminds me of Satoru Iwata for some reason
I've been using a modified version of a script called Multiple Messages. It makes my text boxes look like a Mario & Luigi game! There is something about it that bothers me a little bit, but I shouldn't worry about that now.

Side note, Mist's walking animation is almost perfectly in sync with Loose Yourself by Eminem.
Starting work on some stuff for the community. Hopefully it will be fun, and useful to somebody.

Forum statistics

Threads
107,772
Messages
1,032,030
Members
139,914
Latest member
smudge
Top