我正在使用eclipse IDE进行移动开发的横向卷轴射击游戏,但是当涉及到与敌人物体相撞的子弹时,似乎有一点问题,有时它有效,有时它没有。任何人都知道为什么会这样吗?
以下是我的代码片段:
`boolean aabulletHit = Rect.intersects(abulletDst, aenemyDst);
if (aabulletHit) {
aenemyx1 = -100;aenemyx2 = -30;
abulletx1 = 1000; abulletx2 = 1115;
}
boolean abbulletHit = Rect.intersects(abulletDst, benemyDst);
if (abbulletHit) {
benemyx1 = -100;benemyx2 = -30;
abulletx1 = 1000; abulletx2 = 1115;
}
boolean acbulletHit = Rect.intersects(abulletDst, cenemyDst);
if (acbulletHit) {
cenemyx1 = -100;cenemyx2 = -30;
abulletx1 = 1000; abulletx2 = 1115;
}
boolean adbulletHit = Rect.intersects(abulletDst, denemyDst);
if (adbulletHit) {
denemyx1 = -100;denemyx2 = -30;
abulletx1 = 1000; abulletx2 = 1115;
}
boolean aebulletHit = Rect.intersects(abulletDst, eenemyDst);
if (aebulletHit) {
eenemyx1 = -100;eenemyx2 = -30;
abulletx1 = 1000; abulletx2 = 1115;
}`
我遇到的另一个问题是滚动的BG似乎也没有显示出来。