How to cope with ImageManager In MV {explanation}

Hi guys! 

Here Nio Kasgami for explain something in particuliar.

Sprite loading

So People Might think it's work's like Ace...it's kinda work's like Ace...but in same time Not at all!

I will be direct....ImageManager is far more complex than our default Cache when you just loaded the bitmap and this was loaded!

NOPE NOPE....

How in it's work in MV :

  1. create the bitmap
  2. "preload" the bitmap
  3. "draw" the bitmap
when in Ace we just create the bitmap and it's show....in MV due how the whole system is made you have to preload the bitmap for being able to show it without lags.

They have though some exception where you can directly draw the bitmap...it's when you start a scene since SceneManager already handles the pre-load.

but what's about when you want example to show in the middle of the scene....a message bust? Then if you show immediately the sprite when you created the method...it's will provoke lags! that's not funny huh?

so let's step by step show you how to do the stuff

you first example initialize the sprite but that's the classic

Dummy.prototype.initialize = function(){this.createSprite();};Now when you create the sprite it's like in ace! Although DO NOT REFERENCE the Bitmap! because it's will imidiatly draw the Sprite and also be sure to set the visibility to false or this will also try to load it.

Dummy.prototype.createSprite() {this._sprite = new Sprite();this._sprite.anchor.x = 0.5;this._sprite.anchor.y = 0.5;this._sprite.visible = false;this.addChild(this._sprite);}now the material is "referenced" but now for show it you may need in the update method by using a requirement to the cache.

Dummy.prototype.update = function() {if !(ImageManager.isReady()) { this.loadBitmap(); } else { this.drawSprite();this._bitmap = null;}with that it's will load the bitmap and draw the bitmap...but please this a rought idea don't make this like that lol 

you can reference yourself to Window_Message who are a perfect example of how load bitmap in MV.

Finally here the two final steps for make it work's properly

Dummy.prototype.loadBitmap = function(){this._bitmap = ImageManage.loadSystem('bitmapName');};Dummy.prototype.drawBitmap = function(){this._sprite.bitmap = ImageManager.loadSystem('bitmapName');this._sprite.visible = true;}with that the first method preload the picture so it's still in the system although it's not added to the child so it's will not appear.

and the second catch the bitmap and permit to draw it on the screen! 

and after you input it to the system.

It's simple like that...

and OH....Dispose just not exist in MV so you have to either change the bitmap name to ("");

or to setup to invisible but the first method remove memory usage.

I hope it's will help you guys 🙂
Nice one. What about image preloading? And make sure that all images needed are ready before scene started?

Can you tell us more about that?
Hum? it's the same you work with 

ImageManager.isReady();

and this will make sure the ImageManager is not loading anything and is ready to show the image.
I don't know if this idea will work. But can't you make a preloading function called in initialize and then create the sprite in the start function? since the start function is called once the scene is ready, and by default scene is ready once the ImageManager is ready.

It would be pretty much the same as you did, but you wouldn't need the update method, just put the drawSprite() function inside the start function and the loadBitmap() method in the initialize function.
no this would not work because you need to check in loop if the ImageManager would work
There's an easier solution. I was discussing this with Zale beforehand and we are able to think of a new way to preload the images that we only need. We had it blank at first, now we just made our own module to preload the things we want and specifically the things we just want, that will not cause much trouble for the system.
I don't think that is an easier solution. I don't have any friends named Zale to make a module with. 

Where do you put these sprites if you want them to appear on the same priority as characters?
There's an easier solution. I was discussing this with Zale beforehand and we are able to think of a new way to preload the images that we only need. We had it blank at first, now we just made our own module to preload the things we want and specifically the things we just want, that will not cause much trouble for the system.
Well I don't have the "module" you actually speak in hands so I show the MV default way's lol

I don't think that is an easier solution. I don't have any friends named Zale to make a module with. 

Where do you put these sprites if you want them to appear on the same priority as characters?
this not related to the thread and this question of AddChildAt priority 

Although "same priority" as character don't exist in RM it's overlap when you input in the same Child Digit so your picture will appear either above or below your sprite if not
Simplest solution is to make a function that will preload the images needed. It stores the bitmap for a later time of usage, and that's it. It doesn't need to be this long.
I would also vote for preloading. Either in the initialize of the object OR when the game starts (but only for small bitmaps then due to RAM-usage).
I tried preloading on scene initialization, but it gave me inconsistent result. Sometimes my picture displayed directly on the first time I open the scene, sometime it does not.

More or less, I could follow the flow ImageManager.isReady() but I think it isn't like what I thought.

Maybe if someone can give better explanation about how it worked, it will be useful for many people

Original thread: https://forums.rpgmakerweb.com/threads/how-to-cope-with-imagemanager-in-mv-explanation.53621/