Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,114
Reaction score
5,842
First Language
English
Primarily Uses
RMVXA
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!!
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,812
Reaction score
889
First Language
German
Primarily Uses
RMMZ
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".
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,114
Reaction score
5,842
First Language
English
Primarily Uses
RMVXA
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! :)
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,812
Reaction score
889
First Language
German
Primarily Uses
RMMZ
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.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,114
Reaction score
5,842
First Language
English
Primarily Uses
RMVXA
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!!
 

Latest Threads

Latest Profile Posts

Terrible Writing Advice, you've done it again.
1635026211997.png
Feeling like my new profile picture is nice. Thinking of making it semi-permanent, does any one has an opinion? Does it look too evil or does it work as a public profile picture? :)
Bishiba.png
My washing machine is a supernatural being. I lost a piece of clothing in there a month ago; searched up and down, inside other clothes, nothing. It just vanished.
Today, put in a new load. When I pull it out, the missing clothing is back! And a sock was sacrificed in the process :yswt2:

Forum statistics

Threads
116,029
Messages
1,095,058
Members
151,356
Latest member
Redzoni
Top