diff --git a/example/main.ts b/example/main.ts index 17af1a4..83f6be8 100644 --- a/example/main.ts +++ b/example/main.ts @@ -23,11 +23,17 @@ class GameApp extends Node { } start() { this.fps.fontSize = 40; - this.size.set(200, 50); + this.size.set(300, 50); console.log('start'); } + + lastTime = 0; update(time: number): void { - this.fps.value = (1000 / time).toFixed(2) + ' fps(帧)'; + this.lastTime += time; + if (this.lastTime >= 100) { + this.fps.value = (1000 / time).toFixed(2) + ''; + this.lastTime -= 100; + } } } diff --git a/package.json b/package.json index d304ed7..62dd1f6 100644 --- a/package.json +++ b/package.json @@ -62,4 +62,4 @@ "@tweenjs/tween.js": "^18.6.4", "eventemitter3": "^5.0.0" } -} +} \ No newline at end of file diff --git a/src/core/transform/Transform.ts b/src/core/transform/Transform.ts index 32935c8..a7d127f 100644 --- a/src/core/transform/Transform.ts +++ b/src/core/transform/Transform.ts @@ -38,6 +38,16 @@ export class Transform { * 当添加到显示舞台时 */ ADDED: 'ADDED', + /** + * 当被移除于舞台时 + */ + REMOVED: 'REMOVED', + + /** + * 可见元素发生变化时(需要渲染的元素) + */ + CHANGE_DISPLY: 'CHANGE_DISPLY', + /** * 当添加新的字节点时 */ @@ -67,7 +77,7 @@ export class Transform { * @param classConstructor */ constructor(classConstructor?: Constructor) { - this.id = ++ id; + this.id = ++id; if (classConstructor) { this.container = this.addComponent(classConstructor); } @@ -123,7 +133,7 @@ export class Transform { set height(val: number) { this.size.y = val; } - + private _scale: Vector2 = new Vector2(1, 1); @@ -143,14 +153,14 @@ export class Transform { set scaleX(val: number) { this.scale.x = val; } - + get scaleY() { return this.scale.y; } set scaleY(val: number) { this.scale.y = val; } - + _rotation: number = 0;//Vector2 = new Vector2(0, 1); /** * 旋转 @@ -172,7 +182,7 @@ export class Transform { set anchor(value: Vector2) { this._anchor = value; } - + get anchorX() { return this.anchor.x; } @@ -296,7 +306,7 @@ export class Transform { return list; } - + /** * 子节点 */