Show picture UNDER tiles

So i am basically trying to show a picture on a layer lower than the tiles. My picture is formed in layers, so different blend modes don't work (they just blend with each other). I think i have to alias the function(s) responsible for parallax but i don't know where they are located.

To be more precise, i have tiles and a transparent section, i want the image to be visible only in that transparent section. I would use the built in parallax, but a) the image is formed in layers and b) the image must not loop.

Do you have any solutions?

EDIT: I forgot to mention i'm using RMMV
You can try to use GalvLayers.js for this. But he works as a parallax plugin that you can decide the layer that you will put it.
You can use plugin commands and script calls for show and changes the parallaxes.
You can try to use GalvLayers.js for this. But he works as a parallax plugin that you can decide the layer that you will put it.
You can use plugin commands and script calls for show and changes the parallaxes.

I'll check it out now! Cheers

EDIT: This "kinda" works, although it's mostly made to make parallax mapping easier. In any case, my layers also need to be stretched, and there is no stretching in those commands (or in the js itself). I tried adding a stretching property but it's proving to be beyond my current capabilities :s
I might need to stretch each layer beforehand. It's a shame there's no stretching, at least for the static layers!

After a huge amount of tinkering, i simply can't get it to work for all my layers. It seems that sometimes it adds the lowermost layer to the front, or the last layer doesn't even load, etc. Like i said, it's mostly for parallax mapping, rather than what i want to use it for.
I'm not sure if this is exactly what you're looking for, but to reach the layers where the map actually resides (in sprite form, during execution), the following (lengthy) address will get you to the array that holds them.
JavaScript:
let scn = SceneMananger._scene;
let spriteset = scn._spriteset;
let mapLayers = spriteset.children[0].children[2];
let bottomLayer = mapLayers.children[0];

/*
Lets assume you have the picture in a variable called imageToAdd
Using unshift will add the image to the FRONT of the array, meaning it will
be the bottom-most thing displayed.
It's best to add it directly to this layer, because the contents of mapLayers (the
children) don't actually always sit in the same positions, but the bottom map tile layers
always seem to stay in postion 0, which makes sense.
*/
bottomLayer.unshift(imageToAdd)

As an example, when I made my tactical move-grid (grid that shows where a character can move in games like Fire Emblem or FF Tactics), I added it to the back of the map layer array, so that it would appear on top of the tiles, but below other sprites, like characters.

In your case, it sounds like you want it to be below even the map. So you'd want to add it to the front of the array, which is what .unshift would do.

Let me know if any of this helps.
I'm not sure if this is exactly what you're looking for, but to reach the layers where the map actually resides (in sprite form, during execution), the following (lengthy) address will get you to the array that holds them.

[...]

As an example, when I made my tactical move-grid (grid that shows where a character can move in games like Fire Emblem or FF Tactics), I added it to the back of the map layer array, so that it would appear on top of the tiles, but below other sprites, like characters.

In your case, it sounds like you want it to be below even the map. So you'd want to add it to the front of the array, which is what .unshift would do.

Let me know if any of this helps.

Hi and thanks for your reply. So i have a system in place that basically, whenever an image is called, it decides what image part goes in which layer to build the "central" image, using a series of showpicture commands.

So how can i use what you wrote? I mean,do i add a png name in the array so that it is loaded when the map loads? Is it possible to use something like that to alter the layer of the showpicture command to allow the lowermost layer?


Actually,since my image is built in layers, wouldn't it be better to simply alter the layers of the tileset in the specific map to be above the layers of my image? For example, if my max layer is 50, then the layers of everything else could be 50+whatTheyWere ?

Maybe i forgot to mention it but i only need it on specific maps, where save is disabled, so i was also thinking of altering some function before the map is created and then change it back before leaving. So far i had little success, even with Galv's plugin... (i managed to put the images behind the tiles, however it seems to misplace the images when more than 4-5 are loaded)

To be honest, i think i'll probably crop them individually, although this will require a ton of work, and i'm pretty sure it's doable with JS tinkering...

EDIT: I'm looking into what Galv did to create new layers under the tileset and Galv is aliasing Spriteset_Map.prototype.createLowerLayer. I followed that and i found the functions for parallax and tileset, but i don't see any sort of layers there. This is the function:

Code:
Spriteset_Map.prototype.createParallax = function() {
    this._parallax = new TilingSprite();
    this._parallax.move(0, 0, Graphics.width, Graphics.height);
    this._baseSprite.addChild(this._parallax);
};

and that's it. I thought that then maybe each layer adds a new tiling sprite, but i'm not gonna mess with it until i know for sure what i'm doing...

EDIT: To be honest,whatever i'm trying seems to be a lot more work than what it's worth. Like, i would be better off cropping the images instead. However, just in case someone comes up with the solution, it will be nice to know.
Honestly, there are a couple of different ways to use what I showed to get this done.
What I personally do is alias

Scene_Map.prototype.onMapLoaded

