vanilladocs
vanillapunch.com
API / ui/uiscene

ui/uiscene

UI 씬. (원본 ui/uiscene.js 의 UIScene)

  • GameScene 과 같은 공통 틀(개발자 도구, 터치 라우팅, 로딩 화면, 세이프 에어리어 인셋, 뷰 크기 변화 감지, 캔버스 배경 칠하기)을 가진 씬이다.
  • 제 LayoutSolver 를 들고 tick 마다 트리의 UINode 에 솔버를 붙이고(attach_pending_in_tree) 한 번 푼 뒤 노드에 옮긴다.
  • 화면 가이드 UINode(screen_node): 왼쪽 위 (0, 0) 고정, 너비와 높이는 편집 변수라 크기가 바뀔 때 suggest_value 로 고친다. (UIKit 의 UIWindow.bounds)
  • 세이프 에어리어 가이드 UINode(safe_area_layout_guide): 화면 가이드에서 세이프 에어리어 인셋만큼 안쪽. 레이아웃 때 인셋을 스스로 맞춘다. (UIKit 의 UIView.safeAreaLayoutGuide)
  • 러스트 판은 상속 대신 씬이 UISceneBase 를 품고 UIScene 트레이트를 구현한 뒤 ui_scene! 한 줄로 Scene 을 얻는다. (GameScene, game_scene! 과 같은 꼴)
struct MenuScene { ui_scene_base: UISceneBase }
impl UIScene for MenuScene {
    fn get_ui_scene_base(&self) -> &UISceneBase { &self.ui_scene_base }
    fn get_ui_scene_base_mut(&mut self) -> &mut UISceneBase { &mut self.ui_scene_base }
    fn initialize(&mut self, engine: &Engine) { /* UINode 를 붙인 노드를 만들고 get_safe_area_layout_guide 의 앵커로 제약을 건다 */ }
}
vanilla::ui_scene!(MenuScene);
  • 원본과 다른 것:
  • 원본은 Scene 을 바로 상속해 GameScene 과 같은 코드를 따로 든다. 러스트 판은 공통 틀을 GameSceneBase 로 품고(세이프 에어리어 노드는 만들지 않는다) 솔버와 두 가이드만 더한다. 그래서 GameSceneBase 의 화면 페이드와 놀이 입력도 쓸 수 있다. (원본 UIScene 에는 없다)
  • 원본은 create 에서 솔버와 가이드를 만든다. 러스트 판은 엔진이 필요 없어 생성할 때 만든다. 원본 load 끝의 "뷰 크기를 솔버에 바로 반영"은 initialize 에서 한다.
  • 세이프 에어리어 인셋은 { top, left, bottom, right } 객체 대신 LayoutMargins 다. 솔버 오류는 Result<(), LayoutError> 로 돌려준다.

UI scene. (UIScene of the original ui/uiscene.js)

  • A scene with the same common frame as GameScene (developer tools, touch routing, loading screen, safe area insets, view size change detection, canvas background fill).
  • Holds its own LayoutSolver, and every tick attaches the solver to the UINodes in the tree (attach_pending_in_tree), solves once, then moves the values onto the nodes.
  • Screen guide UINode (screen_node): top left fixed at (0, 0), width and height are edit variables corrected with suggest_value when the size changes. (UIKit's UIWindow.bounds)
  • Safe area guide UINode (safe_area_layout_guide): inset from the screen guide by the safe area insets. It adjusts the insets by itself at layout. (UIKit's UIView.safeAreaLayoutGuide)
  • In the Rust version, instead of inheritance, the scene holds a UISceneBase, implements the UIScene trait, then gets a Scene with one line of ui_scene!. (same form as GameScene, game_scene!)
struct MenuScene { ui_scene_base: UISceneBase }
impl UIScene for MenuScene {
    fn get_ui_scene_base(&self) -> &UISceneBase { &self.ui_scene_base }
    fn get_ui_scene_base_mut(&mut self) -> &mut UISceneBase { &mut self.ui_scene_base }
    fn initialize(&mut self, engine: &Engine) { /* create nodes with UINode attached and add constraints with the get_safe_area_layout_guide anchors */ }
}
vanilla::ui_scene!(MenuScene);
  • Differences from the original:
  • The original inherits Scene directly and carries the same code as GameScene separately. The Rust version holds the common frame as a GameSceneBase (without creating the safe area node) and adds only the solver and the two guides. So GameSceneBase's screen fade and play input can also be used. (not in the original UIScene)
  • The original creates the solver and guides in create. The Rust version does not need the engine, so it creates them at construction. The "apply the view size to the solver right away" at the end of the original load is done in initialize.
  • The safe area insets are LayoutMargins instead of a { top, left, bottom, right } object. Solver errors are returned as Result<(), LayoutError>.

UISceneBasestruct traits Default

소스source

UI 씬의 바탕.

  • GameSceneBase 를 품고 솔버, 화면 가이드, 세이프 에어리어 가이드를 더한다. UIScene 을 구현한 씬이 필드로 품는다.

Base of the UI scene.

  • Holds a GameSceneBase and adds the solver, the screen guide and the safe area guide. A scene implementing UIScene holds it as a field.
예제Example세이프 에어리어 가이드에 붙인 머리 띠가 tick 에 놓인다A header band attached to the safe area guide is placed on tick
use vanilla::{Engine, EngineConfiguration, SafeAreaInsets, UINode, UISceneBase, Vector2};

let engine = Engine::new(EngineConfiguration::new());
engine.get_view_manager_mut().calculate_view_rect(800, 600, 1.0);
engine.get_view_manager_mut().set_safe_area_override(Some(SafeAreaInsets::create(40.0, 0.0, 20.0, 10.0)));
let mut ui_scene_base = UISceneBase::new();
ui_scene_base.initialize(engine);

let guide_left = ui_scene_base.get_safe_area_layout_guide().left_anchor();
let guide_top = ui_scene_base.get_safe_area_layout_guide().top_anchor();
let guide_right = ui_scene_base.get_safe_area_layout_guide().right_anchor();
let node_tree = ui_scene_base.get_scene_base_mut().get_node_tree_mut();
let root_id = node_tree.get_root_id();
let bar_id = node_tree.create_child(root_id, "bar");
node_tree.add_component(bar_id, UINode::new());
node_tree.with_component_mut::<UINode, _>(bar_id, |bar, _tree| {
	bar.add_constraint(&bar.left_anchor().equal_to(guide_left.clone())).unwrap();
	bar.add_constraint(&bar.top_anchor().equal_to(guide_top.clone())).unwrap();
	bar.add_constraint(&bar.right_anchor().equal_to(guide_right.clone())).unwrap();
	bar.add_constraint(&bar.height_anchor().equal_to(50)).unwrap();
});

ui_scene_base.tick(0.016);
let bar_node = &ui_scene_base.get_scene_base().get_node_tree()[bar_id];
assert_eq!(bar_node.get_local_position(), Vector2::create(10.0, 40.0));
assert_eq!(bar_node.get_content_size(), Vector2::create(790.0, 50.0));
생성자constructorpub fn new() -> UISceneBase#0.4.0 부터since 0.4.0소스source

생성. (솔버, 화면 가이드, 세이프 에어리어 가이드. 인셋 기본 0 이라 두 가이드가 같은 영역)

Constructor. (solver, screen guide, safe area guide. The insets default to 0, so both guides cover the same area)

반환ReturnsUISceneBase 새 바탕. (화면 가이드는 왼쪽 위 (0, 0) 고정, 너비와 높이는 strong 강도의 편집 변수)A new base. (the screen guide's top left is fixed at (0, 0), width and height are edit variables of strong strength)

짝Counterpart: vanilla.js UIScene.constructor

메서드methodpub fn get_game_scene_base(&self) -> &GameSceneBase#0.4.0 부터since 0.4.0소스source

공통 틀 반환. (로딩 화면, 배경색, 페이드 같은 GameSceneBase 기능)

Returns the common frame. (GameSceneBase features such as the loading screen, background color, fade)

반환Returns&GameSceneBase 품은 GameSceneBase 의 참조.Reference to the held GameSceneBase.

메서드methodpub fn get_game_scene_base_mut(&mut self) -> &mut GameSceneBase#0.4.0 부터since 0.4.0소스source

공통 틀 반환. (변경용)

Returns the common frame. (for modification)

반환Returns&mut GameSceneBase 품은 GameSceneBase 의 바꿀 수 있는 참조.Mutable reference to the held GameSceneBase.

메서드methodpub fn get_scene_base(&self) -> &SceneBase#0.4.0 부터since 0.4.0소스source

씬 공통 상태 반환.

Returns the common scene state.

반환Returns&SceneBase 씬 공통 상태(노드 트리, 트윈 등)의 참조.Reference to the scene common state (node tree, tweens, etc).

메서드methodpub fn get_scene_base_mut(&mut self) -> &mut SceneBase#0.4.0 부터since 0.4.0소스source

씬 공통 상태 반환. (변경용)

Returns the common scene state. (mutable)

반환Returns&mut SceneBase 씬 공통 상태의 바꿀 수 있는 참조.Mutable reference to the scene common state.

메서드methodpub fn set_view_scale_mode(&mut self, view_scale_mode: ViewScaleMode, engine: Option<&Engine>)#0.4.0 부터since 0.4.0소스source

ViewScaleMode 설정. (엔진을 주면 바로 반영, 아니면 initialize 에서)

Sets the ViewScaleMode. (applied right away if the engine is given, otherwise in initialize)

view_scale_modeViewScaleMode
뷰 배율 방식.View scale mode.
engineOption<&Engine>
바로 반영할 엔진. None 이면 initialize 에서 적용한다.Engine to apply it to right away. If None, it is applied in initialize.

짝Counterpart: vanilla.js UIScene.setViewScaleMode

메서드methodpub fn get_view_scale_mode(&self) -> ViewScaleMode#0.4.0 부터since 0.4.0소스source

지금 ViewScaleMode 반환.

Returns the current ViewScaleMode.

반환ReturnsViewScaleMode 지금 ViewScaleMode. (기본 None)Current ViewScaleMode. (default None)

짝Counterpart: vanilla.js UIScene.getViewScaleMode

메서드methodpub fn set_loading_image_url(&mut self, url: &str)#0.4.0 부터since 0.4.0소스source

로딩 화면 가운데 이미지 경로 설정. (create 전에)

Sets the loading screen center image path. (before create)

url&str
로딩 화면 가운데 이미지 경로. (빈 글이면 이미지 없이 게이지만)Loading screen center image path. (if an empty string, only the gauge without an image)

짝Counterpart: vanilla.js UIScene.setLoadingImageUrl

메서드methodpub fn set_loading_min_duration_ms(&mut self, milliseconds: f64)#0.4.0 부터since 0.4.0소스source

로딩 화면 최소 노출 시간 설정. (밀리초, create 전에)

Sets the loading screen minimum display time. (milliseconds, before create)

millisecondsf64
로딩 화면을 보일 가장 짧은 시간. (밀리초, 기본 3000)Shortest time to show the loading screen. (milliseconds, default 3000)

짝Counterpart: vanilla.js UIScene.setLoadingMinDurationMs

메서드methodpub fn set_scene_background_color(&mut self, color: impl Into<crate::base::color::Color>)#0.4.0 부터since 0.4.0소스source

캔버스 배경색 설정.

Sets the canvas background color.

colorimpl Into<crate::base::color::Color>
캔버스 배경색. (Color 나 "#rrggbb" 같은 글)Canvas background color. (a Color or text like "#rrggbb")

짝Counterpart: vanilla.js Scene.setSceneBackgroundColor

메서드methodpub fn load(&mut self, engine: &Engine)#0.4.0 부터since 0.4.0소스source

생성. (씬 load 에서 맨 먼저, 원본 load 의 앞부분 + load_assets)

Creation. (first thing in the scene's load, the front part of the original load + load_assets)

engine&Engine
엔진.Engine.

짝Counterpart: vanilla.js UIScene.load

메서드methodpub fn draw_on_load(&mut self, graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

로딩 화면 출력.

Draws the loading screen.

graphic&mut Graphic
그릴 그래픽.Graphic to draw with.

짝Counterpart: vanilla.js UIScene.drawOnLoad

메서드methodpub fn initialize(&mut self, engine: &Engine)#0.4.0 부터since 0.4.0소스source

초기화. (ViewScaleMode, 개발자 도구, 그리고 지금 뷰 크기를 솔버에 반영)

Initialization. (ViewScaleMode, developer tools, and applying the current view size to the solver)

engine&Engine
엔진. (뷰 크기와 세이프 에어리어를 읽는다)Engine. (reads the view size and the safe area)

짝Counterpart: vanilla.js UIScene.initialize

메서드methodpub fn resize(&mut self, canvas_native_size: Vector2)#0.4.0 부터since 0.4.0소스source

화면 크기 변경됨. (공통 틀의 레이아웃 뒤 솔버 레이아웃)

Screen size changed. (solver layout after the common frame's layout)

canvas_native_sizeVector2
바뀐 캔버스 크기. (공통 틀에 넘기고, 솔버 레이아웃은 이 값 대신 뷰 매니저의 뷰 크기를 읽는다)The changed canvas size. (passed to the common frame, the solver layout reads the view manager's view size instead of this value)

짝Counterpart: vanilla.js UIScene.resize

메서드methodpub fn layout(&mut self)#0.4.0 부터since 0.4.0소스source

레이아웃. (뷰 크기를 솔버에 제안하고, 세이프 에어리어 인셋이 바뀌었을 때만 가이드 제약을 다시 짓고, 풀어서 노드에 옮긴다)

Layout. (suggests the view size to the solver, rebuilds the guide constraints only when the safe area insets changed, solves, and moves the values onto the nodes)

짝Counterpart: vanilla.js UIScene.layout

메서드methodpub fn tick(&mut self, time_delta: f64) -> bool#0.4.0 부터since 0.4.0소스source

갱신. (공통 틀 tick, 뷰 크기가 바뀌었으면 레이아웃, 새 UINode 에 솔버를 붙이고 풀어서 노드에 옮긴다. 레이아웃을 다시 했으면 true)

Update. (common frame tick, layout if the view size changed, attaches the solver to new UINodes, solves, and moves the values onto the nodes. true if layout was redone)

time_deltaf64
지난 프레임부터 흐른 시간. (초)Time elapsed since the last frame. (seconds)

반환Returnsbool 뷰 크기가 바뀌어 레이아웃을 다시 했으면 true.true if the view size changed and layout was redone.

짝Counterpart: vanilla.js UIScene.tick

메서드methodpub fn suggest_screen_size(&mut self, size: Vector2)#0.4.0 부터since 0.4.0소스source

화면 가이드의 너비와 높이 제안.

Suggests the screen guide's width and height.

sizeVector2
화면 가이드에 줄 너비와 높이. (뷰 좌표, 솔버 오류는 버린다. 노드 값은 솔버를 푼 뒤에 바뀐다)Width and height to give the screen guide. (view coordinates, solver errors are discarded. Node values change after solving)

짝Counterpart: vanilla.js UIScene.suggestScreenSize

예제Example엔진 없이 화면 크기를 주고 가이드 읽기Giving the screen size without an engine and reading the guide
use vanilla::{UISceneBase, Vector2};

let mut ui_scene_base = UISceneBase::new();
ui_scene_base.suggest_screen_size(Vector2::create(1280.0, 720.0));
ui_scene_base.get_solver().update_variables();
assert!((ui_scene_base.get_screen_node().get_width() - 1280.0).abs() < 1e-6);
assert!((ui_scene_base.get_safe_area_layout_guide().get_bottom() - 720.0).abs() < 1e-6);
메서드methodpub fn get_safe_area_insets(&self) -> LayoutMargins#0.4.0 부터since 0.4.0소스source

세이프 에어리어 인셋 반환. (UIKit 의 UIView.safeAreaInsets)

Returns the safe area insets. (UIKit's UIView.safeAreaInsets)

반환ReturnsLayoutMargins 지금 세이프 에어리어 인셋. (뷰 좌표, 처음은 모두 0)Current safe area insets. (view coordinates, all 0 initially)

짝Counterpart: vanilla.js UIScene.getSafeAreaInsets

메서드methodpub fn set_safe_area_insets(&mut self, insets: LayoutMargins) -> Result<(), LayoutError>#0.4.0 부터since 0.4.0소스source

세이프 에어리어 인셋 설정. (가이드 제약 4 개를 바로 다시 짓는다)

Sets the safe area insets. (rebuilds the 4 guide constraints right away)

insetsLayoutMargins
새 인셋. (뷰 좌표, layout 이 엔진에서 읽은 값과 다르면 그 값으로 다시 바꾼다)New insets. (view coordinates, changed back to the engine's value if they differ from what layout reads from the engine)

반환ReturnsResult<(), LayoutError> Ok(()). 가이드 제약을 빼거나 다시 걸다 실패하면 그 LayoutError.Ok(()). The LayoutError if removing or adding the guide constraints again fails.

짝Counterpart: vanilla.js UIScene.setSafeAreaInsets

예제Example위 40, 아래 20 인셋으로 가이드를 줄이기Shrinking the guide with top 40, bottom 20 insets
use vanilla::{LayoutMargins, UISceneBase, Vector2};

let mut ui_scene_base = UISceneBase::new();
ui_scene_base.suggest_screen_size(Vector2::create(400.0, 700.0));
ui_scene_base.set_safe_area_insets(LayoutMargins::create(40.0, 0.0, 20.0, 0.0)).unwrap();
ui_scene_base.get_solver().update_variables();
let guide = ui_scene_base.get_safe_area_layout_guide();
assert!((guide.get_top() - 40.0).abs() < 1e-6);
assert!((guide.get_height() - 640.0).abs() < 1e-6);
메서드methodpub fn rebuild_safe_area_layout_guide_constraints(&mut self) -> Result<(), LayoutError>#0.4.0 부터since 0.4.0소스source

세이프 에어리어 가이드 제약 4 개를 다시 짓는다. (옛 제약을 빼고 지금 인셋으로 지어 다시 건다)

Rebuilds the 4 safe area guide constraints. (removes the old constraints, builds them with the current insets and adds them again)

반환ReturnsResult<(), LayoutError> Ok(()). 솔버에서 옛 제약을 빼거나 새 제약을 걸다 실패하면 그 LayoutError.Ok(()). The LayoutError if removing the old constraints from the solver or adding the new ones fails.

짝Counterpart: vanilla.js UIScene.rebuildSafeAreaLayoutGuideConstraints

메서드methodpub fn get_dev_tools(&self) -> Option<&DevTools>#0.4.0 부터since 0.4.0소스source

개발자 도구 반환. (원본 UIScene.getDevTools, initialize 전이거나 EngineConfiguration::use_dev_tools 가 꺼져 있으면 None)

Returns the developer tools. (the original UIScene.getDevTools, None before initialize or if EngineConfiguration::use_dev_tools is off)

반환ReturnsOption<&DevTools> 개발자 도구. initialize 전이거나 꺼져 있으면 None.Developer tools. None before initialize or when turned off.

짝Counterpart: vanilla.js UIScene.getDevTools

예제Example개발자 도구를 켜지 않은 바탕A base without developer tools turned on
use vanilla::UISceneBase;

let ui_scene_base = UISceneBase::new();
assert!(ui_scene_base.get_dev_tools().is_none());
메서드methodpub fn get_dev_tools_mut(&mut self) -> Option<&mut DevTools>#0.4.0 부터since 0.4.0소스source

개발자 도구 반환. (변경용)

Returns the developer tools. (mutable)

반환ReturnsOption<&mut DevTools> 개발자 도구. (변경용) initialize 전이거나 꺼져 있으면 None.Developer tools. (mutable) None before initialize or when turned off.

짝Counterpart: vanilla.js UIScene.getDevTools

메서드methodpub fn is_dev_tools_capturing_input(&self) -> bool#0.4.0 부터since 0.4.0소스source

개발자 도구가 입력을 가져가는 중인지.

Whether the developer tools are taking the input.

반환Returnsbool 개발자 도구가 보이고 누른 자리가 그 판 안이면 true. (개발자 도구가 꺼져 있으면 false)true if the developer tools are visible and the press position is inside their panel. (false if the developer tools are off)

짝Counterpart: vanilla.js UIScene.isDevToolsCapturingInput

메서드methodpub fn pre_draw(&self, graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

이전 출력. (캔버스 전체를 배경색으로, 세이프 에어리어 바깥 포함)

Pre-draw. (the whole canvas in the background color, including outside the safe area)

graphic&mut Graphic
그릴 그래픽.Graphic to draw with.

짝Counterpart: vanilla.js UIScene.preDraw

메서드methodpub fn post_draw(&mut self, graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

이후 출력. (개발자 도구를 화면 위에)

Post-draw. (the developer tools over the screen)

graphic&mut Graphic
그릴 그래픽.Graphic to draw with.

짝Counterpart: vanilla.js UIScene.postDraw

메서드methodpub fn get_solver(&self) -> &LayoutSolver#0.4.0 부터since 0.4.0소스source

솔버 반환. (값싼 핸들이라 복제해 써도 같은 솔버다)

Returns the solver. (a cheap handle, so clones are the same solver)

반환Returns&LayoutSolver 씬 솔버의 참조.Reference to the scene solver.

짝Counterpart: vanilla.js UIScene.getSolver

메서드methodpub fn get_screen_node(&self) -> &UINode#0.4.0 부터since 0.4.0소스source

화면 가이드 UINode 반환. (트리에 들지 않는다. left, top 은 0, width, height 는 뷰 크기)

Returns the screen guide UINode. (not in the tree. left, top are 0, width, height are the view size)

반환Returns&UINode 화면 가이드 UINode 의 참조.Reference to the screen guide UINode.

짝Counterpart: vanilla.js UIScene.getScreenNode

메서드methodpub fn get_safe_area_layout_guide(&self) -> &UINode#0.4.0 부터since 0.4.0소스source

세이프 에어리어 가이드 UINode 반환. (화면 가이드에서 인셋만큼 안쪽)

Returns the safe area guide UINode. (inset from the screen guide by the insets)

반환Returns&UINode 세이프 에어리어 가이드 UINode 의 참조. (앵커를 읽어 노드 제약에 쓴다)Reference to the safe area guide UINode. (its anchors are read and used in node constraints)

짝Counterpart: vanilla.js UIScene.getSafeAreaLayoutGuide

UIScenetrait traits 'static

짝Counterpart: vanilla.js UIScene소스source

UI 씬. (원본 UIScene 을 상속한 씬이 덮어쓰는 자리, GameScene 과 같은 규칙)

  • ui_scene! 이 만든 Scene 함수는 바탕(UISceneBase)을 먼저 부르고 이 트레이트의 같은 이름 함수를 부른다. post_draw 만 씬의 것이 먼저다.

UI scene. (the points that scenes inheriting the original UIScene override, same rules as GameScene)

  • The Scene functions made by ui_scene! call the base (UISceneBase) first, then the function of the same name in this trait. Only post_draw calls the scene's first.
예제Example세이프 에어리어 안쪽 왼쪽 위에 제목 칸을 놓는 씬A scene that places a title box at the top left inside the safe area
use vanilla::{Engine, EngineConfiguration, UINode, UIScene, UISceneBase};

struct MenuScene {
	ui_scene_base: UISceneBase,
}

impl UIScene for MenuScene {
	fn get_ui_scene_base(&self) -> &UISceneBase {
		&self.ui_scene_base
	}

	fn get_ui_scene_base_mut(&mut self) -> &mut UISceneBase {
		&mut self.ui_scene_base
	}

	fn initialize(&mut self, _engine: &Engine) {
		let guide_left = self.ui_scene_base.get_safe_area_layout_guide().left_anchor();
		let guide_top = self.ui_scene_base.get_safe_area_layout_guide().top_anchor();
		let node_tree = self.ui_scene_base.get_scene_base_mut().get_node_tree_mut();
		let root_id = node_tree.get_root_id();
		let title_id = node_tree.create_child(root_id, "title");
		node_tree.add_component(title_id, UINode::new());
		node_tree.with_component_mut::<UINode, _>(title_id, |title, _tree| {
			title.add_constraint(&title.left_anchor().equal_to(guide_left.add(16))).unwrap();
			title.add_constraint(&title.top_anchor().equal_to(guide_top.add(16))).unwrap();
			title.add_constraint(&title.width_anchor().equal_to(320)).unwrap();
			title.add_constraint(&title.height_anchor().equal_to(48)).unwrap();
		});
	}
}

vanilla::ui_scene!(MenuScene);

fn main() {
	let engine = Engine::new(EngineConfiguration::new());
	let menu_scene = MenuScene {
		ui_scene_base: UISceneBase::new(),
	};
	if let Err(error) = engine.run(Box::new(menu_scene)) {
		eprintln!("{}", error);
	}
}
메서드methodfn get_ui_scene_base(&self) -> &UISceneBase#0.4.0 부터since 0.4.0소스source

바탕 반환.

Returns the base.

반환Returns&UISceneBase 씬이 품은 UISceneBase 의 참조.Reference to the UISceneBase the scene holds.

메서드methodfn get_ui_scene_base_mut(&mut self) -> &mut UISceneBase#0.4.0 부터since 0.4.0소스source

바탕 반환. (변경용)

Returns the base. (mutable)

반환Returns&mut UISceneBase 씬이 품은 UISceneBase 의 바꿀 수 있는 참조.Mutable reference to the UISceneBase the scene holds.

메서드methodfn load_assets(&mut self)#0.4.0 부터since 0.4.0소스source

씬의 애셋 읽기. (원본 async loadAssets() 덮어쓰기)

  • 엔진은 Engine::get_engine() 으로 꺼낸다. await 로 읽으려면 engine.spawn_scene_task(self, ...) 로 불러오기 작업을 맡기고 씬 공통 상태의 track_task 로 맡긴다.

Loads the scene's assets. (overrides the original async loadAssets())

  • Take the engine with Engine::get_engine(). To load with await, hand the loading job to engine.spawn_scene_task(self, ...) and hand it to the scene common state's track_task.

짝Counterpart: vanilla.js UIScene.loadAssets

메서드methodfn draw_on_load(&mut self, _graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

로딩 화면 위에 더 그리기.

Draws more on top of the loading screen.

_graphic&mut Graphic
그릴 그래픽.Graphic to draw with.

짝Counterpart: vanilla.js UIScene.drawOnLoad

메서드methodfn initialize(&mut self, _engine: &Engine)#0.4.0 부터since 0.4.0소스source

초기화. (바탕 initialize 뒤)

Initialization. (after the base initialize)

_engine&Engine
엔진.Engine.

짝Counterpart: vanilla.js UIScene.initialize

메서드methodfn destroy(&mut self)#0.4.0 부터since 0.4.0소스source

소멸.

Destroys.

짝Counterpart: vanilla.js Scene.destroy

메서드methodfn layout(&mut self)#0.4.0 부터since 0.4.0소스source

레이아웃. (바탕이 솔버 레이아웃을 한 뒤)

Layout. (after the base does the solver layout)

짝Counterpart: vanilla.js UIScene.layout

메서드methodfn tick(&mut self, _time_delta: f64)#0.4.0 부터since 0.4.0소스source

갱신. (바탕 tick 뒤)

Update. (after the base tick)

_time_deltaf64
지난 프레임부터 흐른 시간. (초)Time elapsed since the last frame. (seconds)

짝Counterpart: vanilla.js UIScene.tick

메서드methodfn pre_draw(&mut self, _graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

이전 출력. (바탕 뒤)

Pre-draw. (after the base)

_graphic&mut Graphic
그릴 그래픽.Graphic to draw with.

짝Counterpart: vanilla.js UIScene.preDraw

메서드methodfn draw(&mut self, _graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

출력. (노드 트리를 그린 뒤)

Draw. (after drawing the node tree)

_graphic&mut Graphic
그릴 그래픽.Graphic to draw with.

짝Counterpart: vanilla.js Scene.draw

메서드methodfn post_draw(&mut self, _graphic: &mut Graphic)#0.4.0 부터since 0.4.0소스source

이후 출력. (바탕의 개발자 도구보다 먼저)

Post-draw. (before the base's developer tools)

_graphic&mut Graphic
그릴 그래픽.Graphic to draw with.

짝Counterpart: vanilla.js UIScene.postDraw

메서드methodfn finalize(&mut self, _engine: &Engine)#0.4.0 부터since 0.4.0소스source

종료처리. (내릴 때 unload 앞, 원본 Scene.finalize 덮어쓰기)

Finalizes. (before unload when taking down, overrides the original Scene.finalize)

_engine&Engine
엔진.Engine.

짝Counterpart: vanilla.js Scene.finalize

메서드methodfn unload(&mut self, _engine: &Engine)#0.4.0 부터since 0.4.0소스source

로딩 해제. (내릴 때 finalize 뒤, 원본 Scene.unload 덮어쓰기)

Unloads. (after finalize when taking down, overrides the original Scene.unload)

_engine&Engine
엔진.Engine.

짝Counterpart: vanilla.js Scene.unload

메서드methodfn on_page_process_restored(&mut self)#0.4.0 부터since 0.4.0소스source

페이지 프로세스 복원과 가시성 복원. (원본 onPageProcessRestored, onPageVisibilityRestored 덮어쓰기)

Page process restore and visibility restore. (overrides the original onPageProcessRestored, onPageVisibilityRestored)

짝Counterpart: vanilla.js Scene.onPageProcessRestored

메서드methodfn on_page_visibility_restored(&mut self)#0.4.0 부터since 0.4.0소스source

페이지 가시성 복원. (원본 onPageVisibilityRestored 덮어쓰기)

Page visibility restored. (overrides the original onPageVisibilityRestored)

짝Counterpart: vanilla.js Scene.onPageVisibilityRestored

메서드methodfn touch_press(&mut self, _view_input_position: Vector2)#0.4.0 부터since 0.4.0소스source

씬의 터치 훅. (원본 touchPress, touchMove, touchRelease, touchCancel, touchWheel 덮어쓰기, 바탕이 UI 와 놀이 입력에 넘긴 뒤 엔진이 부른다)

Touch hooks of the scene. (overrides the original touchPress, touchMove, touchRelease, touchCancel, touchWheel, called by the engine after the base passes them to the UI and play input)

_view_input_positionVector2
누른 자리. (뷰 좌표)Press position. (view coordinates)

짝Counterpart: vanilla.js UIScene.touchPress

메서드methodfn touch_move(&mut self, _view_input_position: Vector2)#0.4.0 부터since 0.4.0소스source

터치 이동. (누르고 있는 채 움직였을 때, 누른 프레임은 빼고)

Touch move. (when moved while held down, excluding the press frame)

_view_input_positionVector2
지금 자리. (뷰 좌표)Current position. (view coordinates)

짝Counterpart: vanilla.js UIScene.touchMove

메서드methodfn touch_release(&mut self, _view_input_position: Vector2)#0.4.0 부터since 0.4.0소스source

터치 뗌. (한 프레임 안에 눌렀다 떼면 누름 뒤에 바로)

Touch release. (right after press if pressed and released within one frame)

_view_input_positionVector2
뗀 자리. (뷰 좌표)Release position. (view coordinates)

짝Counterpart: vanilla.js UIScene.touchRelease

메서드methodfn touch_cancel(&mut self, _view_input_position: Vector2)#0.4.0 부터since 0.4.0소스source

터치 취소됨.

Touch cancelled.

_view_input_positionVector2
마지막 자리. (뷰 좌표)Last position. (view coordinates)

짝Counterpart: vanilla.js UIScene.touchCancel

메서드methodfn touch_wheel(&mut self, _view_input_position: Vector2, _wheel_delta: Vector2)#0.4.0 부터since 0.4.0소스source

마우스 휠. (이번 프레임에 쌓인 휠이 있을 때)

Mouse wheel. (when there is wheel accumulated this frame)

_view_input_positionVector2
포인터 자리. (뷰 좌표)Pointer position. (view coordinates)
_wheel_deltaVector2
이번 프레임에 쌓인 휠 이동량. (픽셀, x 는 오른쪽으로, y 는 내용을 아래로 넘기면 양수)Wheel movement accumulated this frame. (pixels, x is positive to the right, y is positive when scrolling the content down)

짝Counterpart: vanilla.js UIScene.touchWheel

함수Functions

함수functionmacro_rules! ui_scene#0.4.0 부터since 0.4.0소스source

UIScene 을 구현한 씬에 Scene 을 만들어 준다. (vanilla::ui_scene!(MenuScene);)

Makes a Scene for a scene implementing UIScene. (vanilla::ui_scene!(MenuScene);)