How to attach two sprites andengine
I am working on andengine and i have two sprite,sprite A and sprite B.Now
i want to attach sprite B to sprite A..but i already attach a body to
sprite A with the help of PhysicsConnector..then how to do it..please help
me.. Here is my code:
`final int centerX = (this.mspriteATextureRegion.getWidth()); final int
centerY = (CAMERA_HEIGHT - this.mSpriteATextureRegion.getHeight()) / 2;
final FixtureDef objectFixtureDef = PhysicsFactory.createFixtureDef(0,
0.5f, 0.5f);
spriteA= new Sprite(centerX, centerY, this.mSpriteATextureRegion);
body = PhysicsFactory.createBoxBody(mPhysicsWorld, spriteA,
BodyType.DynamicBody, objectFixtureDef);
mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(spriteA,
body, true, true));
final PhysicsHandler physicsHandler = new PhysicsHandler(spriteA);
spriteA.registerUpdateHandler(physicsHandler);
spriteB= new Sprite(centerX, centerY, this.mSpriteBTextureRegion);
spriteA.attachChild(spriteB,2);
scene.attachChild(spriteA,1);`
i am moving the sprite A with help oh anolog control.its not properly work..
No comments:
Post a Comment