我正在开发一个有 20 个关卡的迷宫和球类游戏。除了一个问题,我的游戏中的所有问题都已修复。我被困在让球更光滑的时刻。球时刻在所有级别都很好,除了动画级别。我无法找到错误在哪里。
在所有关卡中,球都是精灵,关卡图像是精灵和动画精灵。我有用于关卡图像的动画精灵以及 6 个关卡中的球。在其余关卡中,关卡图像和球都只是精灵。
所有动画精灵都有 1024x1024 大小的纹理。我使用以下代码创建动画精灵。
this.multipleImagesTexture = new Texture(1024,1024,TextureOptions.BILINEAR_PREMULTIPLYALPHA);
this.multipleImagesTextureRegion = TextureRegionFactory.createTiledFromResource(this.multipleImagesTexture, this, getResources().getIdentifier(m_level.m_levelImages.get(j), "drawable", "com.andmaze.mobile"),0, 0, col,row);
this.mEngine.getTextureManager().loadTexture(this.multipleImagesTexture);
multipleimagesdragon = new AnimatedSprite(5, 83, this.multipleImagesTextureRegion);
multipleimagesdragon.animate(1000);
scene.getFirstChild().attachChild(multipleimagesdragon);
以下是为球创建精灵的代码
for(GoliMeta g : metalist) {
balls_Array[index] = new Sprite(g.X , g.Y, ballTextureRegion);
Body body = PhysicsFactory.createCircleBody(mPhysicsWorld, balls_Array[index], BodyType.DynamicBody, FIXTURE_DEF);
scene.getFirstChild().attachChild(balls_Array[index]);
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(balls_Array[index], body, true, false));
index++;
}
在所有有迷宫正常精灵的关卡中,球的时刻都很好。而在其他级别,即我有动画精灵的地方,球的时刻是不寻常的。我已将physicsworld 对象代码更改为
mPhysicsWorld = new FixedStepPhysicsWorld(30, new Vector2(0,SensorManager.GRAVITY_EARTH), false);
代替
mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);
球时刻略有变化,但在其他关卡(非动画关卡)中没有那么平滑。它仍然轻轻地反弹。由于这个问题无法玩游戏。
如果知道这一点,任何人都可以帮助我。任何回应将不胜感激。
谢谢。