2

我正在开发一个有 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);

球时刻略有变化,但在其他关卡(非动画关卡)中没有那么平滑。它仍然轻轻地反弹。由于这个问题无法玩游戏。

如果知道这一点,任何人都可以帮助我。任何回应将不胜感激。

谢谢。

4

1 回答 1

2

编码没有任何问题。我通过将动画图像的帧分辨率从 3x2(即 3 行和 2 列)更改为 3x3(即 3 行和 3 列)解决了这个问题。现在在所有动画关卡中,每个图像都有 9 帧,而以前每个图像有 6 帧。

通过使这个改变球时刻变得像现在在非动画关卡中一样平滑。

谢谢

于 2011-08-12T03:22:49.417 回答