Showing Pictures - Can I avoid using gameScreen?

Thanks for checking this topic out. 🙂


I am trying to show dozens of copies of a graphic onscreen (during battle).  Because of the large number of instances that might be onscreen as well as the fact that the graphics are tied to game elements (so I can't always predict which instances will be onscreen and when), I feel like it would be a smarter approach to avoid using the $gameScreen._pictures array.


However, so far I've been unable to actually show the pictures onscreen without using this array.  The following code works properly:

Code:
BattleManager.show_new_points = function() {
    for (var i = 0; i < this.new_points_to_show.length; i++) {
        point = this.new_points_to_show[i];
        // ID, Name, Origin, X, Y, Zoom X, Zoom Y, Opacity, Blending
        $gameScreen.showPicture(this.next_picture_id, "Big Blue Dot", 1, point.center_x,
                point.center_y, 100, 100, 255, 0);
        this.next_picture_id += 1;
    }
};

whereas the following code, while it doesn't error in any form, fails to visibly show anything onscreen:

Code:
BattleManager.show_new_points = function() {
    for (var i = 0; i < this.new_points_to_show.length; i++) {
        point = this.new_points_to_show[i];
        var picture = new Game_Picture();
        // Name, Origin, X, Y, Zoom X, Zoom Y, Opacity, Blending
        picture.show("Big Blue Dot", 1, point.center_x, point.center_y, 100, 100, 255, 0);
        picture.update();
    }
};

Can you please explain to me why RMMV isn't (visibly) doing anything with the second method, and suggest an approach I could use - preferably without touching $gameScreen._pictures at all - to make the pictures appear onscreen during battle?
 


I appreciate your help!!
Do you need to actually use a Game_Picture instance (and if so, why)? Because that will only work inside the pictures array. You can, however, create your own Sprite instance and add it to the scene yourself, like this:


var sprite = new Sprite(Bitmap.load(...));
SceneManager._scene.addChild(sprite);


If possible, don't refer to the scene like this, though. Try to add the picture inside the scene, so you can simply use "this".
Thanks so much, @Iavra, that is a fantastic start!  Using this I was able to make the graphic appear onscreen - of course, all instances appear at (0,0) since I'm not telling them to do any differently.  Where does Scene_Battle store its children, so that I can (for example) change a child sprite's x-coordinate, change its opacity, or remove the sprite from the scene?  Sorry if I'm asking this badly! 🙂
You'll need to store a reference to the sprite somewhere else. The MV base scripts do it like this:


Scene_Title.prototype.createBackground = function() {
this._backSprite1 = new Sprite(ImageManager.loadTitle1($dataSystem.title1Name));
this._backSprite2 = new Sprite(ImageManager.loadTitle2($dataSystem.title2Name));
this.addChild(this._backSprite1);
this.addChild(this._backSprite2);
};


So, you can use "_backSprite1" to refer to a sprite, instead of having to look it up inside the scene's "children" array.
Not sure it's the best approach, but right now I've got everything working as desired by associating the sprite to both the scene (Scene_Battle) and a game construct (in my case Game_Enemy) when it's created.


For example:

Code:
Scene_Battle.prototype.refresh_sprite = function(point, sprite) {
    sprite.x = (point.center_x - (point.diameter / 2));
    sprite.y = (point.center_y - (point.diameter / 2));
    sprite.opacity = point.opacity;
}

I'd probably still be struggling to make it even appear onscreen correctly if it weren't for you, @Iavra.  Thank you so much for your help with this!!

Original thread: https://forums.rpgmakerweb.com/threads/showing-pictures-can-i-avoid-using-gamescreen.56810/