“数组”在EaselJS CreateJS Container对象中不起作用

时间:2013-10-30 17:58:21

标签: javascript arrays tile easeljs createjs

我正在进行半OOP游戏并使用EaselJS作为我的库。到目前为止,我已经完成了大部分工作,但我遇到了一个持续且烦人的问题。当我将瓷砖渲染出来时,瓷砖容器失败了。由于某种原因,它不会读取“数组”类型。这是我的代码:

(function() {

var tile = function(array, _x, _y, spritesheet) {
  this.initialize(array, _x, _y, spritesheet);
}
tile.prototype = new createjs.Container();

tile.prototype.Container_initialize = this.initialize(array, _x, _y, spritesheet);
tile.prototype.initialize = function(array, _x, _y, spritesheet) {
    this.Container_initialize();
    this.x = _x * 120;
    this.y = _y * 120;

    this.tileArray = array; 

    this.tilesheet = spritesheet;

    for (var x = 0; x < this.tileArray.length; x++)
    {
        for (var y = 0; y < this.tileArray.length; y++)
        {
            console.log(this.tileArray[x][y]);
            var tileSprite = new createjs.Sprite(this.tilesheet, this.tileArray[x][y]);
            tileSprite.x = _x * 40 * x;
            tileSprite.y = _y * 40 * y;
        }       
    }
}

window.tile = tile;
}());

1 个答案:

答案 0 :(得分:0)

定义方法Container_initialize:

时删除参数
tile.prototype.Container_initialize = this.initialize;