Class gridpp::CallbackGridObject¶
ClassList > gridpp > CallbackGridObject
使用函式指標提供更新與碰撞行為的網格物件。
#include <GridObject.h>
Inherits the following classes: gridpp::GridObject
Public Types¶
| Type | Name |
|---|---|
| typedef void(*)(GridObject *self, GridObject *other) | CollideFn |
| typedef void(*)(GridObject *self) | UpdateFn |
Public Functions¶
| Type | Name |
|---|---|
| CallbackGridObject (std::string asset_name, int x, int y, UpdateFn update, CollideFn collide=nullptr) update 與 collide 可以是 nullptr。 |
|
| virtual void | OnCollide (GridObject * other) override 與另一個可見物件位於同一個有效網格座標時呼叫。 |
| virtual void | OnUpdate () override 每幀更新時呼叫。 |
Public Functions inherited from gridpp::GridObject¶
| Type | Name |
|---|---|
| GridObject () = default |
|
| GridObject (std::string asset_name, int x, int y) |
|
| GridObject (const GridObject & other) 複本不屬於任何 GridEngine。 |
|
| void | Move (int dx, int dy) |
| virtual void | OnCollide (GridObject * other) 與另一個可見物件位於同一個有效網格座標時呼叫。 |
| virtual void | OnSpawn () 物件加入引擎後呼叫一次。 |
| virtual void | OnUpdate () 每幀更新時呼叫。 |
| virtual void | Render (GridEngine * engine) 繪製物件。預設使用物件的素材、方向與顏色繪製所在格。 |
| const std::string & | asset_name () const |
| int | direction () const |
| GridEngine * | engine () const |
| GridObject & | operator= (const GridObject & other) = delete |
| void | set_asset_name (const std::string & asset_name) |
| void | set_direction (int direction) 每增加 1 逆時針旋轉 90 度;輸入會正規化至 0 到 3。 |
| void | set_tag (const std::string & tag) |
| void | set_tint (Color tint) |
| void | set_visible (bool visible) 隱藏的物件仍會更新,但不會繪製或參與碰撞。 |
| void | set_x (int x) |
| void | set_y (int y) |
| void | set_z_index (int z_index) 數值越大越晚繪製;相同數值保持 Spawn 順序。 |
| const std::string & | tag () const 可用於碰撞時辨識物件。 |
| Color | tint () const |
| bool | visible () const |
| int | x () const |
| int | y () const |
| int | z_index () const |
| virtual | ~GridObject () = default |
Public Types Documentation¶
typedef CollideFn¶
typedef UpdateFn¶
Public Functions Documentation¶
function CallbackGridObject¶
update 與 collide 可以是 nullptr。
inline gridpp::CallbackGridObject::CallbackGridObject (
std::string asset_name,
int x,
int y,
UpdateFn update,
CollideFn collide=nullptr
)
function OnCollide¶
與另一個可見物件位於同一個有效網格座標時呼叫。
Parameters:
other與此物件碰撞的借用指標。
Implements gridpp::GridObject::OnCollide
function OnUpdate¶
每幀更新時呼叫。
Implements gridpp::GridObject::OnUpdate
The documentation for this class was generated from the following file GridObject.h