Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 缩放精灵和引擎时,精灵和身体不相互连接2_Android_Andengine - Fatal编程技术网

Android 缩放精灵和引擎时,精灵和身体不相互连接2

Android 缩放精灵和引擎时,精灵和身体不相互连接2,android,andengine,Android,Andengine,精灵和它的身体在我缩放我的精灵时,看起来不会在一起。当我不缩放它们时,效果很好。请告诉我我能做些什么来解决这个问题 我使用DebugRenderer查看身体的位置,我可以看到附在身体上的精灵的一半。我的意思是雪碧的左上角连接到身体的中心。 无法发布屏幕截图 这是密码 final Sprite circle=new Sprite(0, 0, circletexture, getVertexBufferObjectManager()); circle.setScaleX(0.5f);

精灵和它的身体在我缩放我的精灵时,看起来不会在一起。当我不缩放它们时,效果很好。请告诉我我能做些什么来解决这个问题

我使用DebugRenderer查看身体的位置,我可以看到附在身体上的精灵的一半。我的意思是雪碧的左上角连接到身体的中心。 无法发布屏幕截图

这是密码

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()方法设置缩放中心。实验和它应该起作用:)