Right now I'm trying to display a basic, completely white bitmap - but I can't seem to get anything to happen at all. Here's my code:
Scene_Map.prototype.showPicture = function() { this._bitmap = new Bitmap(200, 200); this._bitmap.fillAll(#FFFFFF); this._sprite = new Sprite(this._bitmap); this.addChild(this._sprite);};The idea is that this creates a bitmap, fills it with white, assigns it to a sprite, and then puts the sprite in the rendering pipeline. Unfortunately, it doesn't work at all. It doesn't throw any errors, and a quick console.log("executed") tells me that the code IS being run. What am I missing?
Oh great, thanks! So I should call bitmap as a function of sprite instead of as an argument of Sprite(). It turns out that my fillAll code was wrong too, but after I looked at your script I was able to display an image with no problem (brilliant idea with that script btw, I will definitely be using it in my games). Thanks!
I'm not seeing it over here. I've tried a couple of variations and still none of them work - though the lines are being executed.
In a plugin script I have:
(Scene_Map.prototype.showPicture = function(){ console.log("I was run!"); this._sprite = new Sprite_Base(); this._sprite.bitmap = new Bitmap(1920,1080); this._sprite.bitmap = ImageManager.loadPicture("digital-assist"); this._sprite.addChild(this._sprite); console.log("I grabbed an image file!");})();It seems nearly identical to what's been posted (minus the this.addChild as it complains 'undefined is not a fucntion') and yet no image is displayed. What am I missing here?
Okay, so I hacked away at this for awhile and learned some weird stuff. Did you copy-paste the code from the site? Because when I copy-pasted your code, it didn't work for me either. But when I typed it in directly, it did work, with the following modifications.
The self-executing anonymous function doesn't seem to work for displaying images. I don't know why. To get the image to show up, I just dropped a line in createDisplayObjects.
Scene_Map.prototype.createDisplayObjects = function() { this.createSpriteset(); this.createMapNameWindow(); this.createWindowLayer(); this.createAllWindows(); this.showPicture();};Obviously this should be aliased in instead - I was in a hurry. Also, I think the "new Bitmap" line is redundant because a sprite can only have one bitmap. Defining it twice is like saying "var x = 0; var x = 1" in that the second value just overwrites the first. Hope this helps!