Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 通过单击按钮销毁相位器。图像对象会导致类型错误_Javascript_Phaser Framework - Fatal编程技术网

Javascript 通过单击按钮销毁相位器。图像对象会导致类型错误

Javascript 通过单击按钮销毁相位器。图像对象会导致类型错误,javascript,phaser-framework,Javascript,Phaser Framework,我正在使用Phaser框架(版本2.2.2)和JavaScript制作一个HTML5游戏。我现在正在为游戏创建一些UI元素。下面的代码表示游戏中的UI窗口 var PointEditScreen = function(game) { Phaser.Image.call(this, game, 600, 50, 'background'); var exitButton = game.add.button(360, 5, 'exit-button', this.closeScreen, t

我正在使用Phaser框架(版本2.2.2)和JavaScript制作一个HTML5游戏。我现在正在为游戏创建一些UI元素。下面的代码表示游戏中的UI窗口

var PointEditScreen = function(game) {
  Phaser.Image.call(this, game, 600, 50, 'background');
  var exitButton = game.add.button(360, 5, 'exit-button', this.closeScreen, this, 1, 0, 2, 0);
  this.addChild(exitButton);

PointEditScreen.prototype.closeScreen = function() {
  this.destroy();
};
我的退出按钮有问题。它的精灵表有3个框架,它们都在设置为使用的状态下工作。现在,这个代码起作用了——当我按下退出按钮时,我的“窗口”关闭了。但是,如果我像在上面的代码中那样为
exitButton
设置所有四个帧,则会出现以下错误:

"Uncaught TypeError: Cannot read property 'cache' of null"
如果我从按钮创建中删除最后两帧(下帧和上帧),即将其更改为以下内容,则不会发生错误:

var exitButton = game.add.button(360, 5, 'exit-button', this.closeScreen, this, 1, 0);

我做错了什么?如何在不从按钮创建中删除这两个帧声明的情况下消除错误?

这似乎是Phaser中的一个错误,现在在较新的版本2.3.0中正常工作。

发现有人有同样的问题:Phaser中可能有错误?