cocos creator 版本为 v2.3.0
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
demo: boolean = false
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.node.on('touchstart', () => {
console.log('touchstart:', this.demo) // 打印出来依旧是false
})
}
start () {
}
game_start () {
this.demo = true
console.log('game_start:', this.demo) // 打印出来是 true
}
// update (dt) {}
}