Mr Nom is CRAZY!

Forum for the book "Beginning Android Games", see http://www.apress.com/9781430230427

Mr Nom is CRAZY!

Postby EderEnciso » Tue Aug 16, 2011 3:06 am

Greetings,

I just completed Mr Nom and it works just fine. There is however something weird. If I hold down either turn arrows Mr Nom goes CRAZY and starts spinning until he decides to stop.

I fixed it with the following code in the game screen:

if(event.type == TouchEvent.TOUCH_DOWN && !touchScreenPressed) {

touchScreenPressed = true;

if(event.x < 64 && event.y > 416) {
world.snake.turnLeft();

}
if(event.x > 256 && event.y > 416) {
world.snake.turnRight();

}

}

if(event.type == TouchEvent.TOUCH_UP && touchScreenPressed) {

if(event.x < 64 && event.y > 416) {
touchScreenPressed = false;

}
if(event.x > 256 && event.y > 416) {
touchScreenPressed = false;

}

}

I added some stuff as you can see. But of course I'm sure something I did made this happen but I have no idea what happened. Any thoughts?
EderEnciso
 
Posts: 3
Joined: Tue May 31, 2011 12:12 am

Re: Mr Nom is CRAZY!

Postby c:games » Sat Aug 20, 2011 6:40 am

I remember turning nom left and right on touchUp.
c:games
 
Posts: 13
Joined: Tue Jul 19, 2011 6:42 am


Return to Beginning Android Games

Who is online

Users browsing this forum: No registered users and 0 guests

x