May 21, 2021
Reaction score
First Language
Primarily Uses
I have an event that creates a new sprite container from image files in the pictures folder, using PIXI.js.
I love this!!!! As long as z value is negative, it draws under the tile map!! Sweet!!
I copied it from an older post here and thought it would be useful for my game. (Thanks to Shaz for pointing out tilemap property in SceneManager).

It works in every way I desire it to by adjusting some parameters...except now I cannot get rid of the pictures created by this method.
I have tried removeChild();
I have tried sprite.destroy();
I have tried rmmv script calls to clear pictures.
var image = PIXI.Sprite.fromImage('./img/pictures/mybackground.png'); SceneManager._scene._spriteset._tilemap.addChild(image); img.x = 0; img.y = 0; img.z = -8; img.width = 816; img.height = 624;

Any further attempts to get rid of it throws me an error:
Type Error: Undefined is not a function
Reference Error: image is not defined.

How do I remove these images...and if the same method of drawing is repeated several times, will it consume all of my device's memory?
Thanks in advance! :)

Screenshot info: It is a fan game of MTG (Magic: the gathering). Many of the land cards in MTG contain panoramic images of cool looking fantasy places. I can reposition and enlarge the card images so that only the portion showing the landscape art is visible, creating a faux parallax layer. In this screenshot, the image is enlarged only slightly, and drawn below the tilemap.


  • Untitled.png
    278.6 KB · Views: 5


Oct 8, 2018
Reaction score
First Language
Primarily Uses
I used to play MTG and will play when times comes.

But "Type Error of undefined is not a function" can be anything:

1) wrong plugin order
2) continue from save file after new plugin is added
3) plugin conflict
4) typo in scriptcall/plugin command

but to narrow down the the error, we need to check the console log
to see which one throws the error to find out what function it has.

if it's a conflict, it can be easier to know which one, in order to find that out,
turn off all plugin (if they are in the correct order) and turn them on 1 by 1
to see which one is conflicting it.
May 21, 2021
Reaction score
First Language
Primarily Uses
Oh wow that's a lot of red! I just attempted to run removeChild() in vanilla mode and this is what it gave me.

ReferenceError: img is not defined
at Game_Interpreter.eval (eval at <anonymous> (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_objects.js:10482:10), <anonymous>:1:53)
at Game_Interpreter.command355 (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_objects.js:10482:5)
at Game_Interpreter.executeCommand (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_objects.js:8932:34)
at Game_Interpreter.update (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_objects.js:8840:19)
at Game_Map.updateInterpreter (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_objects.js:6117:27)
at Game_Map.update (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_objects.js:6024:14)
at Scene_Map.updateMain (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_scenes.js:420:14)
at Scene_Map.updateMainMultiply (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_scenes.js:412:10)
at Scene_Map.update (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_scenes.js:401:10)
at Function.SceneManager.updateScene (file:///C:/Users/jeremy/Documents/Games/Project1/js/rpg_managers.js:1829:25)rpg_managers.js:1756 SceneManager.catchExceptionrpg_managers.js:1717 SceneManager.update


Global Mod
Feb 21, 2018
Reaction score
First Language
Primarily Uses
var image = PIXI.Sprite.fromImage('./img/pictures/mybackground.png'); SceneManager._scene._spriteset._tilemap.addChild(image); img.x = 0; img.y = 0; img.z = -8; img.width = 816; img.height = 624;
I see a few problems here:
  1. You declare var image, but then attempt to manipulate img, a different (possibly undefined) reference.

  2. Script commands are sandboxed evals: all local variables are destroyed once the code is evaluated. To avoid this, you will need to store the reference as a (sub-)property of a pre-existing object, e.g. window (root global) or SceneManager._scene (active scene).

  3. By using PIXI.Sprite directly you ignore the game's image caching system (keeps recently-loaded images in RAM for quick access) and maybe other things.
You may want to try something like this (untested):
  • Define a new, globally-accessible array for your background images:
    window.myBG = [];  // initialise empty array
  • Load new pictures via RMMV's Sprite and ImageManager wrappers:
    window.myBG.push(new Sprite(ImageManager.loadPicture('mybackground')));
  • Add/adjust the child image as usual.
  • Reference the array when removing images:
    SceneManager._scene._spriteset._tilemap.removeChild(window.myBG.splice(0, 1));
    I.e. "splice image 0 (first image) out of the array and remove that image from the tilemap".
push just adds a new entry to an array, and splice lets you add/remove entries. More info here:
Note that this sort of thing will only persist for a single session, so it may have problems with images showing when they're not supposed to or vice-versa, e.g. on new/load game. This looks like a feature that would generally be best done with a plugin using appropriate method hooks. :kaoslp:

Also, be aware of copyright! You should have permission to use these images legally. This applies regardless of whether you intend to profit from your project.

Latest Threads

Latest Posts

Latest Profile Posts

Making games is the only thing I'm good at. Real talk.
So, uh... where's the RPG Maker MZ update with the MV animation system? Is there a release date confirmed?
Also I'm kind of brave enough to admit this. I... I have a crush on Sephiroth.
Please don't call me anything offensive. I'm naturally crazy.
thanks to a lot of lunatic coding... my game finally has a stun mechanic that I feel really good about. damage enemy's mental psyche (mp), and once empty, hitting with certain attacks trigger combos that can stack the damage.
Waiting for the 1.40 update before testing out my copy of MZ so that I don't end up adding unnecessary work to my plate. Meanwhile the current fourth draft for my story is taking shape, and I'm fleshing out the lore as I realize how things would make better sense here and there for the world that I'm building.
Sword_of_Dusk wrote on BCj's profile.
Just found out about your complications. I'm so sorry that you're going through this. I wish I could do something substantial for you, but our distance from each other makes that an impossibility. Still, if you ever need to talk or vent, I'm here.

Forum statistics

Latest member