// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
        // num:1,
        // matrix:11,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.tap();
    },
    tap:function(){
        var self = this;
        var tap = false;
        self.node.on("touchstart",function(){
            // console.log(tap);
            tap = true;
        });
        // self.node.on("touchmove",function(e){
        //     // console.log(e.getDelta());
        //     // if(e.getDelta().x>10)
        //     tap = false;
        // });
        self.node.on("touchend",function(){
            if(tap == true){
                // self.node.getComponent("block").num +=1;
                // self.node.children[0].getComponent(cc.Label).string = self.node.getComponent("block").num + self.node.name;
                // self.node.getComponent("block").num +=1;
                // self.node.getComponent(cc.Sprite).spriteFrame = self.block_sprite[self.node.getComponent("block").num];
                self.node.dispatchEvent(new cc.Event.EventCustom('add_num', true));
                tap = false;   
            }
            
        });
    }

    // update (dt) {},
});
