当两个图像重叠时,其中一个就消失了.如何解决它



有两张图片

//1. 
player = new Sprite(300, 670, this.mChaTextureRegion, this.getVertexBufferObjectManager());
//2.
body[i] = PhysicsFactory.createCircleBody(this.mPhysicsWorld, ball[i], BodyType.DynamicBody, FIXTURE_DEF);
ball[i].setUserData(body[i]);
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(ball[i], body[i], true, true));
this.mScene.registerTouchArea(ball[i]);
this.mScene.attachChild(ball[i]);

ball被定义为TouchArea,但player没有。当两个图像(球员和球)重叠,我触摸球员时,球员消失了。玩家不应该消失。我怎样才能解决这个问题?

希望这对你有帮助:

final ILayer layer = mEngine.getScene().getLayer(YOUR_LAYER);
layer.addEntity(ball);
mPhysicsWorld.registerPhysicsConnector(ball.getPhysicsConnector());

不要注册每个球,但使用onSceneTouchEvent然后测试触球:

for (Ball ball : balls) {
if (ball.contains(eventx, eventy)) {
//touching the ball
}

相关内容

最新更新