繁体   English   中英

javascript无法读取未定义的未定义属性

[英]javascript cannot read property undefined of undefined

我需要快速的帮助,因为这个项目是在本星期三进行的,我不知道我的代码有什么问题以及将所有内容搞砸了。

这应该是战舰游戏

点击处理程序一直在骗我,希望您能为我提供帮助。

    this.Handler = function (getRow, getColumn) {
        var myId = "#grid_" + getRow + "_" + getColumn;

    if (this.GridArray[getRow][getColumn] == 0) {
        $(myId).removeClass('grid');
        $(myId).addClass('gridMiss');

        this.bullets--;
    }
    else if (this.GridArray[getRow][getColumn] == 1) {
        $(myId).removeClass('grid');
        $(myId).addClass('gridHit');
        explosion.pause();
        explosion.play();

        Ships.isHit(getRow, getColumn);
        this.ShipStatus();

        this.bullets--;
        this.bulletStatus();

        //call the function that keep track of the hits of the ships
    }
}

this.ClickHandler = function () {
    refOutside = this
    $('.grid').click(function (eventData) {
        var getRow = $(this).attr('data-Row');
        var getColumn = $(this).attr('data-Column');

        refOutside.Handler(getRow, getColumn);
    });
}

}

在这里,我创建了数组

this.CreateEmptyGrid = function () {

    for (i = 0; i < ROWS; i++) {
        this.GridArray[i] = [];
        for (j = 0; j < COLUMNS; j++) {
            this.GridArray[i][j] = 0;
        }
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM