cocos creator从零开发2048(10)-重新开始游戏

Canvas节点下新建Sprite (单色)并重命名为btnRestartPosition设置为280402Size设置为150x60Color设置为#A69A91,挂载Button组件并设置Transation属性为ScaleZoom Scale属性为1.1

cocos creator从零开发2048(10)-重新开始游戏_第1张图片

cocos creator从零开发2048(10)-重新开始游戏_第2张图片

btnRestart节点下新建Label (文字)String输入重新开始Font SizeLine Height都设置为30

编辑scripts/Game.ts,修改init方法,添加点击重新开始按钮的逻辑。

this.showScore()

const btnRestart = this.node.getChildByName('btnRestart')
btnRestart.on('click', () => cc.game.restart())

你可能感兴趣的:(cocos)