变量初始化问题

刚接触coco,使用cocos的ide,写了个小demo,发现调试时正常,但打包成apk后怎样都黑屏,最终发现是由于变量在初始化的时候赋值问题。调试时,初始化赋值正常,但打包时不行,为什么?

var SnakeLayer = cc.LayerColor.extend({
    food : new cc.Sprite(res.food_png), //这里初始化无效
    ctor:function (color, width, height) {
        this._super(color, width, height);
        this.size = cc.winSize;
                this.food = new cc.Sprite(res.food_png);//这里初始化才行,注释掉黑屏
        this.food.attr({
            x: this.size.width / 4,
            y: this.size.height / 2,
        });
        this.addChild(this.food);
        return true;
    }
});

var SnakeScene = cc.Scene.extend({
    onEnter:function () {
        this._super();
        var layer = new SnakeLayer(cc.color("#ff0000"));
        this.addChild(layer);
    }
});


```

虽然我对javascript的语法也不熟,但你这个应该是语法问题!