【发布时间】:2023-03-09 06:18:01
【问题描述】:
每个人。 我正在使用 Andengine 制作 Android 游戏。 我在这个游戏中使用了 Autoparallax 背景。现在我想在屏幕上添加一个精灵,使视差背景出现在精灵的前面。然而,当精灵覆盖背景时,它并不像我预期的那样
这是我的代码
public static void populateSplashScene(Engine pEngine) {
// create and attach ground to splash scene
MainActivity.ground = new Sprite(0, 0,
mSpritesheetTextureRegionLibrary
.get(TextureRegionId.GROUNDGRASS_ID),
pEngine.getVertexBufferObjectManager());
MainActivity.ground.setOffsetCenter(0, 0);
MainActivity.background.attachParallaxEntity(new ParallaxEntity(-3,
MainActivity.ground));
// create and attach rock to splash scene
MainActivity.rock = new Sprite(0, 0,
mSpritesheetTextureRegionLibrary
.get(TextureRegionId.ROCKGRASS_ID),
pEngine.getVertexBufferObjectManager());
MainActivity.rock.setOffsetCenter(0, 0);
MainActivity.ground.attachChild(MainActivity.rock);
// create and attach rockDown to splashscene
MainActivity.rockDown = new Sprite(30, MainActivity.CAMERA_HEIGHT,
mSpritesheetTextureRegionLibrary
.get(TextureRegionId.ROCKGRASSDOWN_ID),
pEngine.getVertexBufferObjectManager());
MainActivity.rockDown.setOffsetCenter(0, 1);
MainActivity.ground.attachChild(MainActivity.rockDown)
PhysicsHandler physicsHandler = new PhysicsHandler(MainActivity.ground);
MainActivity.ground.registerUpdateHandler(physicsHandler);
physicsHandler.setVelocityX(-25);
}
我要隐藏的精灵是
rock
背景是
ground
我能做什么?任何帮助,将不胜感激。 提前致谢
【问题讨论】:
-
你只是想用'ground'(背景')隐藏'rock'?
-
背景是我的自动视差背景,地面是它的孩子。现在我想在背景和地面之间保持岩石,但我没有办法做到这一点。
-
看不懂,能不能发个图什么的再解释一下?
标签: java android parent-child andengine