I’m following the Mr. Nom tutorial from Beginning Android Game e-book,
and in the part which recognizes where a touch was made, the if statement doesn’t execute even though the condition in true.
I ran the debugger and checked the values. the if is something like
if(event.x >0 && event.x <64 && event.y>416 && event.y<480)
but even with values like
event.x = 15
event.y = 450
(got from the debugger)
it won’t get within the curly brackets of the if statement.
the requested image is in the bottom left corner of the portrait screen.
any thoughts?
Thanks!
If
event.x = 15andevent.y = 450, then the conditionevaluates to true. Something else must be wrong in your code. (Perhaps the branch is executed, just that you don’t see the effect of it for some reason.) Please post more code, or even better, an SSCCE.
To debug the situation, I’d suggest you break up the expression and do something like