123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550 |
- // 削球的动作
- 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:function() {
- this.schedule(this.peelUpdate, 1.0 / 15);
- },
- // 停止
- stop:function() {
- this.index = 1;
- this.unschedule(this.peelUpdate);
- },
- // 定时器
- peelUpdate:function(delay) {
- this.g.clear();
- if (this.index > 7) {
- this.index = 1;
- this.unschedule(this.peelUpdate);
- if (this.actionEnd != null) {
- this.actionEnd();
- }
- return;
- }
- if (this.index == 1) {
- this.peel_001();
- } else if (this.index == 2) {
- this.peel_002();
- } else if (this.index == 3) {
- this.peel_003();
- } else if (this.index == 4) {
- this.peel_004();
- } else if (this.index == 5) {
- this.peel_005();
- } else if (this.index == 6) {
- this.peel_006();
- } else if (this.index == 7) {
- this.peel_007();
- }
- this.index++;
- },
- 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) {},
- });
|