我需要按以下方式运行此应用程序->:如果我触摸正确的项目,score+=5
则更改为gameover.xml
我不知道如何将活动更改为另一个布局?
public boolean onTouchEvent(MotionEvent event) {
int tx = (int) event.getX();
int ty = (int) event.getY();
int i = 0;
for (Element element : mElements) {
if ((element.getmX() < tx && tx < element.getmX()
+ element.getWidth())
&& (element.getmY() < ty && ty < element.getmY()
+ element.getHeight())) {
***if (mGarbagType == element.getGtype()) {
score += 5;
}else score-=5;***
Log.v("DustmanGame", "Touch on:" + element.getGtype()
+ "Score : 5");
mElements.remove(i);
mElementNumber = mElements.size();
mGarbagType = randomGarbage();
break;
}
i++;
}
return super.onTouchEvent(event);
}