game/gamescene
게임 공통 베이스 씬.
Common base scene for games.
ScreenFadeHoldextends Object
화면 페이드를 어둡게 붙잡는 손잡이. (러스트 판 ScreenFadeHold 와 같다)
- fadeScreen 의 onDark 가 돌려주거나 fadeScreenWithHold 의 onDark 가 받는다. release 를 부를 때까지 어둡게 둔다.
A hold that keeps the screen fade dark. (Same as Rust ScreenFadeHold)
- Returned by fadeScreen's onDark or received by fadeScreenWithHold's onDark. The screen stays dark until release is called.
import { ScreenFadeHold } from "./build/vanilla.js";
const screenFadeHold = new ScreenFadeHold();
console.log(screenFadeHold.isReleased());
screenFadeHold.release();
console.log(screenFadeHold.isReleased());생성. (아직 놓지 않음)
Constructor. (Not released yet)
짝Counterpart: vanilla-engine ScreenFadeHold.new
놓기. (막이 밝아진다)
Releases the hold. (The overlay brightens)
짝Counterpart: vanilla-engine ScreenFadeHold.release
놓았는지.
Whether it is released.
반환Returnsboolean release 를 불렀으면 참.True if release was called.
짝Counterpart: vanilla-engine ScreenFadeHold.is_released
GameSceneextends Scene
게임 공통 베이스 씬.
- 로딩 화면 (중앙 이미지 + 게이지 + 터치 단축). 색은 setLoadingColors, 그림 전체는 setLoadingDrawer 로 바꾼다. 게이지는 기본으로 최소 노출 시간의 경과를 보이고, setLoadingProgress 나 trackAssetLoader 로 진행률을 알리면 그 진행률을 부드럽게 따라간다. (LoadingProgress)
- 개발자 도구 (DevTools).
- 터치 입력 라우팅 (TouchRecognizer + DevTools 캡처 시 무시).
- 세이프 에어리어 노드 + env(safe-area-inset-*) 계산.
- viewSize 변화 자동 감지 → layout 재호출.
- 캔버스 배경 클리어.
- 화면 페이드 (fadeScreen, 어두운 동안 입력을 막음).
- UI 누름 판정 (isUserInterfaceAt) 과 UI 가 받지 않은 입력만 놀이로 넘기기 (setPlayInputHandler, 게임 영역 좌표). 처리기 대신 모아 두고 꺼내 쓸 수도 있다. (setPlayInputEnabled, takePlayInputs)
- 세이프 에어리어 인셋을 직접 정할 수 있다. (setSafeAreaInsets, CSS 픽셀. 정하지 않으면 뷰 매니저의 값)
- 세이프에어리어를 뺀 게임 영역의 고정 쪽 길이를 늘 같게 (setPlayAreaReference).
서브클래스 hook:
- loadAssets(): super 호출 후 자체 자산을 비동기 로드.
- layout(): super 호출 후 자체 콘텐츠 레이아웃 갱신.
Common base scene for games.
- Loading screen (center image + gauge + tap to skip). Change the colors with setLoadingColors and the whole drawing with setLoadingDrawer. By default the gauge shows the elapsed minimum display time, and once progress is reported with setLoadingProgress or trackAssetLoader it smoothly follows that progress. (LoadingProgress)
- Developer tools (DevTools).
- Touch input routing (TouchRecognizer, ignored while DevTools captures input).
- Safe area node + env(safe-area-inset-*) calculation.
- Detects viewSize changes automatically → calls layout again.
- Clears the canvas background.
- Screen fade (fadeScreen, blocks input while dark).
- UI hit test (isUserInterfaceAt) and passing only the input the UI did not take to play (setPlayInputHandler, play area coordinates). Instead of a handler, input can also be collected and taken out later. (setPlayInputEnabled, takePlayInputs)
- Safe area insets can be set directly. (setSafeAreaInsets, CSS pixels. If not set, the view manager's values)
- Keeps the fixed-side length of the play area excluding the safe area constant (setPlayAreaReference).
Subclass hooks:
- loadAssets(): after calling super, loads its own assets asynchronously.
- layout(): after calling super, updates its own content layout.
import { Engine, EngineConfiguration, GameScene, WorldNode, Text, Pivot, Vector2 } from "./build/vanilla.js";
class MainScene extends GameScene {
constructor() {
super();
this.setLoadingMinDurationMs(0);
this.setSceneBackgroundColor("#151821");
}
initialize(engine) {
super.initialize(engine);
const titleNode = new WorldNode();
titleNode.setPivot(Pivot.topLeft);
titleNode.setRect(40, 40, 600, 48);
const text = titleNode.addComponent(Text);
text.setText("Tap the play area");
text.setFontSize(32);
this.getSafeAreaNode().addChild(titleNode);
// Only presses the UI did not take arrive here, in play area coordinates.
this.setPlayInputHandler({
press: (position) => {
console.log("play press", position.x, position.y);
this.fadeScreen(() => {
text.setText("Faded at " + Math.round(position.x) + ", " + Math.round(position.y));
});
},
});
}
}
const engineConfiguration = new EngineConfiguration();
engineConfiguration.referenceResolutionSize = Vector2.create(1280, 720);
const engine = new Engine(engineConfiguration);
engine.run(new MainScene());세이프 에어리어 계산. (정적, CSS 픽셀 인셋을 뷰 배율로 나눠 뷰 영역에서 뺀다)
Calculates the safe area. (static, divides CSS pixel insets by the view scale and subtracts them from the view area)
- viewSizeVector2
- 뷰 크기. (뷰 단위)View size. (view units)
- targetResolutionScalenumber
- 뷰 배율. (인셋을 이 값으로 나눠 뷰 단위로 바꾼다, 0 이하면 1)View scale. (Insets are divided by this to convert to view units, 1 if 0 or less)
- insets{ top: number, right: number, bottom: number, left: number }
- CSS 픽셀.CSS pixels.
반환ReturnsRect 세이프 에어리어 영역. (뷰 좌표, 너비와 높이는 0 이상)Safe area rectangle. (view coordinates, width and height are 0 or more)
짝Counterpart: vanilla-engine GameSceneBase.calculate_safe_area_rect
static calculatePlayAreaReferenceLength(fixedLength, isLandscape, canvasNativeSize, safeAreaInsets, insetScale)#게임 영역 기준의 기준 해상도 길이 셈. (못 셈하면 0)
Computes the reference resolution length for the play area reference. (0 if it cannot be computed)
- fixedLengthnumber
- 세이프에어리어를 뺀 게임 영역의 고정 쪽 길이. (기준 해상도 단위)Fixed-side length of the play area excluding the safe area insets. (reference resolution units)
- isLandscapeboolean
- 참이면 가로, 거짓이면 세로가 고정 쪽.If true the width is the fixed side, if false the height.
- canvasNativeSizeVector2
- 캔버스 요소의 크기. (CSS 픽셀)Size of the canvas element. (CSS pixels)
- safeAreaInsetsobject
- { top, right, bottom, left } (뷰 좌표){ top, right, bottom, left } (view coordinates)
- insetScalenumber
- 뷰 좌표 → 캔버스 단위 배율.Scale from view coordinates → canvas units.
반환Returnsnumber 기준 해상도의 고정 쪽 길이. (못 셈하면 0)Fixed-side length of the reference resolution. (0 if it cannot be computed)
짝Counterpart: vanilla-engine GameSceneBase.calculate_play_area_reference_length
ViewScaleMode 설정. 프로젝트별로 자유롭게 지정 가능.
- 디폴트는 ViewScaleMode.none. 엔진 기동 전 / 후 어디서든 호출 가능.
- 호출 시점에 엔진이 이미 attach 되어 있으면 즉시 viewManager 에 반영하고, 아니면 initialize() 에서 일괄 적용된다.
Sets the ViewScaleMode. Can be set freely per project.
- Default is ViewScaleMode.none. Can be called anywhere before / after engine startup.
- If the engine is already attached at call time, it is applied to viewManager immediately, otherwise it is applied all at once in initialize().
- viewScaleModestring
- 뷰 배율 모드. (ViewScaleMode 의 값, 기본 ViewScaleMode.none)View scale mode. (a ViewScaleMode value, default ViewScaleMode.none)
짝Counterpart: vanilla-engine GameSceneBase.set_view_scale_mode
현재 ViewScaleMode 반환.
Returns the current ViewScaleMode.
반환Returnsstring 지금 뷰 배율 모드. (ViewScaleMode 의 값)The current view scale mode. (a ViewScaleMode value)
짝Counterpart: vanilla-engine GameSceneBase.get_view_scale_mode
로딩 화면 중앙 이미지 URL 설정. (빈 문자열이면 이미지 없이 게이지만 노출)
Sets the loading screen center image URL. (shows only the gauge without an image if empty string)
- urlstring
- 로딩 화면 가운데에 그릴 그림 주소. (빈 글이면 그림 없이 게이지만 그린다)URL of the image drawn at the center of the loading screen. (If empty, only the gauge is drawn without an image)
짝Counterpart: vanilla-engine GameSceneBase.set_loading_image_url
로딩 화면 최소 노출 시간 (ms) 설정.
Sets the loading screen minimum display time (ms).
- millisecondsnumber
- 로딩 화면을 보여 줄 가장 짧은 시간. (밀리초, 기본 3000, 화면을 누르면 바로 넘긴다)Minimum time to show the loading screen. (milliseconds, default 3000, skipped at once when the screen is pressed)
짝Counterpart: vanilla-engine GameSceneBase.set_loading_min_duration_ms
로딩 화면 그리기 함수 설정. (null 이면 기본 그림: 가운데 로딩 이미지 + 아래 게이지)
- 엔진이 캔버스를 바깥 색으로, 뷰를 바탕색으로 칠하고 뷰 좌표계를 건 뒤 drawer(graphic, viewSize, progress, elapsedSeconds) 를 부른다. progress 는 보이는 진행률(0 ~ 1, 알린 것이 없으면 최소 노출 시간의 경과), elapsedSeconds 는 로딩을 시작한 뒤의 초다.
- 그림과 글꼴을 받기 전에도 그려지므로 도형과 시스템 글꼴로 그린다.
Sets the loading screen drawing function. (null for the default drawing: loading image at the center + gauge below)
- The engine fills the canvas with the outside color and the view with the background color, applies the view coordinate system, then calls drawer(graphic, viewSize, progress, elapsedSeconds). progress is the displayed progress (0 ~ 1, the elapsed minimum display time if nothing was reported), and elapsedSeconds is the seconds since loading started.
- It is drawn even before images and fonts are loaded, so draw with shapes and system fonts.
- drawer((graphic: Graphic, viewSize: Vector2, progress: number, elapsedSeconds: number) => void) | null
- 로딩 화면 그리기 함수. (graphic, viewSize, progress, elapsedSeconds 를 받는다, null 이면 기본 그림)Loading screen drawing function. (Receives graphic, viewSize, progress, elapsedSeconds, null for the default drawing)
짝Counterpart: vanilla-engine GameSceneBase.set_loading_drawer
로딩 화면 그리기 함수 반환. (없으면 null)
Returns the loading screen drawing function. (null if none)
반환ReturnsFunction | null 로딩 화면 그리기 함수. (정하지 않았으면 null)Loading screen drawing function. (null if not set)
짝Counterpart: vanilla-engine GameSceneBase.get_loading_drawer
setLoadingColors(backgroundColor, barBackColor, barFillColor, outsideColor = backgroundColor)#로딩 화면 색 설정. (Color 나 "#rrggbb" 같은 색 글, 기본은 검은 바탕, #333333 게이지 바탕, #ffffff 게이지)
- outsideColor 는 뷰 바깥(캔버스 나머지)의 색이다. 주지 않으면 바탕색과 같다.
Sets the loading screen colors. (A Color or color text such as "#rrggbb", defaults are a black background, #333333 gauge background, #ffffff gauge)
- outsideColor is the color outside the view (the rest of the canvas). If omitted, it is the same as the background color.
- backgroundColorColor | string
- 뷰 바탕색. (Color 나 색 글, 기본 검정)View background color. (A Color or color text, default black)
- barBackColorColor | string
- 게이지 바탕색. (기본 #333333)Gauge background color. (default #333333)
- barFillColorColor | string
- 게이지 채움 색. (기본 #ffffff)Gauge fill color. (default #ffffff)
- outsideColorColor | string
- 뷰 바깥(캔버스 나머지)의 색. (주지 않으면 바탕색)Color outside the view (the rest of the canvas). (The background color if omitted)
짝Counterpart: vanilla-engine GameSceneBase.set_loading_colors
로딩 화면 뷰 바깥(캔버스 나머지)의 색 설정. (setLoadingColors 의 넷째 값만 바꾼다)
Sets the loading screen color outside the view (the rest of the canvas). (Changes only the fourth value of setLoadingColors)
- outsideColorColor | string
- 뷰 바깥(캔버스 나머지)의 색. (Color 나 색 글)Color outside the view (the rest of the canvas). (A Color or color text)
짝Counterpart: vanilla-engine GameSceneBase.set_loading_outside_color
로딩 화면 그리기 함수가 있는지.
Whether a loading screen drawing function is set.
반환Returnsboolean 로딩 화면 그리기 함수를 정했으면 참.True if a loading screen drawing function is set.
짝Counterpart: vanilla-engine GameSceneBase.has_loading_drawer
로딩 화면을 눌러 건너뛰었는지.
Whether the loading screen was tapped to skip.
반환Returnsboolean 로딩 화면을 눌러 최소 노출 시간을 건너뛰었으면 참.True if the loading screen was tapped to skip the minimum display time.
짝Counterpart: vanilla-engine GameSceneBase.is_load_touched_to_skip
개발자 도구 반환. (initialize 전이거나 EngineConfiguration.useDevTools 가 꺼져 있으면 null)
Returns the developer tools. (null before initialize or when EngineConfiguration.useDevTools is off)
반환ReturnsDevTools | null 개발자 도구. (initialize 전이거나 EngineConfiguration.useDevTools 가 꺼져 있으면 null)Developer tools. (null before initialize or when EngineConfiguration.useDevTools is off)
짝Counterpart: vanilla-engine GameSceneBase.get_dev_tools
세이프 에어리어 인셋 직접 설정. (CSS 픽셀 { top, right, bottom, left }, null 이면 뷰 매니저의 getSafeAreaInsets 를 읽는다)
Sets the safe area insets directly. (CSS pixels { top, right, bottom, left }, if null reads the view manager's getSafeAreaInsets)
- insets{ top: number, right: number, bottom: number, left: number } | null
- 위, 오른쪽, 아래, 왼쪽 인셋. (CSS 픽셀, null 이면 뷰 매니저의 getSafeAreaInsets 를 읽는다)Top, right, bottom, left insets. (CSS pixels, if null reads the view manager's getSafeAreaInsets)
짝Counterpart: vanilla-engine GameSceneBase.set_safe_area_insets
로딩 진행률 알리기. (0 ~ 1, 줄어들지 않는다. 알린 뒤로 게이지가 경과 시간 대신 이 값을 따라간다)
Reports loading progress. (0 ~ 1, never decreases. After reporting, the gauge follows this value instead of the elapsed time)
- progressnumber
- 알릴 진행률. (0 ~ 1, 앞서 알린 것보다 작아지지 않는다)Progress to report. (0 ~ 1, never less than what was reported before)
짝Counterpart: vanilla-engine GameSceneBase.set_loading_progress
로딩 진행률 반환. (알린 정도와 부드럽게 따라가는 보이는 정도)
Returns the loading progress. (The reported amount and the displayed amount that smoothly follows it)
반환ReturnsLoadingProgress 로딩 진행률. (알린 정도와 부드럽게 따라가는 보이는 정도)Loading progress. (The reported amount and the displayed amount that smoothly follows it)
짝Counterpart: vanilla-engine GameSceneBase.get_loading_progress
애셋 함께 받기 맡기기. (로딩 화면이 프레임마다 맡긴 것들의 끝난 수 / 전체 수를 진행률로 알린다)
Hands over an asset loader. (Every frame the loading screen reports the finished count / total count of what was handed over as progress)
- assetLoaderAssetLoader
- 로딩 화면이 진행률을 따라갈 애셋 함께 받기.The asset loader whose progress the loading screen follows.
짝Counterpart: vanilla-engine GameSceneBase.track_asset_loader
맡긴 애셋 함께 받기의 진행률을 알린다. (맡긴 것이 없으면 아무것도 하지 않는다)
Reports the progress of the handed-over asset loaders. (Does nothing if none were handed over)
세이프 에어리어 노드 반환. (서브클래스가 자식 콘텐츠를 여기에 붙인다)
Returns the safe area node. (Subclasses attach child content here)
반환ReturnsWorldNode 세이프 에어리어 노드. (서브클래스의 콘텐츠를 여기에 붙인다)Safe area node. (Attach the subclass's content here)
마지막으로 계산된 세이프 에어리어 영역 반환.
Returns the last calculated safe area rect.
반환ReturnsRect 마지막으로 계산한 세이프 에어리어 영역. (뷰 좌표)The last calculated safe area rect. (view coordinates)
짝Counterpart: vanilla-engine GameSceneBase.get_safe_area_rect
비동기 로드.
- loadAssets() hook 호출 + 최소 노출 시간 보장.
- 시간은 엔진 시계(TimeManager.getRealtimeSinceStartup)로 잰다. 엔진 시계가 아직 돌지 않았으면(첫 프레임 전, 0) 첫 로딩 화면 프레임의 시각부터 잰다.
- 화면을 누르면 바로 단축한다. 누름은 엔진 입력(InputManager.isTouchPressed)으로 drawOnLoad 가 프레임마다 본다. (러스트 판과 같은 시계, 같은 입력)
Asynchronous load.
- Calls the loadAssets() hook + guarantees the minimum display time.
- Time is measured with the engine clock (TimeManager.getRealtimeSinceStartup). If the engine clock has not started yet (before the first frame, 0), it is measured from the time of the first loading screen frame.
- Tapping the screen skips right away. drawOnLoad checks the tap every frame through engine input (InputManager.isTouchPressed). (Same clock and same input as the Rust edition)
- engineEngine
- 씬을 불러오는 엔진.The engine loading the scene.
짝Counterpart: vanilla-engine GameSceneBase.load
자산 로드 hook.
- 서브클래스가 오버라이드해서 자체 자산을 비동기 로드한다. super 호출 필수.
Asset loading hook.
- Subclasses override it to load their own assets asynchronously. Calling super is required.
짝Counterpart: vanilla-engine GameSceneBase.load_assets
로딩 화면 출력. (엔진이 isLoaded() === false 인 동안 매 프레임 호출)
- 바깥 색 캔버스 + 바탕색 뷰 + (그리기 함수, 없으면 중앙 로딩 이미지 + 하단 게이지).
Draws the loading screen. (The engine calls it every frame while isLoaded() === false)
- Outside-color canvas + background-color view + (the drawing function, or if none, the center loading image + bottom gauge).
- graphicGraphic
- 그릴 그래픽.Graphic to draw with.
짝Counterpart: vanilla-engine GameSceneBase.draw_on_load
초기화.
Initialization.
- engineEngine
- 씬을 불러온 엔진.The engine that loaded the scene.
짝Counterpart: vanilla-engine GameSceneBase.initialize
화면 크기 변경됨.
Screen size changed.
- canvasNativeSizeVector2
- 바뀐 캔버스 요소의 크기. (CSS 픽셀)New size of the canvas element. (CSS pixels)
짝Counterpart: vanilla-engine GameSceneBase.resize
레이아웃.
- 서브클래스는 super.layout() 호출 후 자체 콘텐츠 레이아웃을 갱신한다.
Layout.
- Subclasses call super.layout() and then update their own content layout.
짝Counterpart: vanilla-engine GameSceneBase.layout
세이프 에어리어 계산. (뷰 좌표계 기준)
Calculates the safe area. (in the view coordinate system)
반환ReturnsRect 세이프 에어리어 영역. (뷰 좌표, 너비와 높이는 0 이상)Safe area rectangle. (view coordinates, width and height are 0 or more)
짝Counterpart: vanilla-engine GameSceneBase.compute_safe_area_rect
갱신.
- viewSize 변화 감지 → 자동 layout 재호출. (모바일 주소창 표시/숨김으로 100vh 가 동적으로 변하는 경우 등에서 resize 이벤트만으로는 누락될 수 있어 매 tick 보정.)
- DevTools tick 처리.
Update.
- Detects viewSize changes → calls layout again automatically. (Corrected every tick because the resize event alone can miss changes, such as when 100vh changes dynamically as the mobile address bar shows or hides.)
- Handles the DevTools tick.
- timeDeltanumber
- 지난 프레임부터의 시간. (초)Time since the last frame. (Seconds)
짝Counterpart: vanilla-engine GameSceneBase.tick
디브툴이 입력을 가져가는 중인지 여부.
Whether DevTools is taking the input.
반환Returnsboolean 개발자 도구 패널이 보이고 포인터가 그 위에 있으면 참.True if the developer tools panel is visible and the pointer is over it.
짝Counterpart: vanilla-engine GameSceneBase.is_dev_tools_capturing_input
터치 레이캐스터 반환. (터치 훅에서 노드로 넘기는 TouchRecognizer, 씬 기본 넘기기는 끄고 이것으로 넘긴다)
Returns the touch raycaster. (the TouchRecognizer that the touch hooks pass to nodes; the scene's default passing is turned off and this one is used)
반환ReturnsTouchRecognizer 터치 훅이 넘기는 TouchRecognizer. (initialize 전에는 undefined)The TouchRecognizer that the touch hooks pass to. (undefined before initialize)
touchPress.
- viewInputPositionVector2
- 누른 자리. (뷰 좌표)Press position. (view coordinates)
짝Counterpart: vanilla-engine GameScene.touch_press
touchMove.
- viewInputPositionVector2
- 옮긴 자리. (뷰 좌표)Moved position. (view coordinates)
짝Counterpart: vanilla-engine GameScene.touch_move
touchRelease.
- viewInputPositionVector2
- 뗀 자리. (뷰 좌표)Release position. (view coordinates)
짝Counterpart: vanilla-engine GameScene.touch_release
touchCancel.
- viewInputPositionVector2
- 취소된 때의 자리. (뷰 좌표)Position at cancel. (view coordinates)
짝Counterpart: vanilla-engine GameScene.touch_cancel
touchWheel. (그 자리의 가장 앞 스크롤 칸에 넘긴다, 받은 칸이 있으면 true)
- 덮어쓴 게임 씬은 super.touchWheel 이 false 일 때만 게임(지도 확대 등)으로 넘기면 창의 스크롤과 겹치지 않는다.
touchWheel. (Passes it to the frontmost scroll view at that position, true if a view took it)
- An overriding game scene that passes the wheel to the game (map zoom and so on) only when super.touchWheel is false does not overlap with window scrolling.
- viewInputPositionVector2
- 휠을 굴린 자리. (뷰 좌표)Position where the wheel was rolled. (view coordinates)
- wheelDeltaVector2
- 이번 프레임에 쌓인 휠 양. (WheelEvent 의 deltaX, deltaY)Wheel amount accumulated this frame. (deltaX, deltaY of WheelEvent)
반환Returnsboolean 그 자리의 스크롤 칸이 휠을 받았으면 참.True if a scroll view at that position took the wheel.
짝Counterpart: vanilla-engine GameScene.touch_wheel
preDraw. 캔버스 전체를 sceneBackgroundColor 로 칠한다 (세이프 에어리어 바깥 영역 포함).
preDraw. Fills the whole canvas with sceneBackgroundColor (including the area outside the safe area).
- graphicGraphic
- 그릴 그래픽.Graphic to draw with.
짝Counterpart: vanilla-engine GameSceneBase.pre_draw
postDraw. 어두워지는 막과 DevTools 를 화면 위에 그린다.
postDraw. Draws the fade overlay and DevTools on top of the screen.
- graphicGraphic
- 그릴 그래픽.Graphic to draw with.
짝Counterpart: vanilla-engine GameSceneBase.post_draw
어두워졌다 밝아지기.
- 다 어두워지면 onDark 를 부르고, 그것이 Promise 를 돌려주면 끝날 때까지(실패해도), ScreenFadeHold 를 돌려주면 release 할 때까지 어둡게 두었다가 밝힌다.
- 막이 걸린 동안(어두워지고, 기다리고, 밝아지는 동안)은 누름과 휠을 받지 않는다.
- 이미 페이드 중이면 무시하고 false.
Fades to dark and back.
- When fully dark, calls onDark. If it returns a Promise, the screen stays dark until it settles (even on failure), and if it returns a ScreenFadeHold, until the hold is released. Then it brightens.
- While the overlay is up (darkening, waiting, brightening), presses and wheel input are not received.
- If already fading, the call is ignored and returns false.
- onDarkFunction | null
- () => void | Promise | ScreenFadeHold
반환Returnsboolean 시작했는지.Whether it started.
짝Counterpart: vanilla-engine GameSceneBase.fade_screen
어두워졌다 밝아지기의 손잡이 꼴. (러스트 판 fade_screen_with_hold 와 같다)
- 다 어두워지면 onDark 에 새 ScreenFadeHold 를 넘기고, 그 손잡이를 release 할 때까지 어둡게 둔다.
- 이미 페이드 중이면 무시하고 false.
The hold form of fading to dark and back. (Same as Rust fade_screen_with_hold)
- When fully dark, passes a new ScreenFadeHold to onDark and stays dark until that hold is released.
- If already fading, the call is ignored and returns false.
- onDarkfunction(ScreenFadeHold): void
- 다 어두워지면 손잡이를 받아 부를 함수.Function called with the hold when the screen is fully dark.
반환Returnsboolean 시작했는지.Whether it started.
짝Counterpart: vanilla-engine GameSceneBase.fade_screen_with_hold
페이드 중인지. (어두워지거나, onDark 를 기다리거나, 밝아지는 중)
Whether a fade is in progress. (darkening, waiting for onDark, or brightening)
반환Returnsboolean 어두워지거나, onDark 를 기다리거나, 밝아지는 중이면 참.True while darkening, waiting for onDark, or brightening.
짝Counterpart: vanilla-engine GameSceneBase.is_screen_fading
어두워지는 막의 색 설정. (기본 검정)
Sets the color of the fade overlay. (default black)
- colorColor | string
- 어두워지는 막의 색. (Color 나 색 글, 기본 검정)Color of the fade overlay. (A Color or color text, default black)
짝Counterpart: vanilla-engine GameSceneBase.set_screen_fade_color
어두워지는 시간과 밝아지는 시간 설정. (초, 기본 0.35, 0 이면 바로)
Sets the time to darken and to brighten. (seconds, default 0.35, immediate if 0)
- secondsnumber
- 어두워지는 시간이자 밝아지는 시간. (초, 기본 0.35, 0 이면 바로)Time to darken, and also to brighten. (seconds, default 0.35, immediate if 0)
짝Counterpart: vanilla-engine GameSceneBase.set_screen_fade_seconds
어두워지는 막의 진하기. (0 ~ 1)
Opacity of the fade overlay. (0 ~ 1)
반환Returnsnumber 어두워지는 막의 진하기. (0 ~ 1)Opacity of the fade overlay. (0 ~ 1)
짝Counterpart: vanilla-engine GameSceneBase.get_screen_fade_alpha
막 갱신. (tick 이 부른다, 배율을 곱하지 않은 시간으로 움직여 놀이를 멈춰도 돈다, 한 프레임은 0.1 초까지)
Updates the overlay. (Called by tick, advances with unscaled time so it runs even when play is paused, up to 0.1 seconds per frame)
어두워지는 막 그리기. (세이프에어리어까지 캔버스 전체를 덮는다)
Draws the fade overlay. (Covers the whole canvas including the safe area insets)
- graphicGraphic
- 그릴 그래픽.Graphic to draw with.
짝Counterpart: vanilla-engine GameSceneBase.draw_screen_fade
그 자리에 UI(누를 수 있는 노드: 단추, 창의 어둠과 판, 스크롤 칸)가 있는지. (뷰 좌표)
Whether there is UI (a pressable node: a button, a window's dimmer and panel, a scroll view) at that position. (view coordinates)
- viewPositionVector2
- 볼 자리. (뷰 좌표)Position to test. (View coordinates)
반환Returnsboolean 그 자리에 누를 수 있는 UI 노드가 있으면 참.True if there is a pressable UI node at that position.
짝Counterpart: vanilla-engine GameSceneBase.is_user_interface_at
놀이 입력 처리기 설정. (UI 가 받지 않은 누름과 그 누름의 이동, 뗌(취소 포함), UI 밖의 휠을 게임 영역 좌표로 넘긴다, null 이면 넘기지 않는다)
- 게임 영역은 세이프에어리어 영역(getSafeAreaRect)이다. 좌표는 그 왼쪽 위가 0, 0 이다.
- 페이드 중에는 누름과 휠을 넘기지 않는다. 개발자 도구가 입력을 가져가면 넘기지 않는다.
Sets the play input handler. (Passes presses the UI did not take, their moves and releases (including cancel), and the wheel outside the UI in play area coordinates, null to pass nothing)
- The play area is the safe area rect (getSafeAreaRect). Its top left is 0, 0.
- Presses and the wheel are not passed during a fade. Nothing is passed while the developer tools capture input.
- playInputHandlerobject | null
- { press?(position), move?(position), release?(position), wheel?(position, wheelDelta) }
짝Counterpart: vanilla-engine GameSceneBase.set_play_input_handler
놀이 입력 모으기 켜기. (처리기 대신 모아 두었다가 takePlayInputs 로 꺼낸다, 끄면 모은 것을 버린다)
Turns on play input collection. (Collects input instead of a handler, to be taken out with takePlayInputs, turning it off discards what was collected)
- isPlayInputEnabledboolean
- 참이면 놀이 입력을 모은다. (거짓이면 모은 것을 버린다)If true, collects play input. (If false, discards what was collected)
짝Counterpart: vanilla-engine GameSceneBase.set_play_input_enabled
모은 놀이 입력 꺼내기. (온 차례대로 { kind, position, wheelDelta }, 꺼내면 비운다)
Takes the collected play input. ({ kind, position, wheelDelta } in arrival order, taking empties it)
반환ReturnsArray<{ kind: string, position: Vector2, wheelDelta: Vector2 | null }> 모은 놀이 입력. (온 차례대로, kind 는 press, move, release, wheel, 꺼내면 비운다)Collected play input. (In arrival order, kind is press, move, release, wheel, taking empties it)
짝Counterpart: vanilla-engine GameSceneBase.take_play_inputs
뷰 좌표 → 게임 영역 좌표. (세이프에어리어 왼쪽 위가 0, 0)
View coordinates → play area coordinates. (The safe area's top left is 0, 0)
- viewPositionVector2
- 바꿀 자리. (뷰 좌표)Position to convert. (view coordinates)
반환ReturnsVector2 게임 영역 좌표. (세이프에어리어 왼쪽 위가 0, 0)Play area coordinates. (The safe area's top left is 0, 0)
짝Counterpart: vanilla-engine GameSceneBase.convert_view_to_play_area
놀이 입력 넘기기. (kind 는 press, move, release, wheel, 처리기에 그 함수가 없으면 넘기지 않는다)
Dispatches play input. (kind is press, move, release, wheel, not passed if the handler lacks that function)
- kindstring
- 입력 종류. (press, move, release, wheel)Input kind. (press, move, release, wheel)
- viewPositionVector2
- 입력 자리. (뷰 좌표)Input position. (view coordinates)
- wheelDeltaVector2 | null
- 휠 양. (wheel 이 아니면 null)Wheel amount. (null unless wheel)
놀이로 간 누름 끝내기. (뗌과 취소)
Ends a press that went to play. (release and cancel)
- viewPositionVector2
- 뗀 자리. (뷰 좌표)Release position. (view coordinates)
게임 영역 기준 설정. (세이프에어리어를 뺀 게임 영역의 고정 쪽 길이가 늘 fixedLength 가 되게 기준 해상도를 늘린다)
- 엔진은 캔버스 전체의 길이를 기준 해상도에 맞추는데 캔버스는 세이프에어리어까지 덮는다. 그만큼 기준 해상도를 늘린다. (캔버스 길이 : 세이프에어리어를 뺀 길이 = 기준 해상도 길이 : fixedLength)
- isLandscape 면 가로, 아니면 세로가 고정 쪽이다. 뷰 배율 방식도 그에 맞춰 둔다. (가로 고정 stretchWidthExpandHeight, 세로 고정 stretchHeightExpandWidth)
- 무시할 세이프에어리어 쪽은 ViewManager.setIgnoredSafeAreaSides 로 넘긴다. fixedLength 가 0 이면 끈다. (기준 해상도는 그대로 둔다)
Sets the play area reference. (Enlarges the reference resolution so the fixed-side length of the play area excluding the safe area insets is always fixedLength)
- The engine fits the whole canvas length to the reference resolution, but the canvas also covers the safe area insets. The reference resolution is enlarged by that much. (canvas length : length excluding the safe area insets = reference resolution length : fixedLength)
- If isLandscape the width is the fixed side, otherwise the height. The view scale mode is set to match. (width fixed stretchWidthExpandHeight, height fixed stretchHeightExpandWidth)
- Pass the safe area sides to ignore with ViewManager.setIgnoredSafeAreaSides. A fixedLength of 0 turns it off. (The reference resolution is left as is)
- fixedLengthnumber
- 세이프에어리어를 뺀 게임 영역의 고정 쪽 길이. (기준 해상도 단위, 0 이면 끈다)Fixed-side length of the play area excluding the safe area insets. (reference resolution units, 0 turns it off)
- isLandscapeboolean
- 참이면 가로, 거짓이면 세로가 고정 쪽.If true the width is the fixed side, if false the height.
짝Counterpart: vanilla-engine GameSceneBase.set_play_area_reference
게임 영역의 고정 쪽 길이. (0 이면 쓰지 않음)
Fixed-side length of the play area. (0 if not used)
반환Returnsnumber 게임 영역의 고정 쪽 길이. (0 이면 쓰지 않음)Fixed-side length of the play area. (0 if not used)
짝Counterpart: vanilla-engine GameSceneBase.get_play_area_fixed_length
게임 영역 기준을 기준 해상도에 걸기. (캔버스와 인셋 크기에서만 셈해 몇 번을 불러도 같다, 같으면 건드리지 않는다)
Applies the play area reference to the reference resolution. (Computed only from the canvas and inset sizes, so repeated calls give the same result, left untouched if unchanged)
짝Counterpart: vanilla-engine GameSceneBase.apply_play_area_reference