我在Phaser中创建了一个按钮:
//---------------------------------Boot
module.exports = {
init: function() {
closeButton = game.add.button(w/1.47, h/1.272, 'close', this.closeProf, this);
closeButton.fixedToCamera = true;
closeButton.inputEnabled = true;
},
closeProf: function() {
alert('aaa')
}
};
Module.exports - 这是Browserify。
在主文件中有以下代码:
//---------------------------------Main
window.game = new Phaser.Game((h > w) ? h : w, (h > w) ? w : h, Phaser.CANVAS, 'game', {render:render});
var ship;
var cursors;
var sun1;
var rc;
var space;
var profile;
var closeButton, holdLeft, holdRight, avaProfile;
game.state.add('Boot', require('./states/boot.js'));
game.state.add('Play', require('./states/play.js'));
game.state.start('Boot');
如何让按钮调用功能?