mhamon1992 / cocos2d-android-1

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

CCLayer drawing issue #110

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi! When I using CCLayer as dialog(small CCLayer add's in other CCLayer) dialog 
layer have white band with size equal texture(see attach file).
And sorry for my language:)

Code for base dialog:

public class BaseDialog extends CCLayer {
    protected CloseDialogProtocol delegate;

    public void setDelegate(CloseDialogProtocol delegate){
    this.delegate = delegate;
    }

    @Override
    public void onEnter(){
          CCTouchDispatcher.sharedDispatcher().addTargetedDelegate(this, 0, true);
        super.onEnter();
    }

    @Override
    public void onExit(){
        CCTouchDispatcher.sharedDispatcher().removeDelegate(this);
        super.onExit();
    }

    @Override
    public boolean ccTouchesBegan(MotionEvent event){
        return super.ccTouchesBegan(event);
    }

    @Override
    public boolean ccTouchesEnded(MotionEvent event){
        return super.ccTouchesEnded(event);
    }
} 

Code for dialog in screenshot:
public class FailDialog extends BaseDialog {

    public FailDialog(boolean timeIsUp) {   
        CGSize screenSize = CCDirector.sharedDirector().winSize();

        //Fade panel
        CCSprite fadePanel = CCSprite.sprite("sr_pop_up_menu_shadow_screen.png");
        fadePanel.setPosition(CGPoint.ccp( screenSize.width * 0.5f, screenSize.height * 0.5f ));
        this.addChild( fadePanel );

        //Dialog panel
        CCSprite panel = CCSprite.sprite("sr_pop_up_menu_background.png");
        panel.setPosition(CGPoint.ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
        this.addChild( panel );

        //Show intro text
        String msg = String.format("%s",(timeIsUp ? "TIME IS UP" : "LEVEL FAILED") );
        CCTexture2D tex = new CCTexture2D();
        //CCTexture2D.setDefaultAlphaPixelFormat(Config.ARGB_8888);
        tex.initWithText(msg, "BerlinsansDemi", 30);

        CCSprite title = CCSprite.sprite(tex);
        tex.releaseTexture(CCDirector.gl);
        title.setPosition(CGPoint.ccp(screenSize.width * 0.5f, screenSize.height * 0.8f));
        this.addChild(title);

        //Init buttons
        //  Menu
        CCMenuItemImage menuItem = CCMenuItemImage.item("sr_pop_up_menu_button_menu_inactive.png",
                                                        "sr_pop_up_menu_button_menu_active.png",
                                                        this,
                                                        "btnClick");
        menuItem.setTag( CloseDialogProtocol.DialogStatus.DialogStatusMenu.getValue() );
        menuItem.setPosition(CGPoint.ccp(screenSize.width * 0.5f, screenSize.height * 0.632f));

        //  Restart
        CCMenuItemImage restartItem = CCMenuItemImage.item( "sr_pop_up_menu_button_restart_inactive.png",
                                                            "sr_pop_up_menu_button_restart_active.png",
                                                            this,
                                                            "btnClick");
        restartItem.setTag( CloseDialogProtocol.DialogStatus.DialogStatusRestart.getValue() );
        restartItem.setPosition(CGPoint.ccp(screenSize.width * 0.5f, screenSize.height * 0.432f));

        //  Shop
        CCMenuItemImage shopItem = CCMenuItemImage.item("sr_pop_up_menu_button_shop_inactive.png",
                                                        "sr_pop_up_menu_button_shop_active.png",
                                                         this,
                                                         "btnClick");
        shopItem.setTag( CloseDialogProtocol.DialogStatus.DialogStatusShop.getValue() );
        shopItem.setPosition(CGPoint.ccp(screenSize.width * 0.5f, screenSize.height * 0.245f));

        CCMenu menu = CCMenu.menu( restartItem, shopItem, menuItem );
        menu.setPosition(CGPoint.zero());
        this.addChild(menu);

        CCDirector.sharedDirector().pause();
    }

Original issue reported on code.google.com by andr...@octobersoft.net on 9 Dec 2011 at 12:22

Attachments: