Project1

标题: 学习JS遇到难题,请教。 [打印本页]

作者: 天浩    时间: 2019-7-15 19:32
标题: 学习JS遇到难题,请教。
大概写了这么一个场景窗口
为何指令无法移动,光标也不闪动呢?


JAVASCRIPT 代码复制
  1. //命令窗口
  2. function Window_ThmlList() {
  3.     this.initialize.apply(this, arguments);
  4. }
  5.  
  6. Window_ThmlList.prototype = Object.create(Window_Command.prototype);
  7. Window_ThmlList.prototype.initialize = function(x, y, width, height) {
  8.     Window_Command.prototype.initialize.call(this, x, y, width, height);
  9. };
  10.  
  11. Window_ThmlList.prototype.windowWidth = function() {
  12.     return 120;
  13. };
  14.  
  15. Window_ThmlList.prototype.numVisibleRows = function() {
  16.     return 2;
  17. };
  18. Window_ThmlList.prototype.makeCommandList = function() {
  19.         this.addCommand("加入", 'jiaru',true);
  20.         this.addCommand("离开", 'likai',true);
  21. };
  22.  
  23. //状态窗口
  24. function Window_ThztList() {
  25.     this.initialize.apply(this, arguments);
  26. }
  27.  
  28. Window_ThztList.prototype = Object.create(Window_Selectable.prototype);
  29. Window_ThztList.prototype.initialize = function(x, y, width, height) {
  30.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  31. };
  32.  
  33.  
  34. //仓库窗口
  35. function Window_ThjlList() {
  36.     this.initialize.apply(this, arguments);
  37. }
  38.  
  39. Window_ThjlList.prototype = Object.create(Window_Selectable.prototype);
  40. Window_ThjlList.prototype.initialize = function(x, y, width, height) {
  41.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  42. };
  43.  
  44. //队伍窗口
  45. function Window_ThlgList() {
  46.     this.initialize.apply(this, arguments);
  47. }
  48.  
  49. Window_ThlgList.prototype = Object.create(Window_Selectable.prototype);
  50. Window_ThlgList.prototype.initialize = function(x, y, width, height) {
  51.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  52. };
  53.  
  54. //场景设定
  55. function Scene_Thcz() {
  56.     this.initialize.apply(this, arguments);
  57. }
  58. Scene_Thcz.prototype.constructor = Scene_Thcz;
  59.  
  60. Scene_Thcz.prototype = Object.create(Scene_MenuBase.prototype);
  61. Scene_Thcz.prototype.initialize = function() {
  62.     Scene_MenuBase.prototype.initialize.call(this);
  63. };
  64. Scene_Thcz.prototype.create = function() {
  65.     Scene_MenuBase.prototype.create.call(this);
  66.     this.createThmlListWindow();
  67.     this._command2Window = new Window_ThjlList(120, 228, 120, 276);
  68.     this._command3Window = new Window_ThztList(240, 120, 464, 384);
  69.     this.addWindow(this._command2Window);
  70.     this.addWindow(this._command3Window);
  71. };
  72.  
  73. Scene_Thcz.prototype.update = function() {
  74.         this._command1Window.activate();
  75.     //this._command1Window.refresh();
  76.     if (Input.isTriggered('escape') || Input.isTriggered('cancel')) {
  77.         this._command1Window.hide();
  78.         this._command2Window.hide();
  79.         this._command3Window.hide();
  80.         SceneManager.goto(Scene_Map);
  81.    }
  82. };
  83.  
  84. Scene_Thcz.prototype.createThmlListWindow = function() {
  85.     this._command1Window = new Window_ThmlList(120, 120);
  86.     this._command1Window.setHandler('jiaru',  this.commandTh1.bind(this));
  87.     this._command1Window.setHandler('likai',  this.commandTh2.bind(this));
  88.     this._command1Window.setHandler('cancel', this.popScene.bind(this));
  89.     this.addWindow(this._command1Window);
  90. };
  91.  
  92. Scene_Thcz.prototype.commandTh1 = function() {
  93.         this._command2Window.activate();
  94.     this._command2indow.selectLast();
  95.         this._command1Window.drawText("武器",0,0,100,'left')
  96. };
  97.  
  98. Scene_Thcz.prototype.commandTh2 = function() {
  99.  
  100. };

作者: fux2    时间: 2019-7-15 19:44
窗口有激活和非激活状态,有的窗口在初始化的时候并没有激活(比如2级窗口)
你调用window.activate()就可以了




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1