I choose to alias that instead of something that happens elsewhere because I find it has a low chance of conflicting with a lot of core stuff, that other map altering JS might interact with.

As far as showing the image, instead of using the Show Picture command, I'd probably load it with PIXI.Sprite class, or the rpg maker Sprite class.
The latter is 'safer', as RPG Maker can handle encrypting it without any external resources.

Code:
Scene_Map.prototype.onMapLoaded = function(){

    sp_aliasonMapLoaded.call(this);

    let mySprite = new Sprite(Bitmap.load("img/pictures/Atticus1_1.png"));
    let shaderTileMap = this._spriteset.children[0].children[2]
 
    shaderTileMap.addChildAt(mySprite, 0);



 

}

I have a picture in my project's pictures folder called
"Atticus1_1.png"
Obv your image name would be differnt.

Anyway, the above code results in this
underMap.png


It gets an image to be under the tilemap, and can do this when the map loads. My previous method works better if you're adding things dynamically, while the program is running.

EDIT:
Just in case you aren't familiar with the Sprite Class
//to load a new RMMV Sprite class
let myVar = new Sprite(bitmap)

//to load a bitmap
Bitmap.load(filepath)

I'm essentially just putting the latter statement inside of the parenthesis of the former, I could totally do them separately, but since I don't need to do anything else with the Bitmap, I just create it as the argument, rather than a separate variable

DOUBLE EDIT!!!
I realize this image may be very, very confusing, because the picture I'm showing appears to be under part of the map, but over top of another. Those rooms, in my example image, that are getting overlapped by the picture are actually part of a parallax, that's the only reason they're getting overlapped.
The picture is indeed sitting under the tilemap, I'm sorry I didn't pick a less confusing image, I just quickly grabbed a map that I had some transparency on to show it was working. Lol, sorry about that!!
Honestly, there are a couple of different ways to use what I showed to get this done.
What I personally do is alias

Scene_Map.prototype.onMapLoaded

I choose to alias that instead of something that happens elsewhere because I find it has a low chance of conflicting with a lot of core stuff, that other map altering JS might interact with.

As far as showing the image, instead of using the Show Picture command, I'd probably load it with PIXI.Sprite class, or the rpg maker Sprite class.
The latter is 'safer', as RPG Maker can handle encrypting it without any external resources.

Code:
Scene_Map.prototype.onMapLoaded = function(){

    sp_aliasonMapLoaded.call(this);

    let mySprite = new Sprite(Bitmap.load("img/pictures/Atticus1_1.png"));
    let shaderTileMap = this._spriteset.children[0].children[2]
  
    shaderTileMap.addChildAt(mySprite, 0);

  

}

I have a picture in my project's pictures folder called
"Atticus1_1.png"
Obv your image name would be differnt.

Anyway, the above code results in this
View attachment 137054

It get an image to be under the tilemap, and can do this when the map loads. My previous method works better if you're adding things dynamically, while the program is running.

EDIT:
Just in case you aren't familiar with the Sprite Class
//to load a new RMMV Sprite class
let myVar = new Sprite(bitmap)

//to load a bitmap
Bitmap.load(filepath)

I'm essentially just putting the latter statement inside of the parenthesis of the former, I could totally do them separately, but since I don't need to do anything else with the Bitmap, I just create it as the argument, rather than a separate variable

Right, this seems to do the job, but i have a couple of questions:

1. How can i change the x,y position of the image by events? (for example, if the player interacts with a specific event, the x,y position of a specific layer is changed, while the rest of the layers remain intact)

2. How can i change the stretch of the image that will be loaded?

3. How can i add specific layers - and specify those as priorities? (my central image is built by layers one ontop of the other - this can easily be done with the showpicture command since it already has a layer argument)

4. Assuming i have the ID of a layer whose image i want to change, is it possible to change it by an event?

5. Do you generally think it's possible to create a plugin that, say, allowed negative layer values in "showpicture" script call to show it under the tiles using what you demonstrated? I'm not requesting the plugin, i'm just asking if you think it's possible.
Alright, I'll answer in order
1. If you want to easily access the images you add dynamically, instead of setting the Sprite to a local Variable inside of the function, you could create a variable outside of the function, making it global.
JavaScript:
let mySprite = {};
//now mySprite is global, and can be accessed once the game has launched.
//You could also do $gameVariables.setValue(id, PIXI.Sprite(Bitmap.load(filepath))),
//which will set the game variable with the id you specify to the value of that sprite
let sp_aliasonMapLoaded = Scene_Map.prototype.onMapLoaded;

Scene_Map.prototype.onMapLoaded = function(){

    sp_aliasonMapLoaded.call(this);

    mySprite = new Sprite(Bitmap.load("img/pictures/Atticus1_1.png"));
    let shaderTileMap = this._spriteset.children[0].children[2]
 
    shaderTileMap.addChildAt(mySprite, 0);
}

Now, you can access the variable (be it a custom global or a game variable) at any time after the map loads.

mySprite.x = 100;
mySprite.y += 300;

You can just access the x and y properties of the Sprite inside of the variable to move it around.

