我正在制作一个破砖机游戏,我想在球击中地面时显示弹出窗口。但是,我尝试设置子场景或将弹出窗口设为对象并将其添加为实体。两种方法都有相同的错误如下所示。
有人可以给我任何建议吗?
谢谢!
public Scene onLoadScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
scene.registerUpdateHandler(new IUpdateHandler() {
public void reset() { }
public void onUpdate(final float pSecondsElapsed) {
if(ball.collidesWith(paddle)) {
ball.bounceWithRectangle(paddle);
}
else if (ball.getY() >= Game.getCAMERA_HEIGHT() - 30) {
scene.setBackground(new ColorBackground(255f, 0f, 0f));
scene.setIgnoreUpdate(true);
**scene.setChildScene(pauseScene(), false, true, true);
//scene.getTopLayer().addEntity(popup);**
}
}
更新了pauseScene():
public Scene pauseScene() {
Scene pauseScene = new Scene(1);
Texture mTexture = new Texture(256, 256, TextureOptions.BILINEAR);
TextureRegionFactory.setAssetBasePath("popup/");
TextureRegion textTextRegion = TextureRegionFactory.createFromAsset(mTexture, this, "canvas.jpg", 0, 0);
Sprite box = new Sprite(0, 0, textTextRegion);
pauseScene.getTopLayer().addEntity(box);
return pauseScene;
}
=============================================== ============= 其他尝试:
public Dialog onCreateDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this.getApplicationContext());
builder.setMessage("Hello");
AlertDialog alert = builder.create();
return alert;
}