1

有两个图像。

//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]);

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

4

1 回答 1

0

希望这会有所帮助:使用

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
}
于 2013-06-06T12:05:13.007 回答