Commit 9d80174a authored by rockyl's avatar rockyl

更新

parent cff2d3ee
......@@ -3,34 +3,41 @@
*/
import {IAnimation} from "./IAnimation";
export class Wave implements IAnimation {
static round: Function = function (h: number, t: number): any {
export function round(h: number, t: number): any {
return {x: Math.cos(t) * h, y: Math.sin(t) * h};
};
static cos: Function = function (h: number, t: number): any {
}
export function cos(h: number, t: number): any {
return {x: Math.cos(t) * h, y: 0};
};
static sin: Function = function (h: number, t: number): any {
}
export function sin(h: number, t: number): any {
h = h || 1;
return {x: 0, y: Math.sin(t) * h};
};
static rotate: Function = function (t: number): any {
}
export function rotate(t: number): any {
return {r: 360 * t / Math.PI / 2};
};
static shake: Function = function (angle: number, count: number, t: number): any {
}
export function shake(angle: number, count: number, t: number): any {
return {r: Math.sin(t * count) * angle};
};
static breath: Function = function (scale: number, t: number): any {
}
export function breath(scale: number, t: number): any {
return {sx: Math.sin(t) * scale + 1, sy: -Math.sin(t + Math.PI / 4) * scale + 1};
};
static zoom: Function = function (scale: number, t: number): any {
}
export function zoom(scale: number, t: number): any {
scale = scale || 0.1;
return {sx: Math.sin(t) * scale + 1, sy: Math.sin(t) * scale + 1};
};
static fade: Function = function (base, t: number): any {
}
export function fade(base, t: number): any {
return {alpha: (Math.sin(t) + 1) * 0.5 + base};
};
}
export class Wave implements IAnimation {
_tween: egret.Tween;
target: any;
......
/**
* Created by rockyl on 2018/9/26.
*
* 动画队列
*/
export class TweenQueue{
push(){
}
}
......@@ -16,7 +16,7 @@ export function callNet(url: string, params: any = null, method: string = egret.
resolve(request.response);
}, this);
request.addEventListener(egret.IOErrorEvent.IO_ERROR, function (event: egret.Event): void {
reject('request error.');
reject(new Error('request error.'));
}, this);
request.open(finalUrl, method);
......
......@@ -9,7 +9,7 @@
* @returns {number}
*/
export function distancePoint(p1: any, p2: any): number {
return this.distance(p1.x, p1.y, p2.x, p2.y);
return distance(p1.x, p1.y, p2.x, p2.y);
}
/**
......@@ -38,6 +38,9 @@ export function centerPoint(p1: any, p2: any) {
* @returns {number}
*/
export function radian(p1: any, p2: any): number {
if(p2.y == p1.y || p2.x == p1.x){
return NaN;
}
return Math.atan2(p2.y - p1.y, p2.x - p1.x);
}
......@@ -48,7 +51,11 @@ export function radian(p1: any, p2: any): number {
* @returns {number}
*/
export function angle(p1: any, p2: any): number {
return this.radiusToAngle(this.radian(p1, p2));
const r = radian(p1, p2);
if(isNaN(r)){
return r;
}
return radiusToAngle(r);
}
/**
......@@ -91,7 +98,7 @@ export function makeRandomByRange(value: number, range: number): number {
export function makeRandomIntArr(len: number, max: number, min: number = 0): number[] {
let target: number[] = [];
for (let i: number = 0; i < len; i++) {
target.push(this.makeRandomInt(max));
target.push(makeRandomInt(max));
}
return target;
......@@ -120,8 +127,8 @@ export function makeOrderIntArray(to: number, from: number = 0, step: number = 1
*/
export function mixArray(arr: any): Array<any> {
for (let i: number = 0, len: number = Math.round(arr.length / 2); i < len; i++) {
let a: number = this.makeRandomInt(arr.length);
let b: number = this.makeRandomInt(arr.length);
let a: number = makeRandomInt(arr.length);
let b: number = makeRandomInt(arr.length);
let temp = arr[a];
arr[a] = arr[b];
arr[b] = temp;
......@@ -141,8 +148,8 @@ export function mixArray2(arr: Array<Array<any>>): Array<Array<any>> {
let pos0: number[];
let pos1: number[];
for (let i: number = 0, len: number = Math.round(cH * cV / 2); i < len; i++) {
pos0 = [this.makeRandomInt(cH), this.makeRandomInt(cV)];
pos1 = [this.makeRandomInt(cH), this.makeRandomInt(cV)];
pos0 = [makeRandomInt(cH), makeRandomInt(cV)];
pos1 = [makeRandomInt(cH), makeRandomInt(cV)];
let temp = arr[pos0[0]][pos0[1]];
arr[pos0[0]][pos0[1]] = arr[pos1[0]][pos1[1]];
arr[pos1[0]][pos1[1]] = temp;
......@@ -158,7 +165,7 @@ export function mixArray2(arr: Array<Array<any>>): Array<Array<any>> {
* @returns {*}
*/
export function getRandomFromArray(arr: any, del = false): any {
let index = this.makeRandomInt(arr.length);
let index = makeRandomInt(arr.length);
let item = arr[index];
if (del) {
arr.splice(index, 1);
......@@ -303,7 +310,7 @@ export function split(total, count) {
result[i] = 0;
}
for (let i = 0; i < total; i++) {
result[this.makeRandomInt(count)]++;
result[makeRandomInt(count)]++;
}
return result;
}
......@@ -363,7 +370,7 @@ export function intersectToPolygon(points: any[], intersect: any[]) {
dd = points[i + 1];
}
if (this.intersectToIntersect(aa, bb, cc, dd)) {
if (intersectToIntersect(aa, bb, cc, dd)) {
result = true;
break;
}
......
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