feat: update game timescale can effect to physics fixed time
parent
f890a29fb1
commit
c3c155cad5
|
@ -336,7 +336,7 @@
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 540,
|
"x": 540,
|
||||||
"y": 1169.9999999999995,
|
"y": 1169.9999999999998,
|
||||||
"z": 0
|
"z": 0
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
|
@ -387,7 +387,7 @@
|
||||||
"_lpos": {
|
"_lpos": {
|
||||||
"__type__": "cc.Vec3",
|
"__type__": "cc.Vec3",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 2.2737367544323206e-13,
|
"y": 0,
|
||||||
"z": 1000
|
"z": 1000
|
||||||
},
|
},
|
||||||
"_lrot": {
|
"_lrot": {
|
||||||
|
@ -427,7 +427,7 @@
|
||||||
"_priority": 0,
|
"_priority": 0,
|
||||||
"_fov": 45,
|
"_fov": 45,
|
||||||
"_fovAxis": 0,
|
"_fovAxis": 0,
|
||||||
"_orthoHeight": 1169.9999999999998,
|
"_orthoHeight": 1170,
|
||||||
"_near": 0,
|
"_near": 0,
|
||||||
"_far": 2000,
|
"_far": 2000,
|
||||||
"_color": {
|
"_color": {
|
||||||
|
@ -17989,8 +17989,8 @@
|
||||||
"defaultAnimation": "stage5",
|
"defaultAnimation": "stage5",
|
||||||
"_premultipliedAlpha": true,
|
"_premultipliedAlpha": true,
|
||||||
"_timeScale": 1,
|
"_timeScale": 1,
|
||||||
"_preCacheMode": 0,
|
"_preCacheMode": 1,
|
||||||
"_cacheMode": 0,
|
"_cacheMode": 1,
|
||||||
"_sockets": [],
|
"_sockets": [],
|
||||||
"_useTint": false,
|
"_useTint": false,
|
||||||
"_debugMesh": false,
|
"_debugMesh": false,
|
||||||
|
@ -29721,9 +29721,9 @@
|
||||||
"__uuid__": "cc731501-912a-465f-9070-dbe0d8ad3598",
|
"__uuid__": "cc731501-912a-465f-9070-dbe0d8ad3598",
|
||||||
"__expectedType__": "cc.Prefab"
|
"__expectedType__": "cc.Prefab"
|
||||||
},
|
},
|
||||||
"weight": 10000,
|
"weight": 60,
|
||||||
"weightStepOnGoal": 0,
|
"weightStepOnGoal": 0,
|
||||||
"maxWeight": 10000,
|
"maxWeight": 60,
|
||||||
"maxObjects": 1
|
"maxObjects": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -34995,7 +34995,7 @@
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 1080,
|
"width": 1080,
|
||||||
"height": 2339.9999999999995
|
"height": 2340
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
Label,
|
Label,
|
||||||
Node,
|
Node,
|
||||||
NodeSpace,
|
NodeSpace,
|
||||||
|
PhysicsSystem2D,
|
||||||
Sprite,
|
Sprite,
|
||||||
Vec2,
|
Vec2,
|
||||||
Vec3,
|
Vec3,
|
||||||
|
@ -94,13 +95,16 @@ declare global {
|
||||||
|
|
||||||
//#region GAME
|
//#region GAME
|
||||||
|
|
||||||
|
const fixedTime = PhysicsSystem2D.instance.fixedTimeStep;
|
||||||
|
|
||||||
Game.prototype.timeScale = 1;
|
Game.prototype.timeScale = 1;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
game._calculateDT = function (useFixedDeltaTime: number) {
|
game._calculateDT = function (useFixedDeltaTime: boolean) {
|
||||||
|
PhysicsSystem2D.instance.fixedTimeStep = fixedTime * game.timeScale;
|
||||||
this._useFixedDeltaTime = useFixedDeltaTime;
|
this._useFixedDeltaTime = useFixedDeltaTime;
|
||||||
if (useFixedDeltaTime) {
|
if (useFixedDeltaTime) {
|
||||||
this._startTime = performance.now();
|
this._startTime = performance.now();
|
||||||
return this.frameTime / 1000;
|
return (this.frameTime / 1000) * game.timeScale;
|
||||||
}
|
}
|
||||||
const now = performance.now();
|
const now = performance.now();
|
||||||
this._deltaTime = now > this._startTime ? (now - this._startTime) / 1000 : 0;
|
this._deltaTime = now > this._startTime ? (now - this._startTime) / 1000 : 0;
|
||||||
|
|
Loading…
Reference in New Issue