"use strict";
cc._RFpush(module, '280c3rsZJJKnZ9RqbALVwtK', 'touch');
// Script\touch.js

cc.Class({
    "extends": cc.Component,

    properties: {
        touch1: cc.Label,
        touch2: cc.Label,
        log: cc.Label,
        _touches: []
    },
    // use this for initialization
    onLoad: function onLoad() {
        var self = this;
        // cc.eventManager.addListener({
        //     event: cc.EventListener.TOUCH_ALL_AT_ONCE,
        //     onTouchesBegan: function(touch, event) {
        //         if(touch.length === 1){
        //             self.touch1.string = "X = " + touch[0].getLocation().x.toFixed(2) + "---------------Y = " + touch[0].getLocation().y.toFixed(2);

        //         }else{
        //             self.touch1.string = "X = " + touch[0].getLocation().x.toFixed(2) + "---------------Y = " + touch[0].getLocation().y.toFixed(2);
        //             self.touch2.string = "X = " + touch[1].getLocation().x.toFixed(2) + "---------------Y = " + touch[1].getLocation().y.toFixed(2);
        //         }

        //         self.log.string = touch[0].getID();

        //         return true;
        //     },
        //     onTouchesMoved: function(touch, event) {

        //     },
        //     onTouchesEnded: function(touch, event) {

        //     }
        // }, self.node)

        if (!cc.sys.isMobile) {
            return;
        }
        cc.eventManager.addListener({
            event: cc.EventListener.TOUCH_ALL_AT_ONCE,
            onTouchesBegan: function onTouchesBegan(touches, event) {
                return true;
            },
            onTouchesMoved: function onTouchesMoved(touches, event) {
                if (touches.length >= 2) {
                    var touch1 = touches[0],
                        touch2 = touches[1];

                    self.touch1.string = "X = " + touch1.getLocation().x.toFixed(2) + "---Y = " + touch1.getLocation().y.toFixed(2);
                    self.touch2.string = "X = " + touch2.getLocation().x.toFixed(2) + "---Y = " + touch2.getLocation().y.toFixed(2);
                    // var delta1 = touch1.getDelta(), delta2 = touch2.getDelta();
                    // var touchPoint1 = parent.convertToNodeSpaceAR(touch1.getLocation());
                    // var touchPoint2 = parent.convertToNodeSpaceAR(touch2.getLocation());
                    // //缩放
                    // var distance = touchPoint1.sub(touchPoint2);
                    // var delta = delta1.sub(delta2);
                    // var scale = 1;
                    // if (Math.abs(distance.x) > Math.abs(distance.y)) {
                    //     scale = (distance.x + delta.x) / distance.x * self.target.scale;
                    // }
                    // else {
                    //     scale = (distance.y + delta.y) / distance.y * self.target.scale;
                    // }
                    // self.target.scale = scale < 0.5 ? 0.5 : scale;
                }
            }
        }, self.node);
    }

});
// called every frame
// update: function (dt) {

// },

cc._RFpop();