mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
adjust event name and introduce event_begin_frame (#8708)
This commit is contained in:
+11
-4
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user