【问题标题】:Sprite and Body not attached to each other when sprites are scaled Andengine GLES2缩放精灵和引擎 GLES2 时,精灵和身体不相互连接
【发布时间】:2014-03-12 06:21:04
【问题描述】:
当我缩放我的 sprite 时,

Sprite 和它的 body 看起来并不在一起。当我不缩放它们时它工作正常。请告诉我我能做些什么来解决这个问题。

我正在使用 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);

【问题讨论】:

    标签: android andengine


    【解决方案1】:

    您需要使用精灵的 .setScaleCenter() 方法设置缩放中心。实验一下,它应该可以工作:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-19
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 2015-09-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多