So, here is some code, witch works fine on web, but when i run it on win32/android, update() function just do nothing. (using cocos2d-x 3.10 and the same was in 3.9)
(here is app.js)
var winSize = cc.winSize;
var ghostGameLayer;
var action = cc.moveBy(10, cc.p(0, 500));
var a = 0;
var gameLevelScene = cc.Scene.extend({
onEnter: function() {
this._super();
var layer = new gameLevelLayer();
this.addChild(layer);
}
});
var gameLevelLayer = cc.Layer.extend({
sprite: null,
ctor: function() {
this._super();
var winSize = cc.winSize;
var ghost = new cc.Sprite(res.ghost_png);
var testLevelBackground = new cc.Sprite(res.testLevelBackground_png);
testLevelBackground.x = winSize.width / 2;
testLevelBackground.y = winSize.height / 2;
this.addChild(testLevelBackground, 0);
ghost.x = winSize.width / 2;
ghost.y = winSize.height / 2;
this.addChild(ghost, 0);
var playButton = new cc.MenuItemSprite(
new cc.Sprite(res.playButtonUnpressed_png),
new cc.Sprite(res.playButtonPressed_png), null,
this.onPlay, this);
lolbutton = playButton;
ghostGameLayer = ghost;
var menu = new cc.Menu(playButton);
menu.x = winSize.width / 4;
menu.y = winSize.height / 4;
this.addChild(menu);
this.scheduleUpdate();
var action = cc.moveBy(10, cc.p(0, 500));
var a = 0;
return true;
},
update: function(dt) {
if (a==0){
ghostGameLayer.runAction(action);
a = 1;
}
},
onPlay: function() {
}
});
I know, my code looks pretty bad, but - i’m just start learning, so anybody can explain, why update(dt) - dont start any actions (i tried other things too, and got nothng)?
P.S.
Sorry for my english.