//代码如下
cc.Class({
extends: cc.Component,
properties: {
mainMenu:cc.Node,
mapMenu:cc.Node,
},
onLoad () {
cc.director.getPhysicsManager().enabled = true;
//cc.director.getPhysicsManager().debugDrawFlags = 1;
this.initUI();
},
update (dt) {
cc.log(this.mainMenu.y);
},
beginGame:function(){
this.mainMenu.y=-720;
this.mapMenu.y=0;
},
quitGame:function(){
cc.game.end();
},
initUI:function(){
this.mainMenu.y=0;
this.mainMenu.x=0;
this.mapMenu.x=0;
this.mapMenu.y=-720;
cc.log("UI初始化完成!y的坐标是"+this.mainMenu.y);
},
});
//下面是测试结果
load quick_compile_project: 6.457763671875ms
quick_compile.js:236 eval quick_compile_project: 0.798828125ms
CCGame.js:401 Cocos Creator v2.3.3
assets\JavaScript\gameMode.js:35 UI初始化完成!y的坐标是0
assets\JavaScript\gameMode.js:18 0
66assets\JavaScript\gameMode.js:18 -720
6814assets\JavaScript\gameMode.js:18 -720
为啥闪了一个零,之后就又变成了-720,除了上述脚本没有任何脚本。
