Jump to content

Button in Phaser doesn't work


weratius
 Share

Recommended Posts

Hello!!!

 

I have a code, just a button created via Phaser:

//---------------------------------Boot
module.exports = {

init: function() {
closeButton = game.add.button(w/1.47, h/1.272, 'close', this.closeProfile, this);
closeButton.fixedToCamera = true;
closeButton.inputEnabled = true;
},

closeProfile: function() {
alert('asd')
close.key = 'img/profile/closePress.png';
}
};

Module.exports - this is Browserify

in the main file there is another code:

//---------------------------------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');

And button doesn't call a function at all

I really can't get it!

I will appreciate your help

Thanks in advacne!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...