1

我在 COCOS2d 中使用 SpiderMonkey Javascript Engine 进行游戏。基本上我无法完全理解 Javascript Spidermonkey 的范围。Spidermonkey 是否使用不同类型的 Javascript。或者可能很简单,我对 javascript 很弱?

让我解释一下:这是一个类:

var mainLayer = cc.Layer.extend({ 
    genericArray : null,

    constructor: function () {
         this.genericArray = new Array();
         this.genericArray[0] = new TestObject();
    },

    onTouched : function() {
         this.genericArray[0].testme(); // THIS FAILS WITH SPIDERMONKEY, WORKS WITH ANY OTHER BROWSER
    }
}

它告诉我对象没有实例化。但我在构造函数中做到了。我担心问题在于如何在 onTouched 函数中解释它。有什么建议吗?

    var mainLayer = cc.Layer.extend({ 
    genericArray : null,

    constructor: function () {
         this.genericArray = new Array();
         this.genericArray[0] = new TestObject();
    },

    onTouched : function() {
        var genericArray = new Array();
        genericArray[0] = new TestObject();
        genericArray[0].testme(); // THIS WORKS CORRECTLY BOTH ON SPIDERMONKEY AND ON THE BROSWSER, BUT IS NOT WHAT I NEED!
    }
}
4

0 回答 0