adjust event name and introduce event_begin_frame (#8708)

This commit is contained in:
Santy-Wang
2021-05-25 16:11:56 +08:00
committed by GitHub
parent eac556ddab
commit eb21984063
2 changed files with 12 additions and 5 deletions
+11 -4
View File
@@ -232,12 +232,19 @@ export class Director extends EventTarget {
*/
public static readonly EVENT_AFTER_PHYSICS = 'director_after_physics';
/**
* The event which will be triggered at the frame begin.<br/>
* 一帧开始时所触发的事件。
* @event Director.EVENT_BEGIN_FRAME
*/
public static readonly EVENT_BEGIN_FRAME = 'director_begin_frame';
/**
* The event which will be triggered at the frame end.<br/>
* 一帧结束之后所触发的事件。
* @event Director.EVENT_END_OF_FRAME
* @event Director.EVENT_END_FRAME
*/
public static readonly EVENT_END_OF_FRAME = 'director_end_of_frame';
public static readonly EVENT_END_FRAME = 'director_end_frame';
public static instance: Director;
@@ -881,7 +888,7 @@ export class Director extends EventTarget {
} else {
this.calculateDeltaTime(time);
}
this.emit(Director.EVENT_BEGIN_FRAME);
const dt = this._deltaTime;
// Update
@@ -914,7 +921,7 @@ export class Director extends EventTarget {
eventManager.frameUpdateListeners();
Node.clearBooks();
this.emit(Director.EVENT_END_OF_FRAME);
this.emit(Director.EVENT_END_FRAME);
this._totalFrames++;
}
}
+1 -1
View File
@@ -749,7 +749,7 @@ function hackForMultiThread () {
}
}
director.on(Director.EVENT_END_OF_FRAME, () => {
director.on(Director.EVENT_END_FRAME, () => {
if (!director.isPaused) {
lastUpdate(PhysicsSystem.instance);
}