core/timemanager
시간 매니저.
Time manager.
TimeManagerextends Object
시간 매니저.
Time manager.
import { Engine, EngineConfiguration, Scene } from "./build/vanilla.js";
class MainScene extends Scene {
tick(timeDelta) {
super.tick(timeDelta);
const engine = this.getEngine();
const timeManager = engine.getTimeManager();
const unscaledTimeDelta = timeManager.getUnscaleDeltaTime();
const time = timeManager.getTime();
if (time >= 0.5 && time - unscaledTimeDelta < 0.5) {
const framePerSecond = timeManager.getFramePerSecond();
console.log(timeDelta, unscaledTimeDelta, framePerSecond);
}
}
}
const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());
const timeManager = engine.getTimeManager();
timeManager.setTimeScale(0.5);
timeManager.setMaximumTimeDelta(0.1);생성.
Constructor.
- engineEngine
- 이 매니저를 가진 엔진. (쓰지 않는다)The engine that owns this manager. (not used)
짝Counterpart: vanilla-engine TimeManager.new
시간 계산.
Time calculation.
- timestampnumber
- requestAnimationFrame 이 넘긴 시각. (밀리초)Timestamp passed by requestAnimationFrame. (milliseconds)
짝Counterpart: vanilla-engine TimeManager.update
현재 프라우저가 시작 된 이후 시간 반환. (초 단위)
Returns the time since the current browser started. (in seconds)
반환Returnsnumber 페이지가 열린 뒤 지난 시간. (초, 마지막 update 의 시각, 처음 update 전에는 0)Time since the page opened. (seconds, the time of the last update, 0 before the first update)
짝Counterpart: vanilla-engine TimeManager.get_realtime_since_startup
현재 엔진이 시작 된 이후 시간 반환. (초 단위)
Returns the time since the current engine started. (in seconds)
반환Returnsnumber 엔진이 돈 뒤 쌓인 시간. (초, 상한으로 자른 프레임 간격을 더한 것, 시간 배율은 걸지 않는다)Time accumulated since the engine started. (seconds, the sum of frame intervals clipped to the upper limit, without the time scale)
짝Counterpart: vanilla-engine TimeManager.get_time
현재 프레임과 이전 프레임 사이의 경과 시간 반환. (초 단위)
Returns the elapsed time between the current frame and the previous frame. (in seconds)
반환Returnsnumber 시간 배율을 걸지 않은 프레임 간격. (초, 0 ~ 상한)Frame interval without the time scale. (seconds, 0 ~ upper limit)
짝Counterpart: vanilla-engine TimeManager.get_unscale_delta_time
현재 프레임과 이전 프레임 사이의 경과 시간 반환. (초 단위)
Returns the elapsed time between the current frame and the previous frame. (in seconds)
반환Returnsnumber 시간 배율을 건 프레임 간격. (초)Frame interval with the time scale applied. (seconds)
짝Counterpart: vanilla-engine TimeManager.get_time_delta
현재 초당 프레임 수 반환.
Returns the current frames per second.
반환Returnsnumber 지난 1 초 동안 센 프레임 수. (처음 1 초 동안은 0)Number of frames counted during the last second. (0 during the first second)
짝Counterpart: vanilla-engine TimeManager.get_frame_per_second
시간 배율 설정.
Sets the time scale.
- timeScalenumber
- 시간 배율. (1 이 보통, 0 이면 getTimeDelta 가 0)Time scale. (1 is normal, 0 makes getTimeDelta 0)
짝Counterpart: vanilla-engine TimeManager.set_time_scale
시간 배율 반환.
Returns the time scale.
반환Returnsnumber 시간 배율.Time scale.
짝Counterpart: vanilla-engine TimeManager.get_time_scale
한 프레임 간격의 상한 설정. (초, 기본 0.25)
- 창이 가려졌다 돌아오거나 오래 멈춘 뒤의 첫 프레임 간격을 이 값으로 자른다. 0 보다 작거나 숫자가 아니면 0.25 로 둔다.
- 물리나 흐름이 한 번에 크게 나아가면 안 되는 게임은 0.1, 0.05 처럼 줄인다.
Sets the upper limit of one frame interval. (seconds, default 0.25)
- The first frame interval after the window is hidden and comes back, or after a long pause, is clipped to this value. Less than 0 or not a number is set to 0.25.
- Games where physics or flow must not advance a lot at once reduce it, like 0.1 or 0.05.
- secondsnumber
- 한 프레임 간격의 상한. (초)Upper limit of one frame interval. (seconds)
짝Counterpart: vanilla-engine TimeManager.set_maximum_time_delta
한 프레임 간격의 상한 반환. (초)
Returns the upper limit of one frame interval. (seconds)
반환Returnsnumber 한 프레임 간격의 상한. (초)Upper limit of one frame interval. (seconds)
짝Counterpart: vanilla-engine TimeManager.get_maximum_time_delta