2. You can change the .height and .width properties the same way you can change the x and y properties

mysprite.width = 100;
mySprite.height *= 1.5;

3. When dealing with images in the way I showed, the layers are actually in order of the position in the .children 'array'. So in my example, using
.addChildAt(mySprite, 0)

Makes it so that it is the bottom layer. The layers are essentially in order of lowest number to highest, only starting with 0, instead of 1. Pretty much the same as specifying it with Show Picture, you can actually specify the index. 3 would be on top of 2, 1, and 0. Index 10 would be under everything 11 and up, and below everything 9 and under.

4. Yes, it is, but it's actually easier to do if you already have a variable that holds the image.
If your global variable was called
mySpriteLayerTwo
You could do the following to change the image used.

mySpriteLayerTwo.bitmap = Bitmap.load("img/pictures/aDifferentImagePath.png");

This will change it dynamically, and can be done in events. All you need is a way to reference the sprite in question, which is much easier to do if you have it store somewhere.
(FYI, you could search the shaderTileMap dynamically for the image by iterating through the children of the tilemap and checking for the
.bitmap.url
property to see if it matches the image path you're looking for, but that could be a pain)

5. That's definitely possible, although it would likely require enough work to where it would be better to not even bother with Show Picture. This is because you'd ultimately wind up having to use the Show Picture script call, because in the editor, it still wouldn't let you pick a value less than 0.


EDIT:
I'd have to look into this more, because I traditionally use PIXI.Sprite instead of the RPG Maker Sprite class, but it seems changing the width and height isn't directly working to stretch the image.
With the PIXI.Sprite class this would work fine, let me poke around and see if stretching the image is an option with the RPG Maker Sprite class. I'm sure there's some way.

EDIT AGAIN:
To change the width or height, use
mySprite.scale.set(width, height)

The x and y values are set based off of the number 1.
mySprite.scale.set(1.3, 0.2)
would result in the width being 1.3 times it's normal value, and the height would be 20% of it's normal size. Basically 1 equals 100% of it's original value
Alright, I'll answer in order
1. If you want to easily access the images you add dynamically, instead of setting the Sprite to a local Variable inside of the function, you could create a variable outside of the function, making it global.
JavaScript:
let mySprite = {};
//now mySprite is global, and can be accessed once the game has launched.
//You could also do $gameVariables.setValue(id, PIXI.Sprite(Bitmap.load(filepath))),
//which will set the game variable with the id you specify to the value of that sprite
let sp_aliasonMapLoaded = Scene_Map.prototype.onMapLoaded;

Scene_Map.prototype.onMapLoaded = function(){

    sp_aliasonMapLoaded.call(this);

    mySprite = new Sprite(Bitmap.load("img/pictures/Atticus1_1.png"));
    let shaderTileMap = this._spriteset.children[0].children[2]
  
    shaderTileMap.addChildAt(mySprite, 0);
}

Now, you can access the variable (be it a custom global or a game variable) at any time after the map loads.

mySprite.x = 100;
mySprite.y += 300;

You can just access the x and y properties of the Sprite inside of the variable to move it around.

2. You can change the .height and .width properties the same way you can change the x and y properties

mysprite.width = 100;
mySprite.height *= 1.5;

3. When dealing with images in the way I showed, the layers are actually in order of the position in the .children 'array'. So in my example, using
.addChildAt(mySprite, 0)

Makes it so that it is the bottom layer. The layers are essentially in order of lowest number to highest, only starting with 0, instead of 1. Pretty much the same as specifying it with Show Picture, you can actually specify the index. 3 would be on top of 2, 1, and 0. Index 10 would be under everything 11 and up, and below everything 9 and under.

4. Yes, it is, but it's actually easier to do if you already have a variable that holds the image.
If your global variable was called
mySpriteLayerTwo
You could do the following to change the image used.

mySpriteLayerTwo.bitmap = Bitmap.load("img/pictures/aDifferentImagePath.png");

This will change it dynamically, and can be done in events. All you need is a way to reference the sprite in question, which is much easier to do if you have it store somewhere.
(FYI, you could search the shaderTileMap dynamically for the image by iterating through the children of the tilemap and checking for the
.bitmap.url
property to see if it matches the image path you're looking for, but that could be a pain)

5. That's definitely possible, although it would likely require enough work to where it would be better to not even bother with Show Picture. This is because you'd ultimately wind up having to use the Show Picture script call, because in the editor, it still wouldn't let you pick a value less than 0.

Wow that was a VERY informative reply! Thanks a ton!

As for question 5, the reason i was asking is because i am creating my own plugins for my game, and i already have the system using showpicture script calls in place, so it would, possibly, be easier to include negative layers(using all the info i got from you), rather than altering the entire system to work like this. I am not using the engine's "show picture" command, only script calls.

Anyway. I will experiment with all this to see how easy it is but really, thanks a lot!

Original thread: https://forums.rpgmakerweb.com/threads/show-picture-under-tiles.119149/