cocosjs 모드 대화상자

2429 단어 cocosjsmsgbox
직접 부호
var MsgBoxLayer = cc.LayerColor.extend({
    sprite:null,
    ctor : function(color, width, height){
        this._super(color, width, height);
        this._touchListener = cc.EventListener.create({
            event: cc.EventListener.TOUCH_ONE_BY_ONE,
            swallowTouches: true,
            onTouchBegan:function () {
                return true;
            }
        });
        cc.eventManager.addListener(this._touchListener, this);
        //     UI  
        return true;
    },
    onExit : function(){
        if(this._touchListener) {
            cc.eventManager.removeListener(this._touchListener, 1);
            this._touchListener = null;
        }
    }
});

사용 방법:
var msgBox = new MsgBox(cc.color(0,0,0,0), 800, 600);
this.addChild(msgBox);

여기 몇 가지 지식이 있습니다.EventListener.create 공식 자체 관찰자 모드로 사용하기에 매우 편리합니다 2 이벤트:cc.EventListener.TOUCH_ONE_BY_원,swallow Touches:true, 이 두 파라미터는 층층이 전달되는 것을 보장하고 본 가이드가 터치 사건을 삼키고 더 이상 아래로 전달하지 않아 하층을 차단하는 목적을 달성한다.3 탈퇴하기 전에 청소하는 것을 잊지 마라
https://www.processon.com/i/568c6ea4e4b0e51d149a085f이 사이트 는 모두 가 디자인 단계 의 문제 를 해결하고 경량급 의 각종 디자인 모델 을 강력히 추천합니다

좋은 웹페이지 즐겨찾기