- Joined
- Mar 29, 2017
- Messages
- 7
- Reaction score
- 5
- First Language
- Portuguese
- Primarily Uses
- RMMV
Hey guys!
I'm developing a plugin here to use on my project but I ran out into a problem.
To give a full context, here's what my plugin is going to do:
My plugin will manage common actions after a character levels up. For example:
- Display a message;
- Display an image for x seconds;
- Play a song;
- Restore MP and HP.
To make those actions happen I'm working under the Game_Actor.prototype.changeExp function, so if I level up, it will do one or any of those actions described above.
Here's the problem that I'm facing while trying to display an image:
I have this block of code to setup my image:
The problem is that, if I try to call the function loadLevelUpImage, I get the "undefined is not a function", I think that I'm not making the call in the right way (I'm new into Javascript);
So, I'm kinda lost on how to make this works... Also, is this the best way to show an image on screen? If not, what can I use instead?
Not sure if this is useful but I could show the image using Scene_Map.prototype.start, but that will show right after the map starts:
I'm developing a plugin here to use on my project but I ran out into a problem.
To give a full context, here's what my plugin is going to do:
My plugin will manage common actions after a character levels up. For example:
- Display a message;
- Display an image for x seconds;
- Play a song;
- Restore MP and HP.
To make those actions happen I'm working under the Game_Actor.prototype.changeExp function, so if I level up, it will do one or any of those actions described above.
Here's the problem that I'm facing while trying to display an image:
I have this block of code to setup my image:
Code:
ImageManager.loadLevelUpImage = function(filename) {
return this.loadBitmap('img/pictures/', filename, 0, true);
};
Scene_Map.prototype.loadLevelUpImage = function(opacity) {
var levelUpImage = new Sprite_Base();
levelUpImage.bitmap = ImageManager.loadLevelUpImage('levelup');
levelUpImage.x = gfxImageXPosition;
levelUpImage.y = gfxImageYPosition;
levelUpImage.opacity = opacity;
this.addChild(levelUpImage);
};
Code:
var _Game_Actor_changeExp = Game_Actor.prototype.changeExp;
var _Game_BattlerBase_setHp = Game_BattlerBase.prototype.setHp;
var _Game_BattlerBase_setMp = Game_BattlerBase.prototype.setMp;
var _Scene_Map_loadLevelUpImage = Scene_Map.prototype.loadLevelUpImage;
Game_Actor.prototype.changeExp = function(exp, show) {
var lastLevel = this._level;
_Game_Actor_changeExp.call(this, exp, show)
if(this._level > lastLevel){
if(gfxEnabled){ //gfxEnabled is a flag to check if I want to enable or disable this function
_Scene_Map_loadLevelUpImage.call(this,255); //Here's where I want to draw the image on screen
}
}
};
So, I'm kinda lost on how to make this works... Also, is this the best way to show an image on screen? If not, what can I use instead?
Not sure if this is useful but I could show the image using Scene_Map.prototype.start, but that will show right after the map starts:
Code:
ImageManager.loadLevelUpImage = function(filename) {
return this.loadBitmap('img/pictures/', filename, 0, true);
};
var _Scene_Map_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function(){
_Scene_Map_start.call(this);
this.loadLevelUpImage(255);
}
Scene_Map.prototype.loadLevelUpImage = function(opacity) {
var levelUpImage = new Sprite_Base();
levelUpImage.bitmap = ImageManager.loadLevelUpImage('levelup');
levelUpImage.x = gfxImageXPosition;
levelUpImage.y = gfxImageYPosition;
levelUpImage.opacity = opacity;
this.addChild(levelUpImage);
};


