12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- // 静止
- 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 () {
- },
- // update (dt) {},
- idle:function() {
- this.g.clear();
-
- // 画脑袋和身体
- this.g.lineWidth = this.config.CIRCLE_WIDTH
- // 画个脑袋
- this.g.fillColor.fromHEX('#ffffff');
- this.g.circle(-1.5 * this.dir, 110, this.config.HEAD_SIZE);
- this.g.close();
- this.g.stroke();
- this.g.fill();
- // 画个身体
- this.g.fillColor.fromHEX('#ffffff');
- this.g.circle(8 * this.dir, 85, this.config.BODY_SIZE);
- this.g.close();
- this.g.stroke();
- this.g.fill();
- // 画手臂
- var handStart = cc.v2(-7 * this.dir, 86);
- var handEnd = cc.v2(handStart.x - this.dir * 10, handStart.y - 47);
- this.g.lineWidth = this.config.LINE_WIDTH;
- this.g.moveTo(handStart.x, handStart.y);
- this.g.bezierCurveTo(handStart.x, handStart.y, handStart.x, handStart.y - 40, 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 + 4, this.config.BAT_SIZE);
- this.g.close();
- this.g.stroke();
- this.g.fill();
- // 画手臂
- var handStart = cc.v2(13 * this.dir, 99);
- var handEnd = cc.v2(handStart.x + this.dir * 51, handStart.y - 18);
- this.g.lineWidth = this.config.LINE_WIDTH;
- this.g.moveTo(handStart.x, handStart.y);
- this.g.bezierCurveTo(handStart.x, handStart.y, handStart.x + this.dir * 27, handStart.y + 10, handEnd.x, handEnd.y);
- this.g.stroke();
- // 画裤子
- var trousersStart = cc.v2(0, 74);
- var trousersEnd = cc.v2(22 * this.dir, 79);
- this.g.moveTo(trousersStart.x, trousersStart.y);
- this.g.lineTo(trousersEnd.x, trousersEnd.y);
- this.g.stroke();
- // 画腿
- var legStart = cc.v2(10 * this.dir, 73);
- var legEnd = cc.v2(0, 0)
- this.g.moveTo(legStart.x, legStart.y);
- this.g.bezierCurveTo(legStart.x, legStart.y, -10 * this.dir, 60, legEnd.x, legEnd.y);
- this.g.lineTo(legEnd.x - this.dir * 6, legEnd.y);
- this.g.stroke();
- legStart = cc.v2(19 * this.dir, 78);
- legEnd = cc.v2(62 * this.dir, 0)
- this.g.moveTo(legStart.x, legStart.y);
- this.g.lineTo(legEnd.x, legEnd.y);
- this.g.lineTo(legEnd.x + this.dir * 6, legEnd.y);
- this.g.stroke();
- },
- });
|