cocosjs 触摸

/**
 * Created by sun on 15/11/24.
 */

var Piece = cc.Sprite.extend({
    ctor:function (num)
    {
        this._super();
        if(num==0)
        {
            this.initWithFile(res.piece_00_png);
        }
        else if(num==1)
        {
            this.initWithFile(res.piece_01_png);
        }
        else if(num==2)
        {
            this.initWithFile(res.piece_02_png);
        }
        else
        {
            this.initWithFile(res.piece_03_png);
        }

        cc.eventManager.addListener({
            event  : cc.EventListener.TOUCH_ONE_BY_ONE,
            swallowTouches  :  false,
            onTouchBegan  : this.onTouchBegan,
            onTouchMoved : this.onTouchMoved,
            onTouchEnded :  this.onTouchEnded

        },this);

        return true;
    },

    onTouchBegan :function(touch ,event)
    {
        var   touches  =touch.getLocation();
        if(touches){
            //cc.log("touches");
        }
        return true;
    },
    onTouchMoved : function(touch ,event)
    {
        cc.log("hello");
    },
    onTouchEnded :function(touch ,event){
        cc.log("world");
    }

});
posted @ 2015-11-24 16:43  yufenghou  阅读(140)  评论(0)    收藏  举报