Window_Selectable problem

UniqueName

Veteran
Veteran
Joined
Nov 12, 2018
Messages
78
Reaction score
12
First Language
Russian
Primarily Uses
Other
So I was able to create a selectable window but I cant activate it or draw anything on it
It's just a blank window, I cant choose options or do anything with that window and the highlighted option isn't flashing
When I type "SceneManager._scene._menuSelectable.show()" in the console window appears on the screen as it supposed to
but when I type"SceneManager._scene._menuSelectable.activate()" nothing happens
I used this script
function MyWindow() {
this.initialize.apply(this, arguments);
}


MyWindow.prototype = Object.create(Window_Base.prototype)
MyWindow.prototype.constructor = MyWindow;

MyWindow.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, 220, 0, Graphics.boxWidth - 220, Graphics.boxHeight);
this.drawAllItems();
}
MyWindow.prototype.drawAllItems = function() {
this.contents.clear();
this.drawText(Dimeon.Windows.text, 0, 0, Graphics.boxWidth, 48, 'center');
}


// ------------------------------
function MenuScene() {
this.initialize.apply(this, arguments);
}

MenuScene.prototype = Object.create(Scene_MenuBase.prototype)
MenuScene.prototype.constructor = MenuScene;

MenuScene.prototype.initialize = function(x, y, width, height) {
Scene_MenuBase.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, Dimeon.Windows.lh);
}

MenuScene.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this._myScene = new MyWindow(0, 0, 320, 240);
this.addChild(this._myScene);

this._menuSelectable = new MenuSelectable(0, 0, 100, 100);
this._menuSelectable.hide();
this._menuSelectable.select(0);
this._menuSelectable.setHandler("ok", this.commandOk.bind(this));
this._menuSelectable.setHandler("cancel", this.commandCancel.bind(this));
this.addChild(this._menuSelectable);
}
MenuScene.prototype.commandOk = function() {
this._menuSelectable.activate();
SoundManager.playOk();
}
MenuScene.prototype.commandCancel = function() {
SceneManager.pop();
SoundManager.playCancel();
}

MenuScene.prototype.update = function() {
if (!this.drawnWindows){
this._myScene.drawAllItems();
this.drawnWindows = true;}
if (Input.isTriggered("cac")){ SceneManager.pop();
SoundManager.playCancel();
}
};
//===========
function MenuSelectable() {
this.initialize.apply(this, arguments);
}


MenuSelectable.prototype = Object.create(Window_Selectable.prototype)
MenuSelectable.prototype.constructor = MenuSelectable;

MenuSelectable.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, Dimeon.Windows.lh * 2);
this.refresh();
this.hide();
this._index = -1;
this._cursorFixed = false;
this._cursorAll = false;
this._stayCount = 0;
this._helpWindow = null;
this._handlers = {};
this._touching = false;
this._scrollX = 0;
this._scrollY = 0;

}
Window_Selectable.prototype.refresh = function(){
this.drawAllItems();
}
Window_Selectable.prototype.drawAllItems = function() {
var topIndex = this.topIndex();
for (var i = 0; i < this.maxPageItems(); i++) {
var index = topIndex + i;
if (index < this.maxItems()) {
this.drawItem(index);
}
}
};
Window_Selectable.prototype.maxPageRows = function() {
return 3;
}

Window_Selectable.prototype.maxItems = function() {
return 2;
}

Window_Selectable.prototype.itemHeight = function() {
return (this.height - this.padding * 2) / this.maxPageRows();
}

Window_Selectable.prototype.maxPageItems = function () {
return this.maxPageRows() * this.maxCols();
}

