amsterd01 / cocos2d-android-1

Automatically exported from code.google.com/p/cocos2d-android-1
0 stars 0 forks source link

White textures appear while game is being played #97

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. play the game a few times
2. exit out of the game and come back
3.

What is the expected output? What do you see instead?
I expect to see my images on the screen. Instead I see white textures. 
Sometimes they turn white while playing the game. My GameLayer() code is below

What version of the product are you using? On what operating system?
latest version from github

Please provide any additional information below.
//code for GameLayer()
protected GameLayer(ccColor4B color)
    {
        super(color);
        Context mContext = CCDirector.sharedDirector().getActivity();

        this.setIsTouchEnabled(true);

        CGSize winSize = CCDirector.sharedDirector().displaySize();
        transT.initWithImage(getImage(mContext, R.drawable.trans,1));
        //backgroundT.initWithImage(getImage(mContext, R.drawable.background,2));
        //backTC.sharedTextureCache().addImage(getImage(mContext, R.drawable.background,2),"back");
        instructions1T.initWithImage(getImage(mContext, R.drawable.instructionguys,1));
        instructions2T.initWithImage(getImage(mContext, R.drawable.windinstructions,1));
        instructions3T.initWithImage(getImage(mContext, R.drawable.instructionguyswind,1));
        introT.initWithImage(getImage(mContext, R.drawable.introduction,1));
        levelupT.initWithImage(getImage(mContext, R.drawable.levelupguy,2));
        pauseT.initWithImage(getImage(mContext, R.drawable.pause,1));
        georgeT1.initWithImage(getImage(mContext, R.drawable.george_earth,1));
        georgeT2.initWithImage(getImage(mContext, R.drawable.george_fire,1));
        georgeT3.initWithImage(getImage(mContext, R.drawable.george_water,1));
        georgeT1D.initWithImage(getImage(mContext, R.drawable.george_earth_down,1));
        georgeT2D.initWithImage(getImage(mContext, R.drawable.george_fire_down,1));
        georgeT3D.initWithImage(getImage(mContext, R.drawable.george_water_down,1));
        georgeT1U.initWithImage(getImage(mContext, R.drawable.george_earth_up,1));
        georgeT2U.initWithImage(getImage(mContext, R.drawable.george_fire_up,1));
        georgeT3U.initWithImage(getImage(mContext, R.drawable.george_water_up,1));
        georgeT1Dead.initWithImage(getImage(mContext, R.drawable.george_earth_dead,1));
        georgeT2Dead.initWithImage(getImage(mContext, R.drawable.george_fire_dead,1));
        georgeT3Dead.initWithImage(getImage(mContext, R.drawable.george_water_dead,1));
        cloudsT.initWithImage(getImage(mContext, R.drawable.clouds,1));
        adsboardT.initWithImage(getImage(mContext, R.drawable.adsboard,1));
        scoreboardT.initWithImage(getImage(mContext, R.drawable.scoreboard,1));
        earthT.initWithImage(getImage(mContext, R.drawable.earth,1));
        fireT.initWithImage(getImage(mContext, R.drawable.fire,1));
        waterT.initWithImage(getImage(mContext, R.drawable.water,1));
        windT.initWithImage(getImage(mContext, R.drawable.wind,1));

        george = CCSprite.sprite(georgeT1);
        pause = CCSprite.sprite(pauseT);
        trans = CCSprite.sprite(transT);

        CCSprite background = CCSprite.sprite(CCTextureCache.sharedTextureCache().addImage(getImage(mContext,R.drawable.background,2), "backTC"));
        adsboard = CCSprite.sprite(adsboardT);
        scoreboard = CCSprite.sprite(scoreboardT);
        clouds = CCSprite.sprite(cloudsT);
        levelup = CCSprite.sprite(levelupT);
        intro = CCSprite.sprite(introT);
        instructions1 = CCSprite.sprite(instructions1T);
        instructions2 = CCSprite.sprite(instructions2T);
        instructions3 = CCSprite.sprite(instructions3T);

        System.gc();

        scoreLabel = CCBitmapFontAtlas.bitmapFontAtlas("0", "Try48a.fnt");
        windsLabel = CCBitmapFontAtlas.bitmapFontAtlas("0", "Try48a.fnt");
        livesLabel = CCBitmapFontAtlas.bitmapFontAtlas("x3", "Try72a.fnt");
        centerLabel = CCBitmapFontAtlas.bitmapFontAtlas("", "Try48a.fnt");
        instructionsLabel = CCBitmapFontAtlas.bitmapFontAtlas("Instructions", "Try48a.fnt");    
        highScoreLabel = CCBitmapFontAtlas.bitmapFontAtlas("High Score", "Try48a.fnt");
        levelLabel = CCBitmapFontAtlas.bitmapFontAtlas("", "Try96.fnt");
        levelLabel2 = CCBitmapFontAtlas.bitmapFontAtlas("", "Try96.fnt");
        instructLabel = CCBitmapFontAtlas.bitmapFontAtlas("", "Try36a.fnt");
        instructLabel2 = CCBitmapFontAtlas.bitmapFontAtlas("", "Try36a.fnt");
        instructLabel3 = CCBitmapFontAtlas.bitmapFontAtlas("", "Try36a.fnt");

        background.setPosition(winSize.width / 2.0f, winSize.height / 2.0f);
        trans.setPosition(winSize.width / 2.0f, winSize.height / 2.0f);
        adsboard.setPosition(winSize.width / 2.0f, scoreboard.getContentSize().height/2);
        clouds.setPosition(CGPoint.ccp(winSize.width / 2.0f, winSize.height - (winSize.height*0.25f)));
        george.setPosition(CGPoint.ccp(winSize.width / 2.0f, winSize.height*0.25f));
        scoreboard.setPosition(CGPoint.ccp(winSize.width / 2.0f, winSize.height - (scoreboard.getContentSize().height/2)));
        levelup.setPosition(CGPoint.ccp(winSize.width / 2.0f, winSize.height / 2.0f));
        intro.setPosition(CGPoint.ccp(winSize.width / 2.0f, winSize.height / 2.0f));
        pause.setPosition(CGPoint.ccp(pause.getContentSize().width, adsboard.getContentSize().height + pause.getContentSize().height*0.5f));
        instructions1.setPosition(winSize.width * .5f, winSize.height * 0.667f);
        instructions2.setPosition(winSize.width * .5f, winSize.height * 0.667f);
        instructions3.setPosition(winSize.width * .5f, winSize.height * 0.667f);

        background.setScale(2);
        trans.setScale(32);

        scoreLabel.setPosition(CGPoint.ccp(winSize.width*.25f, winSize.height-(scoreboard.getContentSize().height*.40f)));
        windsLabel.setPosition(CGPoint.ccp(winSize.width*.667f, winSize.height-(scoreboard.getContentSize().height*.40f)));
        livesLabel.setPosition(CGPoint.ccp(winSize.width*.85f, (adsboard.getContentSize().height + pause.getContentSize().height*0.5f)));
        centerLabel.setPosition(CGPoint.ccp(winSize.width*.5f, winSize.height*0.5f));
        levelLabel.setPosition(CGPoint.ccp(winSize.width*0.5f, winSize.height*0.75f));
        levelLabel2.setPosition(CGPoint.ccp(winSize.width*0.5f, winSize.height*0.667f));
        highScoreLabel.setPosition(winSize.width*.78f,adsboard.getContentSize().height*.37f);
        instructionsLabel.setPosition(winSize.width*.22f,adsboard.getContentSize().height*.37f);
        instructLabel.setPosition(winSize.width * 0.5f, winSize.height * .333f);
        instructLabel2.setPosition(winSize.width * 0.5f, winSize.height * .270f);
        instructLabel3.setPosition(winSize.width * 0.5f, winSize.height * .200f);

        addChild(background,1);
        addChild(clouds,2);
        addChild(pause,2);
        addChild(george,3);
        addChild(centerLabel,48);
        addChild(trans,49);
        addChild(levelup,50);
        addChild(intro,50);
        addChild(instructions1,51);
        addChild(instructions2,51);
        addChild(instructions3,51);
        addChild(adsboard,100);
        addChild(scoreboard,100);
        addChild(scoreLabel,101);
        addChild(windsLabel,101);
        addChild(livesLabel,101);
        addChild(levelLabel,101);
        addChild(levelLabel2,101);
        addChild(instructionsLabel,101);
        addChild(highScoreLabel,101);
        addChild(instructLabel,101);
        addChild(instructLabel2,101);
        addChild(instructLabel3,101);

        //set invisible layers
        levelup.setVisible(false);
        instructions1.setVisible(false);
        instructions2.setVisible(false);
        instructions3.setVisible(false);
        trans.setVisible(false);

        // Handle sound     
        SoundEngine.sharedEngine().preloadEffect(mContext, R.raw.aliensfxmp3);
        SoundEngine.sharedEngine().preloadEffect(mContext, R.raw.windwavmp3);
        SoundEngine.sharedEngine().playSound(mContext, R.raw.game, true);

        this.schedule("update");
    }

Original issue reported on code.google.com by cgmau...@gmail.com on 2 Sep 2011 at 11:15

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hello. 

We call CCDirector.sharedDirector().purgeCachedData() when the app is closed to 
solve it. 

But in Android 3.X the Android SDK UI get lost (appeared in black some of them 
like the textures cleaned clean the other activity android sdk UI). Cause  
gl.glDeleteTextures(1, new int[]{_name}, 0); in CCTexture2D. 

¿Any idea?

Original comment by manu.msp...@gmail.com on 14 Oct 2011 at 12:16

GoogleCodeExporter commented 8 years ago
I have the same problem but I create CCSprite in Thread and I think it not 
enough cached memory ! need help !

Original comment by tam.httam on 19 Mar 2012 at 3:52

GoogleCodeExporter commented 8 years ago
How are you getting the image from the drawable folder in the CCsprite? 
I am facing the file not found exception.I am using this code:

background = CCSprite.sprite(context.getString(R.drawable.mainmenu_bg));
Please help.

Original comment by himansh....@gmail.com on 9 Jul 2013 at 1:12

Attachments: