如果玩家盾牌低于0,则游戏结束并且广告应该弹出一次并保持到下一个游戏开始但它弹出两次。我找不到我的错误。
if (hitDetected){
player.reduceShieldStrength();
if (player.getShieldStrength() < 0) {
gameEnded = true;
runOnUiThread(new Runnable() {
@Override
public void run() {
showBanner();
}
});
}
}
if (player.getShieldStrength() > 0){
runOnUiThread(new Runnable() {
@Override
public void run() {
hideBanner();
}
});
}
我的showBanner方法:
private void showBanner() {
adView.setVisibility(View.VISIBLE);
adView.loadAd(new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build());
}