Window_Selectable.prototype.drawItem = function(index) {
var itemRect = this.itemRect(index);
this.drawText("text", itemRect.x, itemRect.y, itemRect.width / 2, itemRect.height / 2, 'center');
this.drawTextEx("saddsa", 0, 0);
this.drawFace("Actor2", 1 + index, itemRect.x, itemRect.y, itemRect.width / 2, itemRect.height / 2);
};
if anyone has an idea why it isn't working please help!
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
Code:
MenuSelectable.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, Dimeon.Windows.lh * 2);
this.refresh();
this.hide();
this._index = -1;
this._cursorFixed = false;
this._cursorAll = false;
this._stayCount = 0;
this._helpWindow = null;
this._handlers = {};
this._touching = false;
this._scrollX = 0;
this._scrollY = 0;

}
Window_Selectable.prototype.refresh = function(){
this.drawAllItems();
}
Window_Selectable.prototype.drawAllItems = function() {
var topIndex = this.topIndex();
for (var i = 0; i < this.maxPageItems(); i++) {
var index = topIndex + i;
if (index < this.maxItems()) {
this.drawItem(index);
}
}
};
Window_Selectable.prototype.maxPageRows = function() {
return 3;
}

Window_Selectable.prototype.maxItems = function() {
return 2;
}
You forgot to change the name from Window_Selectable to MenuSelectable. Also, you defined MenuSelectable as Window_Selectable prototype, but call Window_Base prototype initialize.
If you want, I suggest you watch my youtube tutorial series. It's in my signature.
 

UniqueName

Veteran
Veteran
Joined
Nov 12, 2018
Messages
78
Reaction score
12
First Language
Russian
Primarily Uses
Other
Code:
MenuSelectable.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, 0, 0, Graphics.boxWidth, Dimeon.Windows.lh * 2);
this.refresh();
this.hide();
this._index = -1;
this._cursorFixed = false;
this._cursorAll = false;
this._stayCount = 0;
this._helpWindow = null;
this._handlers = {};
this._touching = false;
this._scrollX = 0;
this._scrollY = 0;

}
Window_Selectable.prototype.refresh = function(){
this.drawAllItems();
}
Window_Selectable.prototype.drawAllItems = function() {
var topIndex = this.topIndex();
for (var i = 0; i < this.maxPageItems(); i++) {
var index = topIndex + i;
if (index < this.maxItems()) {
this.drawItem(index);
}
}
};
Window_Selectable.prototype.maxPageRows = function() {
return 3;
}

Window_Selectable.prototype.maxItems = function() {
return 2;
}
You forgot to change the name from Window_Selectable to MenuSelectable. Also, you defined MenuSelectable as Window_Selectable prototype, but call Window_Base prototype initialize.
If you want, I suggest you watch my youtube tutorial series. It's in my signature.
Yeah tnx for pointing that out, I also typed "_myScene" instead of "_menuSelectable" in this part
MenuScene.prototype.update = function() {
if (!this.drawnWindows){
this._myScene.drawAllItems();
this.drawnWindows = true;}
if (Input.isTriggered("cac")){ SceneManager.pop();
SoundManager.playCancel();
}
};
So I was able to get the text and actor face on screen but I still can't activate it, the highligthed option isn't flashing and I can only select options through "SceneManager._scene._menuSelectable.select()" command.
I also made this according to your tutorial but you wrote the code before you recorded the video and you didn't show some parts of the code.
I think that I missed something, I have 2 handlers in _menuSelectable but how does the game even decide which option in the window is which handler?
There certainly must be another function that I'm missing
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
In Window_Selectable prototype you have one ok handler for each selection. The game decides it through the .index() of the window when selected.

The biggest problem I see in your code is, your menuscene's update function doesn't call Scene_Menubase's update function.
 

UniqueName

Veteran
Veteran
Joined
Nov 12, 2018
Messages
78
Reaction score
12
First Language
Russian
Primarily Uses
Other
In Window_Selectable prototype you have one ok handler for each selection. The game decides it through the .index() of the window when selected.

The biggest problem I see in your code is, your menuscene's update function doesn't call Scene_Menubase's update function.
Yea apparently that was the main reason
Thx again
And I would suggest you either let the viewers download your js or show the full code you write in your tutorials cause sometimes its confusing
Like in episode 3 when you wrote the code before recording and didn't show the most of it as if you were expecting viewers to already know how to create command and selectable windows
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
Noted. But that is why youtube comments exist :p
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,074
Members
137,578
Latest member
JamesLightning
Top