You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
607 B
26 lines
607 B
|
1 week ago
|
import { Director, director, js } from "cc";
|
||
|
|
|
||
|
|
/** 全局游戏时间缩放 */
|
||
|
|
//@ts-ignore
|
||
|
|
if (!Director.prototype["__$cc-director-speed-extension$__"]) {
|
||
|
|
//@ts-ignore
|
||
|
|
Director.prototype["__$cc-director-speed-extension$__"] = true;
|
||
|
|
|
||
|
|
let oldTick = director.tick.bind(director);
|
||
|
|
director.tick = function (dt) {
|
||
|
|
dt *= director.globalGameTimeScale;
|
||
|
|
oldTick(dt);
|
||
|
|
};
|
||
|
|
|
||
|
|
js.mixin(Director.prototype, {
|
||
|
|
globalGameTimeScale: 1,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
declare module "cc" {
|
||
|
|
interface Director {
|
||
|
|
globalGameTimeScale: number;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// director.globalGameTimeScale = 0.5;
|