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

Hai collider bắt đầu chồng nhau. Tiếp...

#include <njin_collision.h>

Các thuộc tính Public

entt::entity self = entt::null
 Entity nhận event.
entt::entity other = entt::null
 Entity kia.
bool trigger = false
 Một trong hai là trigger.

Mô tả chi tiết

Hai collider bắt đầu chồng nhau.

Mỗi cặp gửi hai event, một cho mỗi bên, nên handler chỉ cần xét self:

void on_enter(njin::collision_enter &e) {
if (reg.all_of<bullet>(e.self) && reg.all_of<enemy>(e.other)) ...
}
Hai collider bắt đầu chồng nhau.
Definition njin_collision.h:78
entt::entity self
Entity nhận event.
Definition njin_collision.h:79
entt::entity other
Entity kia.
Definition njin_collision.h:80

Event được phát sau phase_post_update, nên hủy entity trong handler là an toàn. Nhưng event của cả frame đã xếp hàng sẵn: một handler trước có thể đã hủy self hoặc other, nên kiểm tra registry.valid() cả hai trước.