njin
Engine 2D gọn nhẹ để tự tay làm game theo ý mình. Vibe coding cũng ổn luôn
Loading...
Searching...
No Matches
njin_scene.h
1#pragma once
2#include "_mod.h"
3
4namespace njin {
5struct context;
6
9
14struct scene_desc {
15 const char *name = nullptr;
16 sys_fnc on_enter = nullptr;
17 sys_fnc on_exit = nullptr;
18};
19
27scene_handle scene_register(context &ctx, const scene_desc &desc);
28
33scene_handle scene_find(const context &ctx, const char *name);
34
47void scene_set(context &ctx, scene_handle scene);
48
52scene_handle scene_current(const context &ctx);
53
60 f32 fade_out = 0.35f;
61 f32 hold = 0.0f;
62 f32 fade_in = 0.35f;
63 rgba color{0.0f, 0.0f, 0.0f, 1.0f};
71};
72
85void scene_fade(context &ctx, scene_handle scene,
86 const scene_transition &transition = {});
87
91bool scene_transitioning(const context &ctx);
92
96f32 scene_transition_cover(const context &ctx);
98} // namespace njin
void(*)(context &ctx) sys_fnc
Một system là một hàm thường nhận context của engine.
Definition _mod.h:15
scene_handle scene_register(context &ctx, const scene_desc &desc)
Đăng ký một scene.
scene_handle scene_current(const context &ctx)
Scene đang chạy.
scene_handle scene_find(const context &ctx, const char *name)
Tìm scene theo tên.
f32 scene_transition_cover(const context &ctx)
Độ phủ hiện tại của hiệu ứng chuyển scene.
void scene_fade(context &ctx, scene_handle scene, const scene_transition &transition={})
Chuyển sang scene khác với hiệu ứng mờ dần (fade).
bool scene_transitioning(const context &ctx)
Có đang chuyển scene bằng scene_fade() không.
void scene_set(context &ctx, scene_handle scene)
Chuyển sang một scene khác.
float f32
Số thực 32 bit.
Definition _types.h:28
Màu gồm đỏ, xanh lá, xanh dương và alpha.
Definition _types.h:64
Mô tả một scene, dùng với scene_register().
Definition njin_scene.h:14
sys_fnc on_exit
Gọi một lần khi rời scene. Có thể null.
Definition njin_scene.h:17
sys_fnc on_enter
Gọi một lần khi vào scene. Có thể null.
Definition njin_scene.h:16
const char * name
Tên scene, phải là duy nhất.
Definition njin_scene.h:15
Định danh của một scene, tạo bởi scene_register().
Definition _types.h:139
Hiệu ứng chuyển scene, dùng với scene_fade().
Definition njin_scene.h:59
f32 fade_out
Thời gian phủ màn hình, giây.
Definition njin_scene.h:60
rgba color
Màu phủ.
Definition njin_scene.h:63
f32 hold
Thời gian tối thiểu giữ màn hình kín, giây.
Definition njin_scene.h:61
f32 fade_in
Thời gian mở màn hình, giây.
Definition njin_scene.h:62
sys_fnc draw_loading
Vẽ màn hình loading trong lúc phủ kín, trong không gian màn hình, đè lên màu phủ.
Definition njin_scene.h:70