3

I have successfully displayed an animation by using spritesheet(generated using TexturePacker). But when I set transparent background for the scene,it is not working! its displayed with black background. But for the other colors it is displaying the specified colors.

m_Scene.setBackground(new Background(Color.RED));//displayed with red Bg

m_Scene.setBackground(new Background(Color.TRANSPARENT));//displayed with black Bg

below is my full method onCreateScene() and my Activity extends SimpleBaseGameActivity

What could be the reason for this issue? can anyone help me to solve this ?

@Override
protected Scene onCreateScene() {

    m_Scene = new Scene();
    m_Scene.setBackground(new Background(Color.TRANSPARENT));
    mTiledTextureRegion = getTiledTextureFromPack("sample");
    mAnimatedSprite = new AnimatedSprite(0, 0, mTiledTextureRegion,
            this.getVertexBufferObjectManager());
    m_Scene.attachChild(mAnimatedSprite);
    mAnimatedSprite.animate(160);
    return m_Scene;
}

I have two activities "FirstActivity" and "SecondActivity". "FirstActivity" extends Activity and "SecondActivity" extends SimpleBaseGameActivity. What I'm doing is, I'm starting SecondActivity from FirstActivity on a button click.

   public void onGoButtonCLick(View view) {

      startActivity(new IntentFirstActivity.this,SecondActivity.class));
}

and the SecondActivity made as transparent in the manifest

android:theme="@android:style/Theme.Translucent"

Now the output screen displays transparent in other places but the scene area becomes black if set m_Scene.setBackground(new Background(Color.TRANSPARENT));

please check below link to see the output:

m_Scene.setBackground(new Background(Color.RED)); //displayed with red Bg

https://docs.google.com/file/d/0BwMxWp4Tk7MEUE53dEVnM3NoTlk/edit

m_Scene.setBackground(new Background(Color.TRANSPARENT));//displayed with black Bg

https://docs.google.com/file/d/0BwMxWp4Tk7MEVWZYWGJDa3o2Ums/edit

san
  • 490
  • 3
  • 8

1 Answers1

0

First I thought you want to make your phone screen transparent like a window because something eventually must be in the background;p But then I saw that you are using scene in the wrong way.

Probably the method onCreateScene is used in class extending Scene. It means that you mustn't create another scene on top of another. Instead of creating new Scene() use this.attachChild(sprite)

Mateusz Gaweł
  • 673
  • 1
  • 8
  • 22
  • I have added more detail to the question since comment area is restricted by number of letters. please check – san May 22 '14 at 08:47
  • tell me what effect you want to get after setting background to transparent? – Mateusz Gaweł May 22 '14 at 12:17
  • It should be transparent! I mean the layout of FirstActivity should be visible on the blackground, please check below links to see the output: `m_Scene.setBackground(new Background(Color.RED)); //displayed with red Bg` https://docs.google.com/file/d/0BwMxWp4Tk7MEUE53dEVnM3NoTlk/edit and `m_Scene.setBackground(new Background(Color.TRANSPARENT));//displayed with black Bg` https://docs.google.com/file/d/0BwMxWp4Tk7MEVWZYWGJDa3o2Ums/edit – san May 22 '14 at 15:18
  • in the above example only some area of FirstActivity layout displayed(marked with yellow arrow), other areas displayed as black! – san May 23 '14 at 09:53