我正在开发一个应用程序,但是当我尝试获取httprequest的状态代码时 为了知道哪个游戏结束叠加层调用状态代码被多次调用,所以我怎么只调用一次
public void update(float dt) {
for (NewPhysicsActor baseEnemyOthers: balloonList) {
if (baseEnemyOthers.getY() < 250) {
removeList.add(baseEnemyOthers);
gameFailed();
}
}
}
public void gameFailed() {
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl("https://www.google.com");
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
HttpStatus status = httpResponse.getStatus();
if (status.getStatusCode() >= 200 && status.getStatusCode() < 300) {
togglePaused();
watchVideoOverlay.setVisible(isPaused());
} else {
togglePaused();
levelFailedOverlay.setVisible(isPaused());
}
}
@Override
public void failed(Throwable t) {
togglePaused();
levelFailedOverlay.setVisible(isPaused());
}
@Override
public void cancelled() {
togglePaused();
levelFailedOverlay.setVisible(isPaused());
}
});
}
如果我断开数据连接,则一切正常 但是当问题继续存在时。 Watchoverlay()连续不断地被调用和关闭