java - && Syntax Error AGP for Dummies -
so, learning off of android game programming dummies book, , have run problem (on page 128) i'm given code
case motionevent.action_down: if (x > (screenw-playbuttonup.getwidth())/2 && x < ((screenw-playbuttonup.getwidth())/2) + playbuttonup.getwidth()) && y > (int)(screenh*0.45) && y < (int)(screenh*0.45) + playbuttonup.getheight()) { playbuttonpressed = true; } break;
and 4th 6th lines accompanied error "syntax error on token "&&", throw expected". have no idea on how fix this, i'd appreciate alternatives or help.
the parentheses messed up. specifically, second )
in line:
// -- 1 // v playbuttonup.getwidth()) &&
matches (
starting if
condition, meaning &&
after not part of condition. remove )
.
here's parentheses analysis:
if (x > (screenw-playbuttonup.getwidth())/2 && // ( = 3, ) = 2; nested level: 1 x < ((screenw-playbuttonup.getwidth())/2) + // ( = 3, ) = 3; nested level: 1 playbuttonup.getwidth()) && // ( = 1, ) = 2; nested level: 0 y > (int)(screenh*0.45) && // ( = 2, ) = 2; nested level: 0 y < (int)(screenh*0.45) + // ( = 2, ) = 2; nested level: 0 playbuttonup.getheight()) { // ( = 1, ) = 2; nested level: -1?!? playbuttonpressed = true; // total ( = 12, ) = 13 }
Comments
Post a Comment