Class gridpp::GridObject¶
ClassList > gridpp > GridObject
遊戲世界中會更新、碰撞與繪製的物件。
#include <GridObject.h>
Inherited by the following classes: gridpp::CallbackGridObject, gridpp::GridMaze, gridpp::shapes::Shape
Public Functions¶
| 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 Functions Documentation¶
function GridObject [1/3]¶
function GridObject [2/3]¶
function GridObject [3/3]¶
複本不屬於任何 GridEngine。
function Move¶
function OnCollide¶
與另一個可見物件位於同一個有效網格座標時呼叫。
Parameters:
other與此物件碰撞的借用指標。
function OnSpawn¶
物件加入引擎後呼叫一次。
function OnUpdate¶
每幀更新時呼叫。
function Render¶
繪製物件。預設使用物件的素材、方向與顏色繪製所在格。
Parameters:
engine所屬引擎的借用指標。
function asset_name¶
function direction¶
function engine¶
Returns:
所屬引擎的借用指標;尚未 Spawn 時為 nullptr。
function operator=¶
function set_asset_name¶
function set_direction¶
每增加 1 逆時針旋轉 90 度;輸入會正規化至 0 到 3。
function set_tag¶
function set_tint¶
function set_visible¶
隱藏的物件仍會更新,但不會繪製或參與碰撞。
function set_x¶
function set_y¶
function set_z_index¶
數值越大越晚繪製;相同數值保持 Spawn 順序。
function tag¶
可用於碰撞時辨識物件。
function tint¶
function visible¶
function x¶
function y¶
function z_index¶
function ~GridObject¶
The documentation for this class was generated from the following file GridObject.h