JonathanAlphonso Posted June 1, 2014 Share Posted June 1, 2014 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! Link to comment Share on other sites More sharing options...
rich Posted June 2, 2014 Share Posted June 2, 2014 You don't have a mouse on mobile, so "mousePointer" will always be zero Instead swap "mousePointer" for "activePointer" and it should work fine, as it will have detected you're on touch and swapped accordingly. JonathanAlphonso 1 Link to comment Share on other sites More sharing options...
JonathanAlphonso Posted June 2, 2014 Author Share Posted June 2, 2014 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 Link to comment Share on other sites More sharing options...
Recommended Posts