How to set the touch priority of a layer?

YingnanWangYingnanWang USMember

I want to popup a setting menu layer at the gameStartScene. However, the button on the menu layer doesn't work when I click it while the button of the gameStartLayer still working when popup. I gusee it is because of the touch priority of the bottom layer is higher than the popup layer. So how can I set the priority?

my popupLayer
`public class PopUpLayer:CCLayer
CCLabel mTitle;
public CCSprite mBackgroundImage;
Button mConfirmBtn;

    public PopUpLayer (CCSprite background, CCLabel title)
        mBackgroundImage = background;
        mTitle = title;

        CreateLayer ();


    private void CreateLayer()
        mBackgroundImage.PositionX = ContentSize.Center.X;
        mBackgroundImage.PositionY = ContentSize.Center.Y;
        mBackgroundImage.IsAntialiased = false;
        this.AddChild (mBackgroundImage);

        mTitle.PositionX = mBackgroundImage.VisibleBoundsWorldspace.Center.X;
        mTitle.PositionY = mBackgroundImage.VisibleBoundsWorldspace.Center.Y + 250;
        mTitle.IsAntialiased = false;
        this.AddChild (mTitle);

        mConfirmBtn = new Button (this);
        mConfirmBtn.ButtonStyle = ButtonStyle.confirmBtn1;
        mConfirmBtn.btnText = "OK";
        mConfirmBtn.PositionX = mBackgroundImage.VisibleBoundsWorldspace.Center.X;
        mConfirmBtn.PositionY = mBackgroundImage.VisibleBoundsWorldspace.Center.Y - 250;
        mConfirmBtn.Clicked += BtnCallBack;
        this.AddChild (mConfirmBtn);


    private void BtnCallBack(object sender, EventArgs args)
        mConfirmBtn.RemoveBtnTouchListener ();


Call at the gameStartScene:

`CCSprite mSettingBackImage=new CCSprite("images/GameStartSettingPopUpBackground");
CCLabel mSettingTitle = new CCLabel ("Setting", "fonts/Gimme Danger.ttf", 30, CCLabelFormat.SystemFont);

        mSettingPopUp = new PopUpLayer (mSettingBackImage,mSettingTitle);

        mSettingPopUp.Position = gameStartLayer.VisibleBoundsWorldspace.Center;
        gameStartLayer.AddChild (mSettingPopUp);`


Sign In or Register to comment.