精灵由Sprite和Body类组成。 Sprite类处理sprite的“look”,body处理它的物理(触摸边界等)。
问题是我可以通过调用setScale()来扩展sprite。但这并没有扩大它的身体。
简单示例:
sprite = new Sprite(x, y, mTextureRegion, mObjectManager);
sprite.setScale(2); //scales sprite at 2
//since sprite is scaled at 2, body will also be scaled at 2
body = PhysicsFactory.createCircleBody(mPhysicsWorld, sprite, DynamicBody, FIXTURE_DEF);
face.setScale(3); //scales ONLY sprite, body doesn't get scaled
//sprite size is scaled at 3 but it's body (boundaries) are still scaled at 2
有没有办法缩放精灵的身体?
答案 0 :(得分:1)
在缩放Body
后附加sprite
。
如果您想再次调整sprite
的大小,请取消注册registerPhysicsConnector
并缩放sprite
然后再次连接精灵和身体。
希望它有效..!