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::anim_graph_desc Struct Tham chiếu

Mô tả một máy trạng thái animation, dùng với anim_graph_create(). Tiếp...

#include <njin_anim.h>

Các thuộc tính Public

anim_sheet_handle sheet {}
 Sheet chứa các clip.
std::vector< anim_state_desc > states {}
 Các trạng thái.
std::vector< anim_transition_desc > transitions {}
 Các chuyển trạng thái.
const char * start = nullptr
 Trạng thái ban đầu. null là trạng thái đầu tiên.

Mô tả chi tiết

Mô tả một máy trạng thái animation, dùng với anim_graph_create().

g.player_anim = njin::anim_graph_create(ctx, {
.sheet = sheet,
.states = {{.name = "idle", .clip = "idle"},
{.name = "run", .clip = "run"},
{.name = "jump", .clip = "jump", .repeat = 1},
{.name = "attack", .clip = "attack", .repeat = 1}},
.transitions = {
{.to = "attack", .when = {{"attack", njin::anim_trigger}}},
{.from = "attack", .to = "idle", .after_finish = true},
{.from = "idle", .to = "jump", .when = {{"grounded", njin::anim_false}}},
{.from = "run", .to = "jump", .when = {{"grounded", njin::anim_false}}},
{.from = "jump", .to = "idle", .when = {{"grounded", njin::anim_true}}},
{.from = "idle", .to = "run", .when = {{"speed", njin::anim_gt, 10}}},
{.from = "run", .to = "idle", .when = {{"speed", njin::anim_le, 10}}},
}});
anim_graph_handle anim_graph_create(context &ctx, const anim_graph_desc &desc)
Tạo một máy trạng thái animation.
@ anim_le
Tham số nhỏ hơn hoặc bằng value.
Definition njin_anim.h:99
@ anim_false
Tham số bằng 0 (bool đang tắt).
Definition njin_anim.h:103
@ anim_gt
Tham số lớn hơn value.
Definition njin_anim.h:96
@ anim_trigger
Tham số được bật bằng animator_trigger() trong frame này.
Definition njin_anim.h:106
@ anim_true
Tham số khác 0 (bool đang bật).
Definition njin_anim.h:102
anim_sheet_handle sheet
Sheet chứa các clip.
Definition njin_anim.h:159