开发者

How to make ball moment smoother in andengine

I am developing a maze and ball game with 20 levels. All the issues are fixed in my game except one problem. I am stuck at making balls moment smoother. the ball moment is good in all levels, except animated levels. I am not able to find where the mistake was.

In all levels balls are sprites and level images are sprites and animated sprites. I have animated sprites for level images along with balls in 6 levels. In remaining levels level images and balls both are spri开发者_如何学Pythontes only.

all animated sprites are having 1024x1024 size textures. I used the following code to create animated sprites.

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);

and following is the code to create sprites for balls

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++;
}

In all levels in which there is normal sprite for maze the ball moment is good. and in other levels i.e where i have animated sprites, there the ball moment is unusual. I have changed the physicsworld object code to

    mPhysicsWorld = new FixedStepPhysicsWorld(30, new Vector2(0,SensorManager.GRAVITY_EARTH), false);

instead of

     mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);

there is a slight change in ball moment but not as much smoother in other levels( non animated levels). it is still getting bounced lightly. and because of that problem not able to play the game.

Can any one help me if aware about this. any response would be appreciated.

Thanks.


There was nothing wrong in coding and all. I have resolved the issue by changing the frame resolution for animated images to 3x3 (i.e 3 rows and 3 columns) from 3x2 (i.e 3 rows and 2 columns). Now in all animated levels each image have 9 frames where previously had 6 frames each.

By making this change ball moment became as smoother as in non animated levels now.

Thanks

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