123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- // 失败的动作
- 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;
- }
- },
- start () {
- },
- fail:function() {
- this.g.clear();
-
- // 画脑袋和身体
- this.g.lineWidth = this.config.CIRCLE_WIDTH
- // 画个脑袋
- this.g.fillColor.fromHEX('#ffffff');
- this.g.circle(this.dir * 1, 36, this.config.HEAD_SIZE);
- this.g.close();
- this.g.stroke();
- this.g.fill();
- // 画个身体
- this.g.fillColor.fromHEX('#ffffff');
- this.g.circle(this.dir * 27, 46, this.config.BODY_SIZE);
- this.g.close();
- this.g.stroke();
- this.g.fill();
- // 画手臂
- var handStart = cc.v2(this.dir * 16, 36);
- var handEnd = cc.v2(this.dir * 6, 1);
- this.g.lineWidth = this.config.LINE_WIDTH;
- this.g.moveTo(handStart.x, handStart.y);
- this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 16, 5, handEnd.x, handEnd.y);
- this.g.stroke();
- // 画个球拍
- this.g.lineWidth = this.config.CIRCLE_WIDTH
- this.g.fillColor.fromHEX('#ffffff');
- this.g.circle(this.dir * 2, 5, this.config.BAT_SIZE);
- this.g.close();
- this.g.stroke();
- this.g.fill();
- // 画手臂
- var handStart = cc.v2(this.dir * 20, 51);
- var handEnd = cc.v2(this.dir * 12, -1);
- this.g.lineWidth = this.config.LINE_WIDTH;
- this.g.moveTo(handStart.x, handStart.y);
- this.g.bezierCurveTo(handStart.x, handStart.y, this.dir * 25, 0, handEnd.x, handEnd.y);
- this.g.stroke();
- // 画裤子
- var trousersStart = cc.v2(this.dir * 39, 53);
- var trousersEnd = cc.v2(this.dir * 30, 32);
- this.g.moveTo(trousersStart.x, trousersStart.y);
- this.g.lineTo(trousersEnd.x, trousersEnd.y);
- this.g.stroke();
- // 画腿
- var legStart = cc.v2(this.dir * 27, 32);
- var legMid = cc.v2(this.dir * 26, 7);
- var legEnd = cc.v2(this.dir * 55, 8)
- this.g.moveTo(legStart.x, legStart.y);
- this.g.lineTo(legMid.x, legMid.y)
- this.g.bezierCurveTo(legMid.x, legMid.y, this.dir * 20, 0, legEnd.x, legEnd.y);
- this.g.lineTo(this.dir * 60, 5);
- this.g.stroke();
- legStart = cc.v2(this.dir * 38, 36);
- legMid = cc.v2(this.dir * 35, 5);
- legEnd = cc.v2(this.dir * 69, 3)
- this.g.moveTo(legStart.x, legStart.y);
- this.g.lineTo(legMid.x, legMid.y)
- this.g.bezierCurveTo(legMid.x, legMid.y, this.dir * 30, 0, legEnd.x, legEnd.y);
- this.g.lineTo(this.dir * 72, -2);
- this.g.stroke();
- },
- });
|