// 削球的动作
cc.Class({
    extends: cc.Component,

    properties: {
        loc: 0, // 代表方向，0为正位，1为反位
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        // 配置绘制的数据
        // 从配置中心获取数据
        this.config = require ("gameconfig")
        // 配置绘制组件
        this.g = this.getComponent(cc.Graphics);
        
        // 配置方向
        if (this.loc == 0) {
            this.dir = 1;
        } else {
            this.dir = -1;
        }

        this.index = 1;
    },

    // start () {},

    peel_001:function() {
        // 画脑袋和身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH

        // 画个脑袋
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * -7, 115, this.config.HEAD_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画个身体
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * -20, 90, this.config.BODY_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * -7, 95);
        var handEnd = cc.v2(this.dir * 14, 50);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 3, 60, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画个球拍
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(handEnd.x + this.dir * 3, handEnd.y + 2, this.config.BAT_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * -27, 102);
        var handEnd = cc.v2(this.dir * -64, 79);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * -45, 115, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画裤子
        var trousersStart = cc.v2(this.dir * -10, 79);
        var trousersEnd = cc.v2(this.dir * -33, 83);
        this.g.moveTo(trousersStart.x, trousersStart.y);
        this.g.lineTo(trousersEnd.x, trousersEnd.y);
        this.g.stroke();

        // 画腿
        var legStart = cc.v2(this.dir * -14, 76);
        var legEnd = cc.v2(0, 0)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, this.dir * 5, 60, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();

        legStart = cc.v2(this.dir * -26, 76);
        legEnd = cc.v2(this.dir * -62, 0)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, this.dir * -55, 35, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x - this.dir * 6, legEnd.y);
        this.g.stroke();
    },

    peel_002:function() {
        // 画脑袋和身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH

        // 画个脑袋
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * -56, 85, this.config.HEAD_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画个身体
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * -52, 57, this.config.BODY_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * -44, 69);
        var handEnd = cc.v2(this.dir * 6, 54);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * -10, 51, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画个球拍
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(handEnd.x + this.dir * 2, handEnd.y + 3, this.config.BAT_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * -63, 66);
        var handEnd = cc.v2(this.dir * -74, 25);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * -105, 52, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画裤子
        var trousersStart = cc.v2(this.dir * -41, 47);
        var trousersEnd = cc.v2(this.dir * -66, 51);
        this.g.moveTo(trousersStart.x, trousersStart.y);
        this.g.lineTo(trousersEnd.x, trousersEnd.y);
        this.g.stroke();

        // 画腿
        var legStart = cc.v2(this.dir * -43, 45);
        var legEnd = cc.v2(0, 2)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, 0, 80, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, 0);
        this.g.stroke();

        legStart = cc.v2(this.dir * -62, 44);
        legEnd = cc.v2(this.dir * -61, 2)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, this.dir * -140, 65, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x - this.dir * 6, legEnd.y);
        this.g.stroke();
    },

    peel_003:function() {
        // 画脑袋
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.fillColor.fromHEX('#ffffff');
        if (this.loc == 0) {
            this.g.arc(29, 55, this.config.HEAD_SIZE, Math.PI / 2 - Math.PI / 8, Math.PI * 1.5, true)
            this.g.lineTo(54, 46);
            this.g.arc(53, 50, this.config.HEAD_SIZE, Math.PI * 1.5 + Math.PI / 12, Math.PI / 2, true)
            this.g.lineTo(31, 59);
        } else {
            this.g.arc(-29, 55, this.config.HEAD_SIZE, Math.PI / 2 + Math.PI / 8, Math.PI * 1.5, false)
            this.g.lineTo(-54, 46);
            this.g.arc(-53, 50, this.config.HEAD_SIZE, Math.PI * 1.5 - Math.PI / 12, Math.PI / 2, false)
            this.g.lineTo(-31, 59);
        }

        // 画个身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * 45, 23, this.config.BODY_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * 59, 25);
        var handEnd = cc.v2(this.dir * 79, 66);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 90, 35, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画个球拍
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(handEnd.x - this.dir * 4, handEnd.y + 1, this.config.BAT_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * 34, 31);
        var handEnd = cc.v2(this.dir * -28, 38);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, 0, 22, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画裤子
        var trousersStart = cc.v2(this.dir * 30, 23);
        var trousersEnd = cc.v2(this.dir * 51, 9);
        this.g.moveTo(trousersStart.x, trousersStart.y);
        this.g.lineTo(trousersEnd.x, trousersEnd.y);
        this.g.stroke();

        // 画腿
        var legStart = cc.v2(this.dir * 55, 11);
        var legEnd = cc.v2(this.dir * 100, -32)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, this.dir * 120, 40, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();

        legStart = cc.v2(this.dir * 32, 14);
        legEnd = cc.v2(this.dir * -63, -1)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, 0, 10, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x - this.dir * 6, legEnd.y);
        this.g.stroke();
    },

    peel_004:function() {
        // 画脑袋和身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH

        // 画个脑袋
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * 60, 47, this.config.HEAD_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画个身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * 50, 20, this.config.BODY_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * 63, 23);
        var handEnd = cc.v2(this.dir * 100, 73);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 85, 30, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画个球拍
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(handEnd.x - this.dir * 5, handEnd.y - 1, this.config.BAT_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * 44, 31);
        var handEnd = cc.v2(this.dir * -15, 58);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 10, 35, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画裤子
        var trousersStart = cc.v2(this.dir * 35, 25);
        var trousersEnd = cc.v2(this.dir * 52, 5);
        this.g.moveTo(trousersStart.x, trousersStart.y);
        this.g.lineTo(trousersEnd.x, trousersEnd.y);
        this.g.stroke();

        var legStart = cc.v2(this.dir * 61, 10);
        var legEnd = cc.v2(this.dir * 100, -33)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, this.dir * 120, 40, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();

        // 画腿
        legStart = cc.v2(this.dir * 37, 11);
        legEnd = cc.v2(this.dir * -66, -1)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, 0, 10, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();
    },

    peel_005:function() {
        // 画脑袋和身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH

        // 画个脑袋
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * 61, 52, this.config.HEAD_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画个身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * 49, 25, this.config.BODY_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * 63, 28);
        var handEnd = cc.v2(this.dir * 110, -9);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 85, 19, handEnd.x, handEnd.y);
        this.g.stroke();
        
        // 画个球拍
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.fillColor.fromHEX('#ffffff');
        if (this.loc == 0) {
            // 正位
            this.g.arc(110, 60, this.config.BAT_SIZE + 2, Math.PI * 1.5 - Math.PI / 8, Math.PI / 4, false);
            this.g.bezierCurveTo(113, 62, 142, 30, 118, -9);
            this.g.arc(113, -6, this.config.BAT_SIZE + 2, -Math.PI / 8, Math.PI - Math.PI / 4, false);
            this.g.bezierCurveTo(111, -8, 130, 30, 107, 57);
        } else {
            // 逆位
            this.g.arc(-110, 60, this.config.BAT_SIZE + 2, Math.PI * 1.5 + Math.PI / 8, Math.PI / 4 * 3, true);
            this.g.bezierCurveTo(-113, 62, -142, 30, -118, -9);
            this.g.arc(-113, -6, this.config.BAT_SIZE + 2, Math.PI + Math.PI / 8, Math.PI / 4, true);
            this.g.bezierCurveTo(-111, -8, -130, 30, -107, 57);
        }
        this.g.stroke();

        // 画手臂
        var handStart = cc.v2(this.dir * 41, 33);
        var handEnd = cc.v2(this.dir * -12, 58);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 10, 43, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画裤子
        var trousersStart = cc.v2(this.dir * 36, 27);
        var trousersEnd = cc.v2(this.dir * 51, 10);
        this.g.moveTo(trousersStart.x, trousersStart.y);
        this.g.lineTo(trousersEnd.x, trousersEnd.y);
        this.g.stroke();

        var legStart = cc.v2(this.dir * 54, 10);
        var legEnd = cc.v2(this.dir * 100, -33)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, this.dir * 120, 40, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();

        // 画腿
        legStart = cc.v2(this.dir * 39, 14);
        legEnd = cc.v2(this.dir * -66, -1)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, 0, 10, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();
    },

    peel_006:function() {
        // 画脑袋和身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH

        // 画个脑袋
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * 68, 56, this.config.HEAD_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画个身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * 58, 30, this.config.BODY_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * 71, 30);
        var handEnd = cc.v2(this.dir * 45, -18);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 82, 5, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画个球拍
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(handEnd.x - this.dir * 1, handEnd.y + 8, this.config.BAT_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * 47, 40);
        var handEnd = cc.v2(this.dir * -18, 54);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 26, 43, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画裤子
        var trousersStart = cc.v2(this.dir * 43, 31);
        var trousersEnd = cc.v2(this.dir * 63, 14);
        this.g.moveTo(trousersStart.x, trousersStart.y);
        this.g.lineTo(trousersEnd.x, trousersEnd.y);
        this.g.stroke();

        var legStart = cc.v2(this.dir * 61, 14);
        var legEnd = cc.v2(this.dir * 100, -33)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, this.dir * 140, 20, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();

        // 画腿
        legStart = cc.v2(this.dir * 45, 21);
        legEnd = cc.v2(this.dir * -66, -1)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, 0, 10, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();
    },

    peel_007:function() {
        // 画脑袋和身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH

        // 画个脑袋
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * 61, 52, this.config.HEAD_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画个身体
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(this.dir * 50, 25, this.config.BODY_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * 65, 26);
        var handEnd = cc.v2(this.dir * 33, -4);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 82, -10, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画个球拍
        this.g.lineWidth = this.config.CIRCLE_WIDTH
        this.g.fillColor.fromHEX('#ffffff');
        this.g.circle(handEnd.x - this.dir * 1, handEnd.y + 6, this.config.BAT_SIZE);
        this.g.close();
        this.g.stroke();
        this.g.fill();

        // 画手臂
        var handStart = cc.v2(this.dir * 50, 39);
        var handEnd = cc.v2(this.dir * -21, 42);
        this.g.lineWidth = this.config.LINE_WIDTH;
        this.g.moveTo(handStart.x, handStart.y);
        this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 30, 45, handEnd.x, handEnd.y);
        this.g.stroke();

        // 画裤子
        var trousersStart = cc.v2(this.dir * 35, 28);
        var trousersEnd = cc.v2(this.dir * 53, 10);
        this.g.moveTo(trousersStart.x, trousersStart.y);
        this.g.lineTo(trousersEnd.x, trousersEnd.y);
        this.g.stroke();

        var legStart = cc.v2(this.dir * 57, 12);
        var legEnd = cc.v2(this.dir * 100, -33)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, this.dir * 140, 20, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();

        // 画腿
        legStart = cc.v2(this.dir * 38, 19);
        legEnd = cc.v2(this.dir * -66, -1)
        this.g.moveTo(legStart.x, legStart.y);
        this.g.bezierCurveTo(legStart.x, legStart.y, 0, 10, legEnd.x, legEnd.y);
        this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
        this.g.stroke();
    },

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