今天接着学Phaser.js,写接元宝游戏,由于最后要放到移动端去玩,所以今天对游戏做出如下完善:
1.将game宽高改为百分比,适配屏幕
2.新增game.input.onDown来监听移动端触碰,本来在搜touch系事件,后来在stackoverflow上看了几个回答都一直推荐onDown。就去看文档然后就写出来了。
Phaser.Input.onDown.add介绍如下:
A Signal is used for object communication via a custom broadcaster instead of Events. class Phaser.Signal { Add a listener to the signal. arg function listener The function to call when this Signal is dispatched. arg object listenerContext (optional) The context under which the listener will be executed (i.e. the object that should represent the `this` variable). arg number priority (optional) The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower pr