Android 缩放精灵和引擎时,精灵和身体不相互连接2
精灵和它的身体在我缩放我的精灵时,看起来不会在一起。当我不缩放它们时,效果很好。请告诉我我能做些什么来解决这个问题 我使用DebugRenderer查看身体的位置,我可以看到附在身体上的精灵的一半。我的意思是雪碧的左上角连接到身体的中心。 无法发布屏幕截图 这是密码Android 缩放精灵和引擎时,精灵和身体不相互连接2,android,andengine,Android,Andengine,精灵和它的身体在我缩放我的精灵时,看起来不会在一起。当我不缩放它们时,效果很好。请告诉我我能做些什么来解决这个问题 我使用DebugRenderer查看身体的位置,我可以看到附在身体上的精灵的一半。我的意思是雪碧的左上角连接到身体的中心。 无法发布屏幕截图 这是密码 final Sprite circle=new Sprite(0, 0, circletexture, getVertexBufferObjectManager()); circle.setScaleX(0.5f);
final Sprite circle=new Sprite(0, 0, circletexture, getVertexBufferObjectManager());
circle.setScaleX(0.5f);
circle.setScaleY(0.5f);
circle.setWidth(circle.getWidthScaled());
circle.setHeight(circle.getHeightScaled());
circle.setPosition(CAMERA_WIDTH/2,CAMERA_HEIGHT/2);
SceneMenu.attachChild(circle);
final Body circleBody=PhysicsFactory.createCircleBody(mPhysicsWorld, circle, BodyType.DynamicBody, fixture);
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(circle, circleBody,true,false));
circleBody.setLinearVelocity(-5f,0);
SceneMenu.registerUpdateHandler(mPhysicsWorld);
您需要使用sprite的.setScaleCenter()方法设置缩放中心。实验和它应该起作用:)