Drawing image into specific layer? [solved]

Status
Not open for further replies.
Joined
Jun 30, 2017
Messages
42
Reaction score
31
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

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,665
Reaction score
13,276
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
31
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
7,009
Reaction score
4,747
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.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Husband has roped me into playing one of his PSO2 characters. Productivity is now negative.
Tileset A is lava! Don't burn D:
as MZ come out what you guys think about.....Some particles engine :3c?
Who wants to sing this song with me?~

Decided to submit my games to the Monday Night Stream. Figured it might be a fun way to get some traction.

Forum statistics

Threads
100,704
Messages
978,549
Members
132,320
Latest member
LavaWave
Top