通过单击按钮销毁 Phaser.Image 对象会导致 TypeError

Destroying Phaser.Image object through Button click results in TypeError

我正在使用 Phaser-framework(版本 2.2.2)和 JavaScript 制作 HTML5 游戏。我现在正在为游戏创建一些 UI 元素。以下代码表示游戏中的UIwindow

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();
};

我遇到了 exitButton 的问题。它的 spritesheet 有 3 个帧,它们都在它们被设置为使用的状态下工作。现在,此代码有效 - 当我按下 exitButton 时,我的 "window" 关闭。但是,如果我像在上面的代码中那样为 exitButton 设置所有四个帧,我会收到以下错误:

"Uncaught TypeError: Cannot read property 'cache' of null"

如果我从按钮创建中删除最后两帧(downFrame 和 upFrame),即将其更改为以下内容,则不会发生错误:

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

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

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