Commit 55d8ec14 authored by Dumplings X's avatar Dumplings X

fix

parent a7e92ed4
{ {
"name": "ng-template-generator", "name": "ng-template-generator",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"start": "ng serve", "start": "ng serve",
"build": "ng build --build--optimizer --aot --base-href /JGT/v3/", "build": "ng build --build--optimizer --aot --base-href /JGT/v3/",
"publish": "node ./bin/publish.js" "publish": "node ./bin/publish.js"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
......
import TWEEN from '@tweenjs/tween.js'; import TWEEN from '@tweenjs/tween.js';
import {del} from 'selenium-webdriver/http';
import construct = Reflect.construct;
class Sprite { class Sprite {
...@@ -49,14 +50,6 @@ export class MySprite extends Sprite { ...@@ -49,14 +50,6 @@ export class MySprite extends Sprite {
skewX = 0; skewX = 0;
skewY = 0; skewY = 0;
_shadowFlag = false;
_shadowColor;
_shadowOffsetX = 0;
_shadowOffsetY = 0;
_shadowBlur = 5;
_radius = 0;
children = [this]; children = [this];
childDepandVisible = true; childDepandVisible = true;
...@@ -83,21 +76,6 @@ export class MySprite extends Sprite { ...@@ -83,21 +76,6 @@ export class MySprite extends Sprite {
} }
setShadow(offX, offY, blur, color = 'rgba(0, 0, 0, 0.3)') {
this._shadowFlag = true;
this._shadowColor = color;
this._shadowOffsetX = offX;
this._shadowOffsetY = offY;
this._shadowBlur = blur;
}
setRadius(r) {
this._radius = r;
}
update($event = null) { update($event = null) {
if (!this.visible && this.childDepandVisible) { if (!this.visible && this.childDepandVisible) {
...@@ -116,8 +94,6 @@ export class MySprite extends Sprite { ...@@ -116,8 +94,6 @@ export class MySprite extends Sprite {
this.updateChildren(); this.updateChildren();
this.ctx.restore(); this.ctx.restore();
} }
drawInit() { drawInit() {
...@@ -133,48 +109,12 @@ export class MySprite extends Sprite { ...@@ -133,48 +109,12 @@ export class MySprite extends Sprite {
this.ctx.transform(1, this.skewX, this.skewY, 1, 0, 0); this.ctx.transform(1, this.skewX, this.skewY, 1, 0, 0);
if (this._radius) {
const r = this._radius;
const w = this.width;
const h = this.height;
this.ctx.lineTo(-w / 2, h / 2); // 创建水平线
this.ctx.arcTo(-w / 2, -h / 2, -w / 2 + r, -h / 2, r);
this.ctx.arcTo(w / 2, -h / 2, w / 2, -h / 2 + r, r);
this.ctx.arcTo(w / 2, h / 2, w / 2 - r, h / 2, r);
this.ctx.arcTo(-w / 2, h / 2, -w / 2, h / 2 - r, r);
this.ctx.clip();
}
} }
drawSelf() { drawSelf() {
if (this._shadowFlag) {
this.ctx.shadowOffsetX = this._shadowOffsetX;
this.ctx.shadowOffsetY = this._shadowOffsetY;
this.ctx.shadowBlur = this._shadowBlur;
this.ctx.shadowColor = this._shadowColor;
} else {
this.ctx.shadowOffsetX = 0;
this.ctx.shadowOffsetY = 0;
this.ctx.shadowBlur = null;
this.ctx.shadowColor = null;
}
if (this.img) { if (this.img) {
this.ctx.drawImage(this.img, this._offX, this._offY); this.ctx.drawImage(this.img, this._offX, this._offY);
} }
} }
updateChildren() { updateChildren() {
...@@ -359,7 +299,7 @@ export class ColorSpr extends MySprite { ...@@ -359,7 +299,7 @@ export class ColorSpr extends MySprite {
g = 0; g = 0;
b = 0; b = 0;
createGSCanvas() { createGSCanvas(){
if (!this.img) { if (!this.img) {
return; return;
...@@ -573,10 +513,10 @@ export class Label extends MySprite { ...@@ -573,10 +513,10 @@ export class Label extends MySprite {
this._shadowFlag = true; this._shadowFlag = true;
this._shadowColor = color; this._shadowColor = color;
// 将阴影向右移动15px,向上移动10px // 将阴影向右移动15px,向上移动10px
this._shadowOffsetX = 5; this._shadowOffsetX = offX;
this._shadowOffsetY = 5; this._shadowOffsetY = offY;
// 轻微模糊阴影 // 轻微模糊阴影
this._shadowBlur = 5; this._shadowBlur = blur;
} }
setOutline(width = 5, color = '#ffffff') { setOutline(width = 5, color = '#ffffff') {
...@@ -594,15 +534,15 @@ export class Label extends MySprite { ...@@ -594,15 +534,15 @@ export class Label extends MySprite {
if (!this.text) { return; } if (!this.text) { return; }
// if (this._shadowFlag) { if (this._shadowFlag) {
//
// this.ctx.shadowColor = this._shadowColor; this.ctx.shadowColor = this._shadowColor;
// // 将阴影向右移动15px,向上移动10px // 将阴影向右移动15px,向上移动10px
// this.ctx.shadowOffsetX = this._shadowOffsetX; this.ctx.shadowOffsetX = this._shadowOffsetX;
// this.ctx.shadowOffsetY = this._shadowOffsetY; this.ctx.shadowOffsetY = this._shadowOffsetY;
// // 轻微模糊阴影 // 轻微模糊阴影
// this.ctx.shadowBlur = this._shadowBlur; this.ctx.shadowBlur = this._shadowBlur;
// } }
...@@ -837,7 +777,6 @@ export class RichText extends Label { ...@@ -837,7 +777,6 @@ export class RichText extends Label {
export class ShapeRect extends MySprite { export class ShapeRect extends MySprite {
fillColor = '#FF0000'; fillColor = '#FF0000';
...@@ -866,6 +805,86 @@ export class ShapeRect extends MySprite { ...@@ -866,6 +805,86 @@ export class ShapeRect extends MySprite {
export class ShapeRectNew extends MySprite {
radius = 0;
fillColor = '#ffffff';
strokeColor = '#000000';
fill = true;
stroke = false;
lineWidth = 1;
setSize(w, h, r) {
this.width = w;
this.height = h;
this.radius = r;
}
setOutLine(color, lineWidth) {
this.stroke = true;
this.strokeColor = color;
this.lineWidth = lineWidth;
}
drawShape() {
const ctx = this.ctx;
const width = this.width;
const height = this.height;
const radius = this.radius;
ctx.save();
ctx.beginPath(0);
// 从右下角顺时针绘制,弧度从0到1/2PI
ctx.arc(width - radius, height - radius, radius, 0, Math.PI / 2);
// 矩形下边线
ctx.lineTo(radius, height);
// 左下角圆弧,弧度从1/2PI到PI
ctx.arc(radius, height - radius, radius, Math.PI / 2, Math.PI);
// 矩形左边线
ctx.lineTo(0, radius);
// 左上角圆弧,弧度从PI到3/2PI
ctx.arc(radius, radius, radius, Math.PI, Math.PI * 3 / 2);
// 上边线
ctx.lineTo(width - radius, 0);
// 右上角圆弧
ctx.arc(width - radius, radius, radius, Math.PI * 3 / 2, Math.PI * 2);
// 右边线
ctx.lineTo(width, height - radius);
ctx.closePath();
if (this.fill) {
ctx.fillStyle = this.fillColor;
ctx.fill();
}
if (this.stroke) {
ctx.lineWidth = this.lineWidth;
ctx.strokeStyle = this.strokeColor;
ctx.stroke();
}
ctx.restore();
}
drawSelf() {
super.drawSelf();
this.drawShape();
}
}
export class ShapeCircle extends MySprite { export class ShapeCircle extends MySprite {
fillColor = '#FF0000'; fillColor = '#FF0000';
...@@ -1076,7 +1095,7 @@ export function tweenChange(item, obj, time = 0.8, callBack = null, easing = nul ...@@ -1076,7 +1095,7 @@ export function tweenChange(item, obj, time = 0.8, callBack = null, easing = nul
} }
if (update) { if (update) {
tween.onUpdate( (a, b) => { tween.onUpdate( (a, b) => {
update(a, b); update(a, b);
}); });
} }
...@@ -1129,7 +1148,7 @@ export function moveItem(item, x, y, time = 0.8, callBack = null, easing = null) ...@@ -1129,7 +1148,7 @@ export function moveItem(item, x, y, time = 0.8, callBack = null, easing = null)
if (callBack) { if (callBack) {
tween.onComplete(() => { tween.onComplete(() => {
callBack(); callBack();
}); });
} }
if (easing) { if (easing) {
...@@ -1327,16 +1346,6 @@ export function removeItemFromArr(arr, item) { ...@@ -1327,16 +1346,6 @@ export function removeItemFromArr(arr, item) {
export function getPosDistance(sx, sy, ex, ey) {
const _x = ex - sx;
const _y = ey - sy;
const len = Math.sqrt( Math.pow(_x, 2) + Math.pow(_y, 2) );
return len;
}
...@@ -1380,6 +1389,13 @@ export function circleMove(item, x0, y0, time = 2, addR = 360, xPer = 1, yPer = ...@@ -1380,6 +1389,13 @@ export function circleMove(item, x0, y0, time = 2, addR = 360, xPer = 1, yPer =
} }
export function getPosDistance(sx, sy, ex, ey) {
const _x = ex - sx;
const _y = ey - sy;
const len = Math.sqrt( Math.pow(_x, 2) + Math.pow(_y, 2) );
return len;
}
export function delayCall(callback, second) { export function delayCall(callback, second) {
const tween = new TWEEN.Tween(this) const tween = new TWEEN.Tween(this)
...@@ -1392,27 +1408,6 @@ export function delayCall(callback, second) { ...@@ -1392,27 +1408,6 @@ export function delayCall(callback, second) {
.start(); .start();
} }
export function formatTime(fmt, date) {
// "yyyy-MM-dd HH:mm:ss";
const o = {
"M+": date.getMonth() + 1, // 月份
"d+": date.getDate(), // 日
"h+": date.getHours(), // 小时
"m+": date.getMinutes(), // 分
"s+": date.getSeconds(), // 秒
"q+": Math.floor((date.getMonth() + 3) / 3), // 季度
"S": date.getMilliseconds() // 毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1)
? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
export function getMinScale(item, maxLen) { export function getMinScale(item, maxLen) {
const sx = maxLen / item.width; const sx = maxLen / item.width;
const sy = maxLen / item.height; const sy = maxLen / item.height;
...@@ -1546,3 +1541,4 @@ export function shake(item, time = 0.5, callback = null, rate = 1) { ...@@ -1546,3 +1541,4 @@ export function shake(item, time = 0.5, callback = null, rate = 1) {
// --------------- custom class -------------------- // --------------- custom class --------------------
const res = [ const res = [
// ['bg', "assets/play/bg.jpg"], ['bg', "assets/play/bg.jpg"],
['btn_left', "assets/play/btn_left.png"], ['text_bg', "assets/play/text_bg.png"],
['btn_right', "assets/play/btn_right.png"], ['light', "assets/play/light.png"],
// ['text_bg', "assets/play/text_bg.png"], ['star', "assets/play/star.png"],
['shadow', "assets/play/shadow.png"],
['top_star', "assets/play/top_star.png"],
['top_star_bg', "assets/play/top_star_bg.png"],
['petal_1', "assets/default/petal_1.png"],
['petal_2', "assets/default/petal_2.png"],
['petal_3', "assets/default/petal_3.png"],
]; ];
...@@ -11,7 +19,15 @@ const res = [ ...@@ -11,7 +19,15 @@ const res = [
const resAudio = [ const resAudio = [
['click', "assets/play/music/click.mp3"], ['click', "assets/play/music/click.mp3"],
['right', "assets/play/music/right.mp3"],
['wrong', "assets/play/music/wrong.mp3"],
['star', "assets/play/music/star.mp3"],
['tip', "assets/play/music/tip.mp3"],
['finish', "assets/play/music/finish.mp3"],
]; ];
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
<script type="text/javascript" src="http://teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script> <script type="text/javascript" src="https://staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air.js"></script>
</head> </head>
<body> <body>
<app-root></app-root> <app-root></app-root>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment