Button touch event problem

  • webkuk
    Likes 1

    Problem Description

    Hi, again me ))

    var PlayBtn = ccui.Button.extend({

        ctor: function(){

            this._super(res.btnPlay);

            this.setPositionType(ccui.Widget.POSITION_PERCENT);

            this.setPositionPercent(cc.p(0.5,0.5));

            this.setTouchEnabled(true);

            this.setZoomScale(-0.1);

            this.addTouchEventListener( this.clcikPlay );

        },

        

        clickPlay: function(btn, type){

            switch (type){

                case ccui.Widget.TOUCH_BEGAN:

                    cc.director.runScene(new SplashScene());

                break;

            }

        }

    });

    Why this code dont work? Touch function clcikPlay dont call.

     

  • Sonar Systems admin
    Likes 0

    Your calling the function as 

    this.clcikPlay

    but the function is 

    clickPlay: function(btn, type){
    
    not
    
    clcikPlay: function(btn, type){

    So you should call it as

     this.addTouchEventListener( this.clickPlay );

     

  • webkuk
    Likes 1

    THX )) now it work )) im blind ))

  • Sonar Systems admin
    Likes 0

    Your welcome :D

Login to reply