1
我在移相器中創建一個按鈕:移相器按鈕不調用函數
//---------------------------------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');
如何使按鈕調用一個函數?