How to create a Phaser button in Facebook instant games for a mobile device

后端 未结 1 1225
粉色の甜心
粉色の甜心 2021-01-23 19:54

I am trying to create a button with Phaser 2 CE on a mobile device but it doesn\'t fires, even if it works fine on desktop, the entiere code will be on my github repository but

相关标签:
1条回答
  • 2021-01-23 20:13

    It seems that alert("...") doesn't fire, and the code is correct because if you just make your sprite move, it moves, for example like the code below:

    var game = new Phaser.Game(640, 480, Phaser.AUTO, 'game', { preload: preload, create: create, update: update });
    var sprite;
    
    function  preload () {
      // This is equivalent to <https://examples.phaser.io/assets/>.
      this.load.image('dude', 'assets/sprites/phaser-dude.png');
    }
    
    function create() {
      sprite = game.add.sprite(game.world.centerX, game.world.centerY, 'dude');
      sprite.inputEnabled = true;
      sprite.events.onInputDown.add(myHandler, this);
    }
    
    function myHandler() {
      sprite.x += 10;
    }
    
    function update() {
    }
    
    0 讨论(0)
提交回复
热议问题