Jump to content

Cannot find mouse x co-ordinate only on mobile


JonathanAlphonso
 Share

Recommended Posts

Hello everyone!

 

This is my first time using phaser (or node.js) and its really nifty! But theres this one thing I can't for the life of me figure out.

 

I made a remix based off a flappy bird game I found in a tutorial http://codevinsky.ghost.io/phaser-2-0-tutorial-flappy-bird-part-1/

 

The object of the game is to not get hit by upward moving pipes. You can click left of the bird to move left, and right of the bird to move right.

 

This works fine on desktop, but the mouse coordinates seems to be stuck at 0,0 on my android device.

 

You can see the game @ http://tests.jalphonso.com/dist/

 

Here are the codes for the click to flap controls

//This code is located in the create function in states/play.js    // add mouse/touch controls    this.game.input.onDown.addOnce(this.startGame, this);    this.game.input.onDown.add(this.bird.flap, this.bird);//This code is located in prefabs/bird.jsBird.prototype.flap = function() { if (this.body.x>this.game.input.mousePointer.x) {    this.flapLeft();    console.log(this.x);  }  else {this.flapRight();}};

I also put in a debug pointer circle, so I can see where the mouse is. It goes to the mouse on my laptop, but not my android. :(

 

Any and all help is greatly apperciated! :D

Link to comment
Share on other sites

That makes a lot of sense, andddd it works!

 

Just gotta fix how the game over screen doesn't appear on mobile. This happens with the flappy bird tutorial game as well :/

 

Also if anyone could suggest debugging methods for android devices that would be super. I am pretty excited to start making mobile friendly games :D

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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