First time ever posting on any kind of forums so I don't know the protocol or anything. 😛 Forgive me beforehand. Also, I hope this is the correct place to be posting.
Anyways to get into the topic, I'm trying to add a battle command that pulls up a new window that contains sprite buttons (clickable buttons). I've been able to add a battle command that I can select that pulls up a new window, but that's as far as I've got. It pulls up a new window, but literally all that command does is pull up a window, and the window just stays open for the remainder of the battle. xD;
Here is the js I have for that part:
My next step is to create a sprite button which will allow me to cancel out of the window. However, with the current code I have, I receive an error saying "TypeError Cannot read property 'parent' of undefined". I would appreciate it if anyone can look thru the code I have for the sprite button part to tell me why this issue is occurring :/
Anyways to get into the topic, I'm trying to add a battle command that pulls up a new window that contains sprite buttons (clickable buttons). I've been able to add a battle command that I can select that pulls up a new window, but that's as far as I've got. It pulls up a new window, but literally all that command does is pull up a window, and the window just stays open for the remainder of the battle. xD;
Here is the js I have for that part:
Code:
function My_Window() {
this.initialize.apply(this, arguments);
};
My_Window.prototype = Object.create(Window_Base.prototype);
My_Window.prototype.constructor = My_Window;
Code
My_Window.prototype.initialize = function(x, y){
Window_Base.prototype.initialize.call(this, x, y, 400, 300);
};
var _battlemenu = Window_ActorCommand.prototype.makeCommandList
Window_ActorCommand.prototype.makeCommandList = function() {
_battlemenu.call(this);
this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
this.addCommand('New', 'new');
};
var _battlemenuWindow = Scene_Battle.prototype.createActorCommandWindow
Scene_Battle.prototype.createActorCommandWindow = function() {
_battlemenuWindow.call(this);
this._actorCommandWindow.setHandler('escape', this.commandEscape.bind(this));
this._actorCommandWindow.setHandler('new', this.commandNew.bind(this));
};
Scene_Battle.prototype.commandNew = function(){
this._myWindow = new My_Window(213,110);
this.addWindow(this._myWindow);
};
My next step is to create a sprite button which will allow me to cancel out of the window. However, with the current code I have, I receive an error saying "TypeError Cannot read property 'parent' of undefined". I would appreciate it if anyone can look thru the code I have for the sprite button part to tell me why this issue is occurring :/
Code:
(function(){
function My_Window() {
this.initialize.apply(this, arguments);
};
My_Window.prototype = Object.create(Window_Base.prototype);
My_Window.prototype.constructor = My_Window;
My_Window.prototype.initialize = function(x, y){
Window_Base.prototype.initialize.call(this, x, y, 400, 300);
};
var _battlemenu = Window_ActorCommand.prototype.makeCommandList
Window_ActorCommand.prototype.makeCommandList = function() {
_battlemenu.call(this);
this.addCommand(TextManager.escape, 'escape', BattleManager.canEscape());
this.addCommand('New', 'new');
};
var _battlemenuWindow = Scene_Battle.prototype.createActorCommandWindow
Scene_Battle.prototype.createActorCommandWindow = function() {
_battlemenuWindow.call(this);
this._actorCommandWindow.setHandler('escape', this.commandEscape.bind(this));
this._actorCommandWindow.setHandler('new', this.commandNew.bind(this));
};
Scene_Battle.prototype.commandNew = function(){
this._myWindow = new My_Window(213,110);
this.addWindow(this._myWindow);
this.createSpriteButtons();
};
Scene_Battle.prototype.createSpriteButtons = function(){
this._spriteButton = new Sprite_Button();
this._spriteButton.bitmap = ImageManager.loadSystem('test');
this.addChild(this.Sprite_Button);
};
})();