Hi,
I’m new to Cocos2d-JS and I’m having problems when subclassing cc.Sprite; I have the following simple game layer:
var GameLayer = cc.Layer.extend({
ballSprite:null,
ctor:function () {
this._super();
this.init();
},
init:function () {
this._super();
this.ballSprite=new aBall();
this.addChild(this.ballSprite);
}
});
and this is the aBall subclass:
var aBall = cc.Sprite.extend({
ctor:function() {
this._super();
this.initWithFile(res.aBall1_png);
},
onEnter:function(){
this._super;
this.setPosition(500, 500);
var moveAction=cc.MoveTo.create(4,cc.p(0,500));
this.runAction(moveAction);
},
})
I have a PlyScene:
var PlayScene = cc.Scene.extend({
onEnter:function () {
this._super();
add three layer in the right order
this.addChild(new BackgroundLayer());
this.addChild(new GameLayer());
},
});
The problem is that the ball won’t move at all, it positions fine on the screen but the runAction has no effect at all and the ball remains static at the initial coordinates.
What am I doing wrong?