0

I am trying to attach a child sprite with another sprite.

There is no error in the logcat, but only parent sprite is getting displayed on the screen.

Basically I have a car and I want to attach another sprite as a roof of that car, so I can change roofs color and other properties.

And I want to animate that car, so roof should also animate with that.

I tried many ways but nothing seems to be working.

Below is my code AnimatedSprite car = new AnimatedSprite( CAMERA_WIDTH/2, CAMERA_HEIGHT/2, carTexureRegion, this.getVertexBufferObjectManager());

AnimatedSprite roof = new AnimatedSprite( CAMERA_WIDTH/2, CAMERA_HEIGHT/2, roofTextureRegion, this.getVertexBufferObjectManager());

car.registerEntityModifier(new MoveXModifier(5f,CAMERA_WIDTH, 0));
roof.registerEntityModifier(new MoveXModifier(5f,CAMERA_WIDTH, 0));

roof.setZIndex(0);
car.setZIndex(1);

car.animate(200);

this.scene.attachChild(car);
roof.attachChild(car);

I try to debug the code by adding below line

int count = car.getChildCount();

Above line returns 1, which means the car has a child sprite but is not getting displayed on the screen

Please help!!!

Amit Chowdhury
  • 623
  • 1
  • 7
  • 22
Himanshu
  • 573
  • 1
  • 9
  • 15

1 Answers1

0

a sprite can just have one parent. at the end of your method the parent of car is roof, but u didn't attach roof to your scene...

Izu
  • 235
  • 1
  • 5