這可能看起來像一個非常簡單的問題,但我很困惑。 我有一個if條件,它有很多條件,我無法弄清楚在這種情況下使用的括號語法。任何人都可以給我一些關於如何弄清楚這個或其他if語句中有多少條件的情況的正確語法的提示嗎?謝謝!圍繞每個條件處理括號的語法
void collisionEn() {
for (int i = 0; i < myPlats.length; i++) {
if (posEx > myPlats[i].xPos)
&& (posEx+wEx > myPlats[i].xPos)
&& (posEx+wEx < myPlats[i].xPos + myPlats[i].platWidth)
&& (posEx < myPlats[i].xPos + myPlats[i].platWidth)
&& (posEy > myPlats[i].yPos)
&& (posEy < myPlats[i].yPos + myPlats[i].platHeight)
&& (posEy+wEy > myPlats[i]yPos)
&& (posEy+wEy < myPlats[i].yPos + myPlats[i].platHeight)
rect(0, 0, 1000, 1000);
我不知道Processing處理支持你所建議的第二種語法。我想我可能誤解了我正在閱讀的這本書,我會再次檢查它。另外,我犯的錯誤是:「&& posEy + wEy> myPlats [i] yPos」。我忘了在myPlats [i](。)yPos之後加上這個點。謝謝! – Alvarop 2013-04-22 12:05:16