初始化默认数值
This commit is contained in:
2
demo/libs/framework/framework.d.ts
vendored
2
demo/libs/framework/framework.d.ts
vendored
@@ -1165,6 +1165,7 @@ declare module es {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
|
var matrixPool: any[];
|
||||||
class Matrix2D extends egret.Matrix {
|
class Matrix2D extends egret.Matrix {
|
||||||
m11: number;
|
m11: number;
|
||||||
m12: number;
|
m12: number;
|
||||||
@@ -1183,6 +1184,7 @@ declare module es {
|
|||||||
divide(matrix: Matrix2D): Matrix2D;
|
divide(matrix: Matrix2D): Matrix2D;
|
||||||
multiply(matrix: Matrix2D): Matrix2D;
|
multiply(matrix: Matrix2D): Matrix2D;
|
||||||
determinant(): number;
|
determinant(): number;
|
||||||
|
release(matrix: Matrix2D): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||||
@@ -1129,6 +1129,7 @@ var es;
|
|||||||
}
|
}
|
||||||
if (this._instance._scene == null) {
|
if (this._instance._scene == null) {
|
||||||
this._instance._scene = value;
|
this._instance._scene = value;
|
||||||
|
this._instance.addChild(value);
|
||||||
this._instance._scene.begin();
|
this._instance._scene.begin();
|
||||||
Core.Instance.onSceneChanged();
|
Core.Instance.onSceneChanged();
|
||||||
}
|
}
|
||||||
@@ -1161,7 +1162,6 @@ var es;
|
|||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0:
|
case 0:
|
||||||
this.startDebugUpdate();
|
|
||||||
es.Time.update(egret.getTimer());
|
es.Time.update(egret.getTimer());
|
||||||
if (!this._scene) return [3, 2];
|
if (!this._scene) return [3, 2];
|
||||||
for (i = this._globalManagers.length - 1; i >= 0; i--) {
|
for (i = this._globalManagers.length - 1; i >= 0; i--) {
|
||||||
@@ -1173,17 +1173,17 @@ var es;
|
|||||||
this._scene.update();
|
this._scene.update();
|
||||||
}
|
}
|
||||||
if (!this._nextScene) return [3, 2];
|
if (!this._nextScene) return [3, 2];
|
||||||
|
this.removeChild(this._scene);
|
||||||
this._scene.end();
|
this._scene.end();
|
||||||
this._scene = this._nextScene;
|
this._scene = this._nextScene;
|
||||||
this._nextScene = null;
|
this._nextScene = null;
|
||||||
this.onSceneChanged();
|
this.onSceneChanged();
|
||||||
|
this.addChild(this._scene);
|
||||||
return [4, this._scene.begin()];
|
return [4, this._scene.begin()];
|
||||||
case 1:
|
case 1:
|
||||||
_a.sent();
|
_a.sent();
|
||||||
_a.label = 2;
|
_a.label = 2;
|
||||||
case 2:
|
case 2: return [2];
|
||||||
this.endDebugUpdate();
|
|
||||||
return [2];
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1787,9 +1787,19 @@ var es;
|
|||||||
})(DirtyType = es.DirtyType || (es.DirtyType = {}));
|
})(DirtyType = es.DirtyType || (es.DirtyType = {}));
|
||||||
var Transform = (function () {
|
var Transform = (function () {
|
||||||
function Transform(entity) {
|
function Transform(entity) {
|
||||||
|
this._localTransform = es.Matrix2D.create();
|
||||||
this._worldTransform = es.Matrix2D.create().identity();
|
this._worldTransform = es.Matrix2D.create().identity();
|
||||||
this._worldToLocalTransform = es.Matrix2D.create().identity();
|
this._worldToLocalTransform = es.Matrix2D.create().identity();
|
||||||
this._worldInverseTransform = es.Matrix2D.create().identity();
|
this._worldInverseTransform = es.Matrix2D.create().identity();
|
||||||
|
this._rotationMatrix = es.Matrix2D.create();
|
||||||
|
this._translationMatrix = es.Matrix2D.create();
|
||||||
|
this._scaleMatrix = es.Matrix2D.create();
|
||||||
|
this._position = es.Vector2.zero;
|
||||||
|
this._scale = es.Vector2.one;
|
||||||
|
this._rotation = 0;
|
||||||
|
this._localPosition = es.Vector2.zero;
|
||||||
|
this._localScale = es.Vector2.one;
|
||||||
|
this._localRotation = 0;
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.scale = es.Vector2.one;
|
this.scale = es.Vector2.one;
|
||||||
this._children = [];
|
this._children = [];
|
||||||
@@ -2111,6 +2121,10 @@ var es;
|
|||||||
})(CameraStyle = es.CameraStyle || (es.CameraStyle = {}));
|
})(CameraStyle = es.CameraStyle || (es.CameraStyle = {}));
|
||||||
var CameraInset = (function () {
|
var CameraInset = (function () {
|
||||||
function CameraInset() {
|
function CameraInset() {
|
||||||
|
this.left = 0;
|
||||||
|
this.right = 0;
|
||||||
|
this.top = 0;
|
||||||
|
this.bottom = 0;
|
||||||
}
|
}
|
||||||
return CameraInset;
|
return CameraInset;
|
||||||
}());
|
}());
|
||||||
@@ -2123,6 +2137,8 @@ var es;
|
|||||||
var _this = _super.call(this) || this;
|
var _this = _super.call(this) || this;
|
||||||
_this._minimumZoom = 0.3;
|
_this._minimumZoom = 0.3;
|
||||||
_this._maximumZoom = 3;
|
_this._maximumZoom = 3;
|
||||||
|
_this._bounds = new es.Rectangle();
|
||||||
|
_this._inset = new CameraInset();
|
||||||
_this._transformMatrix = new es.Matrix2D().identity();
|
_this._transformMatrix = new es.Matrix2D().identity();
|
||||||
_this._inverseTransformMatrix = new es.Matrix2D().identity();
|
_this._inverseTransformMatrix = new es.Matrix2D().identity();
|
||||||
_this._origin = es.Vector2.zero;
|
_this._origin = es.Vector2.zero;
|
||||||
@@ -2131,9 +2147,9 @@ var es;
|
|||||||
_this._isProjectionMatrixDirty = true;
|
_this._isProjectionMatrixDirty = true;
|
||||||
_this.followLerp = 0.1;
|
_this.followLerp = 0.1;
|
||||||
_this.deadzone = new es.Rectangle();
|
_this.deadzone = new es.Rectangle();
|
||||||
_this.focusOffset = new es.Vector2();
|
_this.focusOffset = es.Vector2.zero;
|
||||||
_this.mapLockEnabled = false;
|
_this.mapLockEnabled = false;
|
||||||
_this.mapSize = new es.Vector2();
|
_this.mapSize = es.Vector2.zero;
|
||||||
_this._desiredPositionDelta = new es.Vector2();
|
_this._desiredPositionDelta = new es.Vector2();
|
||||||
_this._worldSpaceDeadZone = new es.Rectangle();
|
_this._worldSpaceDeadZone = new es.Rectangle();
|
||||||
_this._targetEntity = targetEntity;
|
_this._targetEntity = targetEntity;
|
||||||
@@ -5317,6 +5333,7 @@ var es;
|
|||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
(function (es) {
|
(function (es) {
|
||||||
|
es.matrixPool = [];
|
||||||
var Matrix2D = (function (_super) {
|
var Matrix2D = (function (_super) {
|
||||||
__extends(Matrix2D, _super);
|
__extends(Matrix2D, _super);
|
||||||
function Matrix2D() {
|
function Matrix2D() {
|
||||||
@@ -5383,26 +5400,57 @@ var es;
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
Matrix2D.create = function () {
|
Matrix2D.create = function () {
|
||||||
return egret.Matrix.create();
|
var matrix = es.matrixPool.pop();
|
||||||
|
if (!matrix)
|
||||||
|
matrix = new Matrix2D();
|
||||||
|
return matrix;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.identity = function () {
|
Matrix2D.prototype.identity = function () {
|
||||||
_super.prototype.identity.call(this);
|
this.a = this.d = 1;
|
||||||
|
this.b = this.c = this.tx = this.ty = 0;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.translate = function (dx, dy) {
|
Matrix2D.prototype.translate = function (dx, dy) {
|
||||||
_super.prototype.translate.call(this, dx, dy);
|
this.tx += dx;
|
||||||
|
this.ty += dy;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.scale = function (sx, sy) {
|
Matrix2D.prototype.scale = function (sx, sy) {
|
||||||
_super.prototype.scale.call(this, sx, sy);
|
if (sx !== 1) {
|
||||||
|
this.a *= sx;
|
||||||
|
this.c *= sx;
|
||||||
|
this.tx *= sx;
|
||||||
|
}
|
||||||
|
if (sy !== 1) {
|
||||||
|
this.b *= sy;
|
||||||
|
this.d *= sy;
|
||||||
|
this.ty *= sy;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.rotate = function (angle) {
|
Matrix2D.prototype.rotate = function (angle) {
|
||||||
_super.prototype.rotate.call(this, angle);
|
angle = +angle;
|
||||||
|
if (angle !== 0) {
|
||||||
|
angle = angle / DEG_TO_RAD;
|
||||||
|
var u = Math.cos(angle);
|
||||||
|
var v = Math.sin(angle);
|
||||||
|
var ta = this.a;
|
||||||
|
var tb = this.b;
|
||||||
|
var tc = this.c;
|
||||||
|
var td = this.d;
|
||||||
|
var ttx = this.tx;
|
||||||
|
var tty = this.ty;
|
||||||
|
this.a = ta * u - tb * v;
|
||||||
|
this.b = ta * v + tb * u;
|
||||||
|
this.c = tc * u - td * v;
|
||||||
|
this.d = tc * v + td * u;
|
||||||
|
this.tx = ttx * u - tty * v;
|
||||||
|
this.ty = ttx * v + tty * u;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.invert = function () {
|
Matrix2D.prototype.invert = function () {
|
||||||
_super.prototype.invert.call(this);
|
this.$invertInto(this);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.add = function (matrix) {
|
Matrix2D.prototype.add = function (matrix) {
|
||||||
@@ -5450,6 +5498,11 @@ var es;
|
|||||||
Matrix2D.prototype.determinant = function () {
|
Matrix2D.prototype.determinant = function () {
|
||||||
return this.m11 * this.m22 - this.m12 * this.m21;
|
return this.m11 * this.m22 - this.m12 * this.m21;
|
||||||
};
|
};
|
||||||
|
Matrix2D.prototype.release = function (matrix) {
|
||||||
|
if (!matrix)
|
||||||
|
return;
|
||||||
|
es.matrixPool.push(matrix);
|
||||||
|
};
|
||||||
return Matrix2D;
|
return Matrix2D;
|
||||||
}(egret.Matrix));
|
}(egret.Matrix));
|
||||||
es.Matrix2D = Matrix2D;
|
es.Matrix2D = Matrix2D;
|
||||||
|
|||||||
2
demo/libs/framework/framework.min.js
vendored
2
demo/libs/framework/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -28,23 +28,25 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class Main extends es.Core {
|
class Main extends es.Core {
|
||||||
protected async initialize() {
|
protected initialize() {
|
||||||
await this.runGame();
|
this.runGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async runGame() {
|
private runGame() {
|
||||||
await this.loadResource();
|
this.loadResource();
|
||||||
this.createGameScene();
|
this.createGameScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async loadResource() {
|
private loadResource() {
|
||||||
try {
|
try {
|
||||||
const loadingView = new LoadingUI();
|
const loadingView = new LoadingUI();
|
||||||
this.stage.addChild(loadingView);
|
this.stage.addChild(loadingView);
|
||||||
await RES.loadConfig("resource/default.res.json", "resource/");
|
RES.loadConfig("resource/default.res.json", "resource/").then(()=>{
|
||||||
await RES.loadGroup("preload", 0, loadingView);
|
RES.loadGroup("preload", 0, loadingView).then(()=>{
|
||||||
this.stage.removeChild(loadingView);
|
this.stage.removeChild(loadingView);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|||||||
2
source/bin/framework.d.ts
vendored
2
source/bin/framework.d.ts
vendored
@@ -1165,6 +1165,7 @@ declare module es {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
|
var matrixPool: any[];
|
||||||
class Matrix2D extends egret.Matrix {
|
class Matrix2D extends egret.Matrix {
|
||||||
m11: number;
|
m11: number;
|
||||||
m12: number;
|
m12: number;
|
||||||
@@ -1183,6 +1184,7 @@ declare module es {
|
|||||||
divide(matrix: Matrix2D): Matrix2D;
|
divide(matrix: Matrix2D): Matrix2D;
|
||||||
multiply(matrix: Matrix2D): Matrix2D;
|
multiply(matrix: Matrix2D): Matrix2D;
|
||||||
determinant(): number;
|
determinant(): number;
|
||||||
|
release(matrix: Matrix2D): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
|
|||||||
@@ -1129,6 +1129,7 @@ var es;
|
|||||||
}
|
}
|
||||||
if (this._instance._scene == null) {
|
if (this._instance._scene == null) {
|
||||||
this._instance._scene = value;
|
this._instance._scene = value;
|
||||||
|
this._instance.addChild(value);
|
||||||
this._instance._scene.begin();
|
this._instance._scene.begin();
|
||||||
Core.Instance.onSceneChanged();
|
Core.Instance.onSceneChanged();
|
||||||
}
|
}
|
||||||
@@ -1161,7 +1162,6 @@ var es;
|
|||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
switch (_a.label) {
|
switch (_a.label) {
|
||||||
case 0:
|
case 0:
|
||||||
this.startDebugUpdate();
|
|
||||||
es.Time.update(egret.getTimer());
|
es.Time.update(egret.getTimer());
|
||||||
if (!this._scene) return [3, 2];
|
if (!this._scene) return [3, 2];
|
||||||
for (i = this._globalManagers.length - 1; i >= 0; i--) {
|
for (i = this._globalManagers.length - 1; i >= 0; i--) {
|
||||||
@@ -1173,17 +1173,17 @@ var es;
|
|||||||
this._scene.update();
|
this._scene.update();
|
||||||
}
|
}
|
||||||
if (!this._nextScene) return [3, 2];
|
if (!this._nextScene) return [3, 2];
|
||||||
|
this.removeChild(this._scene);
|
||||||
this._scene.end();
|
this._scene.end();
|
||||||
this._scene = this._nextScene;
|
this._scene = this._nextScene;
|
||||||
this._nextScene = null;
|
this._nextScene = null;
|
||||||
this.onSceneChanged();
|
this.onSceneChanged();
|
||||||
|
this.addChild(this._scene);
|
||||||
return [4, this._scene.begin()];
|
return [4, this._scene.begin()];
|
||||||
case 1:
|
case 1:
|
||||||
_a.sent();
|
_a.sent();
|
||||||
_a.label = 2;
|
_a.label = 2;
|
||||||
case 2:
|
case 2: return [2];
|
||||||
this.endDebugUpdate();
|
|
||||||
return [2];
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1787,9 +1787,19 @@ var es;
|
|||||||
})(DirtyType = es.DirtyType || (es.DirtyType = {}));
|
})(DirtyType = es.DirtyType || (es.DirtyType = {}));
|
||||||
var Transform = (function () {
|
var Transform = (function () {
|
||||||
function Transform(entity) {
|
function Transform(entity) {
|
||||||
|
this._localTransform = es.Matrix2D.create();
|
||||||
this._worldTransform = es.Matrix2D.create().identity();
|
this._worldTransform = es.Matrix2D.create().identity();
|
||||||
this._worldToLocalTransform = es.Matrix2D.create().identity();
|
this._worldToLocalTransform = es.Matrix2D.create().identity();
|
||||||
this._worldInverseTransform = es.Matrix2D.create().identity();
|
this._worldInverseTransform = es.Matrix2D.create().identity();
|
||||||
|
this._rotationMatrix = es.Matrix2D.create();
|
||||||
|
this._translationMatrix = es.Matrix2D.create();
|
||||||
|
this._scaleMatrix = es.Matrix2D.create();
|
||||||
|
this._position = es.Vector2.zero;
|
||||||
|
this._scale = es.Vector2.one;
|
||||||
|
this._rotation = 0;
|
||||||
|
this._localPosition = es.Vector2.zero;
|
||||||
|
this._localScale = es.Vector2.one;
|
||||||
|
this._localRotation = 0;
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.scale = es.Vector2.one;
|
this.scale = es.Vector2.one;
|
||||||
this._children = [];
|
this._children = [];
|
||||||
@@ -2111,6 +2121,10 @@ var es;
|
|||||||
})(CameraStyle = es.CameraStyle || (es.CameraStyle = {}));
|
})(CameraStyle = es.CameraStyle || (es.CameraStyle = {}));
|
||||||
var CameraInset = (function () {
|
var CameraInset = (function () {
|
||||||
function CameraInset() {
|
function CameraInset() {
|
||||||
|
this.left = 0;
|
||||||
|
this.right = 0;
|
||||||
|
this.top = 0;
|
||||||
|
this.bottom = 0;
|
||||||
}
|
}
|
||||||
return CameraInset;
|
return CameraInset;
|
||||||
}());
|
}());
|
||||||
@@ -2123,6 +2137,8 @@ var es;
|
|||||||
var _this = _super.call(this) || this;
|
var _this = _super.call(this) || this;
|
||||||
_this._minimumZoom = 0.3;
|
_this._minimumZoom = 0.3;
|
||||||
_this._maximumZoom = 3;
|
_this._maximumZoom = 3;
|
||||||
|
_this._bounds = new es.Rectangle();
|
||||||
|
_this._inset = new CameraInset();
|
||||||
_this._transformMatrix = new es.Matrix2D().identity();
|
_this._transformMatrix = new es.Matrix2D().identity();
|
||||||
_this._inverseTransformMatrix = new es.Matrix2D().identity();
|
_this._inverseTransformMatrix = new es.Matrix2D().identity();
|
||||||
_this._origin = es.Vector2.zero;
|
_this._origin = es.Vector2.zero;
|
||||||
@@ -2131,9 +2147,9 @@ var es;
|
|||||||
_this._isProjectionMatrixDirty = true;
|
_this._isProjectionMatrixDirty = true;
|
||||||
_this.followLerp = 0.1;
|
_this.followLerp = 0.1;
|
||||||
_this.deadzone = new es.Rectangle();
|
_this.deadzone = new es.Rectangle();
|
||||||
_this.focusOffset = new es.Vector2();
|
_this.focusOffset = es.Vector2.zero;
|
||||||
_this.mapLockEnabled = false;
|
_this.mapLockEnabled = false;
|
||||||
_this.mapSize = new es.Vector2();
|
_this.mapSize = es.Vector2.zero;
|
||||||
_this._desiredPositionDelta = new es.Vector2();
|
_this._desiredPositionDelta = new es.Vector2();
|
||||||
_this._worldSpaceDeadZone = new es.Rectangle();
|
_this._worldSpaceDeadZone = new es.Rectangle();
|
||||||
_this._targetEntity = targetEntity;
|
_this._targetEntity = targetEntity;
|
||||||
@@ -5317,6 +5333,7 @@ var es;
|
|||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
(function (es) {
|
(function (es) {
|
||||||
|
es.matrixPool = [];
|
||||||
var Matrix2D = (function (_super) {
|
var Matrix2D = (function (_super) {
|
||||||
__extends(Matrix2D, _super);
|
__extends(Matrix2D, _super);
|
||||||
function Matrix2D() {
|
function Matrix2D() {
|
||||||
@@ -5383,26 +5400,57 @@ var es;
|
|||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
Matrix2D.create = function () {
|
Matrix2D.create = function () {
|
||||||
return egret.Matrix.create();
|
var matrix = es.matrixPool.pop();
|
||||||
|
if (!matrix)
|
||||||
|
matrix = new Matrix2D();
|
||||||
|
return matrix;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.identity = function () {
|
Matrix2D.prototype.identity = function () {
|
||||||
_super.prototype.identity.call(this);
|
this.a = this.d = 1;
|
||||||
|
this.b = this.c = this.tx = this.ty = 0;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.translate = function (dx, dy) {
|
Matrix2D.prototype.translate = function (dx, dy) {
|
||||||
_super.prototype.translate.call(this, dx, dy);
|
this.tx += dx;
|
||||||
|
this.ty += dy;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.scale = function (sx, sy) {
|
Matrix2D.prototype.scale = function (sx, sy) {
|
||||||
_super.prototype.scale.call(this, sx, sy);
|
if (sx !== 1) {
|
||||||
|
this.a *= sx;
|
||||||
|
this.c *= sx;
|
||||||
|
this.tx *= sx;
|
||||||
|
}
|
||||||
|
if (sy !== 1) {
|
||||||
|
this.b *= sy;
|
||||||
|
this.d *= sy;
|
||||||
|
this.ty *= sy;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.rotate = function (angle) {
|
Matrix2D.prototype.rotate = function (angle) {
|
||||||
_super.prototype.rotate.call(this, angle);
|
angle = +angle;
|
||||||
|
if (angle !== 0) {
|
||||||
|
angle = angle / DEG_TO_RAD;
|
||||||
|
var u = Math.cos(angle);
|
||||||
|
var v = Math.sin(angle);
|
||||||
|
var ta = this.a;
|
||||||
|
var tb = this.b;
|
||||||
|
var tc = this.c;
|
||||||
|
var td = this.d;
|
||||||
|
var ttx = this.tx;
|
||||||
|
var tty = this.ty;
|
||||||
|
this.a = ta * u - tb * v;
|
||||||
|
this.b = ta * v + tb * u;
|
||||||
|
this.c = tc * u - td * v;
|
||||||
|
this.d = tc * v + td * u;
|
||||||
|
this.tx = ttx * u - tty * v;
|
||||||
|
this.ty = ttx * v + tty * u;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.invert = function () {
|
Matrix2D.prototype.invert = function () {
|
||||||
_super.prototype.invert.call(this);
|
this.$invertInto(this);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
Matrix2D.prototype.add = function (matrix) {
|
Matrix2D.prototype.add = function (matrix) {
|
||||||
@@ -5450,6 +5498,11 @@ var es;
|
|||||||
Matrix2D.prototype.determinant = function () {
|
Matrix2D.prototype.determinant = function () {
|
||||||
return this.m11 * this.m22 - this.m12 * this.m21;
|
return this.m11 * this.m22 - this.m12 * this.m21;
|
||||||
};
|
};
|
||||||
|
Matrix2D.prototype.release = function (matrix) {
|
||||||
|
if (!matrix)
|
||||||
|
return;
|
||||||
|
es.matrixPool.push(matrix);
|
||||||
|
};
|
||||||
return Matrix2D;
|
return Matrix2D;
|
||||||
}(egret.Matrix));
|
}(egret.Matrix));
|
||||||
es.Matrix2D = Matrix2D;
|
es.Matrix2D = Matrix2D;
|
||||||
|
|||||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -5,10 +5,10 @@ module es {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class CameraInset {
|
export class CameraInset {
|
||||||
public left: number;
|
public left: number = 0;
|
||||||
public right: number;
|
public right: number = 0;
|
||||||
public top: number;
|
public top: number = 0;
|
||||||
public bottom: number;
|
public bottom: number = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Camera extends Component {
|
export class Camera extends Component {
|
||||||
@@ -167,8 +167,8 @@ module es {
|
|||||||
public _zoom;
|
public _zoom;
|
||||||
public _minimumZoom = 0.3;
|
public _minimumZoom = 0.3;
|
||||||
public _maximumZoom = 3;
|
public _maximumZoom = 3;
|
||||||
public _bounds: Rectangle;
|
public _bounds: Rectangle = new Rectangle();
|
||||||
public _inset: CameraInset;
|
public _inset: CameraInset = new CameraInset();
|
||||||
public _transformMatrix: Matrix2D = new Matrix2D().identity();
|
public _transformMatrix: Matrix2D = new Matrix2D().identity();
|
||||||
public _inverseTransformMatrix: Matrix2D = new Matrix2D().identity();
|
public _inverseTransformMatrix: Matrix2D = new Matrix2D().identity();
|
||||||
public _origin: Vector2 = Vector2.zero;
|
public _origin: Vector2 = Vector2.zero;
|
||||||
@@ -190,7 +190,7 @@ module es {
|
|||||||
/**
|
/**
|
||||||
* 相机聚焦于屏幕中心的偏移
|
* 相机聚焦于屏幕中心的偏移
|
||||||
*/
|
*/
|
||||||
public focusOffset: Vector2 = new Vector2();
|
public focusOffset: Vector2 = Vector2.zero;
|
||||||
/**
|
/**
|
||||||
* 如果为true 相机位置则不会超出地图矩形(0, 0, mapwidth, mapheight)
|
* 如果为true 相机位置则不会超出地图矩形(0, 0, mapwidth, mapheight)
|
||||||
*/
|
*/
|
||||||
@@ -198,7 +198,7 @@ module es {
|
|||||||
/**
|
/**
|
||||||
* 當前地圖映射的寬度和高度
|
* 當前地圖映射的寬度和高度
|
||||||
*/
|
*/
|
||||||
public mapSize: Vector2 = new Vector2();
|
public mapSize: Vector2 = Vector2.zero;
|
||||||
|
|
||||||
public _targetEntity: Entity;
|
public _targetEntity: Entity;
|
||||||
public _targetCollider: Collider;
|
public _targetCollider: Collider;
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ module es {
|
|||||||
|
|
||||||
if (this._instance._scene == null) {
|
if (this._instance._scene == null) {
|
||||||
this._instance._scene = value;
|
this._instance._scene = value;
|
||||||
|
this._instance.addChild(value);
|
||||||
this._instance._scene.begin();
|
this._instance._scene.begin();
|
||||||
Core.Instance.onSceneChanged();
|
Core.Instance.onSceneChanged();
|
||||||
} else {
|
} else {
|
||||||
@@ -100,7 +101,7 @@ module es {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async update() {
|
protected async update() {
|
||||||
this.startDebugUpdate();
|
// this.startDebugUpdate();
|
||||||
|
|
||||||
// 更新我们所有的系统管理器
|
// 更新我们所有的系统管理器
|
||||||
Time.update(egret.getTimer());
|
Time.update(egret.getTimer());
|
||||||
@@ -121,17 +122,19 @@ module es {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this._nextScene) {
|
if (this._nextScene) {
|
||||||
|
this.removeChild(this._scene);
|
||||||
this._scene.end();
|
this._scene.end();
|
||||||
|
|
||||||
this._scene = this._nextScene;
|
this._scene = this._nextScene;
|
||||||
this._nextScene = null;
|
this._nextScene = null;
|
||||||
this.onSceneChanged();
|
this.onSceneChanged();
|
||||||
|
|
||||||
|
this.addChild(this._scene);
|
||||||
await this._scene.begin();
|
await this._scene.begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.endDebugUpdate();
|
// this.endDebugUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async draw() {
|
public async draw() {
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ module es {
|
|||||||
/**
|
/**
|
||||||
* 值会根据位置、旋转和比例自动重新计算
|
* 值会根据位置、旋转和比例自动重新计算
|
||||||
*/
|
*/
|
||||||
public _localTransform: Matrix2D;
|
public _localTransform: Matrix2D = Matrix2D.create();
|
||||||
/**
|
/**
|
||||||
* 值将自动从本地和父矩阵重新计算。
|
* 值将自动从本地和父矩阵重新计算。
|
||||||
*/
|
*/
|
||||||
@@ -228,17 +228,17 @@ module es {
|
|||||||
public _worldToLocalTransform = Matrix2D.create().identity();
|
public _worldToLocalTransform = Matrix2D.create().identity();
|
||||||
public _worldInverseTransform = Matrix2D.create().identity();
|
public _worldInverseTransform = Matrix2D.create().identity();
|
||||||
|
|
||||||
public _rotationMatrix: Matrix2D;
|
public _rotationMatrix: Matrix2D = Matrix2D.create();
|
||||||
public _translationMatrix: Matrix2D;
|
public _translationMatrix: Matrix2D = Matrix2D.create();
|
||||||
public _scaleMatrix: Matrix2D;
|
public _scaleMatrix: Matrix2D = Matrix2D.create();
|
||||||
|
|
||||||
public _position: Vector2;
|
public _position: Vector2 = Vector2.zero;
|
||||||
public _scale: Vector2;
|
public _scale: Vector2 = Vector2.one;
|
||||||
public _rotation: number;
|
public _rotation: number = 0;
|
||||||
|
|
||||||
public _localPosition: Vector2;
|
public _localPosition: Vector2 = Vector2.zero;
|
||||||
public _localScale: Vector2;
|
public _localScale: Vector2 = Vector2.one;
|
||||||
public _localRotation: number;
|
public _localRotation: number = 0;
|
||||||
|
|
||||||
public _children: Transform[];
|
public _children: Transform[];
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
module es {
|
module es {
|
||||||
|
export var matrixPool = [];
|
||||||
/**
|
/**
|
||||||
* 表示右手3 * 3的浮点矩阵,可以存储平移、缩放和旋转信息。
|
* 表示右手3 * 3的浮点矩阵,可以存储平移、缩放和旋转信息。
|
||||||
*/
|
*/
|
||||||
@@ -40,32 +41,66 @@ module es {
|
|||||||
this.ty = value;
|
this.ty = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从对象池中取出或创建一个新的Matrix对象。
|
||||||
|
*/
|
||||||
public static create(): Matrix2D{
|
public static create(): Matrix2D{
|
||||||
return egret.Matrix.create() as Matrix2D;
|
let matrix = matrixPool.pop();
|
||||||
|
if (!matrix)
|
||||||
|
matrix = new Matrix2D();
|
||||||
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public identity(): Matrix2D{
|
public identity(): Matrix2D{
|
||||||
super.identity();
|
this.a = this.d = 1;
|
||||||
|
this.b = this.c = this.tx = this.ty = 0;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public translate(dx: number, dy: number): Matrix2D {
|
public translate(dx: number, dy: number): Matrix2D {
|
||||||
super.translate(dx, dy);
|
this.tx += dx;
|
||||||
|
this.ty += dy;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public scale(sx: number, sy: number): Matrix2D {
|
public scale(sx: number, sy: number): Matrix2D {
|
||||||
super.scale(sx, sy);
|
if (sx !== 1){
|
||||||
|
this.a *= sx;
|
||||||
|
this.c *= sx;
|
||||||
|
this.tx *= sx;
|
||||||
|
}
|
||||||
|
if (sy !== 1){
|
||||||
|
this.b *= sy;
|
||||||
|
this.d *= sy;
|
||||||
|
this.ty *= sy;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public rotate(angle: number): Matrix2D {
|
public rotate(angle: number): Matrix2D {
|
||||||
super.rotate(angle);
|
angle = +angle;
|
||||||
|
if (angle !== 0) {
|
||||||
|
angle = angle / DEG_TO_RAD;
|
||||||
|
let u = Math.cos(angle);
|
||||||
|
let v = Math.sin(angle);
|
||||||
|
let ta = this.a;
|
||||||
|
let tb = this.b;
|
||||||
|
let tc = this.c;
|
||||||
|
let td = this.d;
|
||||||
|
let ttx = this.tx;
|
||||||
|
let tty = this.ty;
|
||||||
|
this.a = ta * u - tb * v;
|
||||||
|
this.b = ta * v + tb * u;
|
||||||
|
this.c = tc * u - td * v;
|
||||||
|
this.d = tc * v + td * u;
|
||||||
|
this.tx = ttx * u - tty * v;
|
||||||
|
this.ty = ttx * v + tty * u;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public invert(): Matrix2D {
|
public invert(): Matrix2D {
|
||||||
super.invert();
|
this.$invertInto(this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,5 +172,11 @@ module es {
|
|||||||
public determinant(){
|
public determinant(){
|
||||||
return this.m11 * this.m22 - this.m12 * this.m21;
|
return this.m11 * this.m22 - this.m12 * this.m21;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public release(matrix: Matrix2D) {
|
||||||
|
if (!matrix)
|
||||||
|
return;
|
||||||
|
matrixPool.push(matrix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user