Class gridpp::GridObject¶
ClassList > gridpp > GridObject
操作遊戲世界中單一網格物件的 handler。 More...
#include <GridObject.h>
Public Functions¶
| Type | Name |
|---|---|
| GridObject () = default 建立不指向任何物件的 handler。 |
|
| Color | color () const |
| GridObject | deepCopy () const |
| int | direction () const |
| bool | exists () const |
| int | get (const std::string & key, int & value) const |
| int | get (const std::string & key, long long & value) const |
| int | get (const std::string & key, double & value) const |
| int | get (const std::string & key, bool & value) const |
| int | get (const std::string & key, std::string & value) const |
| int | get (const std::string & key, std::vector< T > & value) const |
| void | hide () 隱藏物件;隱藏期間仍會更新,但不會繪製或參與碰撞。 |
| std::string | image () const |
| int | layer () const |
| void | move (int dx, int dy) 將物件相對移動 dx 欄、dy 列。 |
| void | remove () 從引擎移除物件;呼叫後所有指向它的 handler 都會失效。 |
| void | set (const std::string & key, int value) 以 key 儲存整數;int 與 long long 都以 long long 保存。 |
| void | set (const std::string & key, long long value) 以 key 儲存長整數。 |
| void | set (const std::string & key, double value) 以 key 儲存浮點數。 |
| void | set (const std::string & key, bool value) 以 key 儲存布林值。 |
| void | set (const std::string & key, const std::string & value) 以 key 儲存字串。 |
| void | set (const std::string & key, const char * value) 以 key 儲存 C 字串;內部會複製為 std::string。 |
| void | set (const std::string & key, const std::vector< T > & value) 以 key 儲存指定類型的 vector。 |
| void | setCollideFunction (CollisionCallback function) 取代碰撞 callback。 |
| void | setColor (Color color) 設定圖片 tint 或幾何形狀的顏色。 |
| void | setDirection (int direction) 設定繪製方向;輸入會正規化至 0 到 3。 |
| void | setImage (const std::string & image) 設定圖片物件使用的素材名稱。 |
| void | setInitFunction (GridObjectCallback function) 取代初始化 callback;若物件已初始化,新函式不會自動補呼叫。 |
| void | setLayer (int layer) 設定繪製層級;數值越大越晚繪製,相同層級保持建立順序。 |
| void | setPosition (int x, int y) 將物件移到指定網格座標。 |
| void | setUpdateFunction (GridObjectCallback function) 取代每幀更新 callback。 |
| void | show () 顯示物件。 |
| bool | visible () const |
| int | x () const |
| int | y () const |
Detailed Description¶
複製 handler 不會複製物件;所有複本仍指向同一個遊戲實體。物件被移除或 GameEngine 銷毀後,可以用 exists() 檢查 handler 是否仍有效。除 exists() 之外,對失效 handler 呼叫其他函式會拋出 std::runtime_error。
Public Functions Documentation¶
function GridObject¶
建立不指向任何物件的 handler。
function color¶
Returns:
圖片 tint 或幾何形狀的顏色。
function deepCopy¶
Returns:
一個擁有獨立狀態、callback 與新 handler 的物件複本。
function direction¶
Returns:
繪製方向,0 到 3 分別表示逆時針旋轉 0°、90°、180° 與 270°。
function exists¶
Returns:
handler 是否仍指向存在的物件。
function get [1/6]¶
Returns:
找到 key 時為 0;找不到時將 value 清為預設值並回傳 1。
Exception:
std::runtime_error若類型不同,或儲存的整數無法容納於 int。
function get [2/6]¶
Returns:
找到 key 時為 0;找不到時將 value 清為預設值並回傳 1。
Exception:
std::runtime_error若取值類型與儲存類型不同。
function get [3/6]¶
Returns:
找到 key 時為 0;找不到時將 value 清為預設值並回傳 1。
Exception:
std::runtime_error若取值類型與儲存類型不同。
function get [4/6]¶
Returns:
找到 key 時為 0;找不到時將 value 清為預設值並回傳 1。
Exception:
std::runtime_error若取值類型與儲存類型不同。
function get [5/6]¶
Returns:
找到 key 時為 0;找不到時將 value 清為預設值並回傳 1。
Exception:
std::runtime_error若取值類型與儲存類型不同。
function get [6/6]¶
template<typename T>
inline int gridpp::GridObject::get (
const std::string & key,
std::vector< T > & value
) const
Returns:
找到 key 時為 0;找不到時將 value 清為空 vector 並回傳 1。
Exception:
std::runtime_error若取值類型與儲存類型不同。
function hide¶
隱藏物件;隱藏期間仍會更新,但不會繪製或參與碰撞。
function image¶
Returns:
圖片物件的素材名稱。
Exception:
std::runtime_error若此 handler 指向幾何形狀。
function layer¶
Returns:
物件的繪製層級。
function move¶
將物件相對移動 dx 欄、dy 列。
function remove¶
從引擎移除物件;呼叫後所有指向它的 handler 都會失效。
function set [1/7]¶
以 key 儲存整數;int 與 long long 都以 long long 保存。
function set [2/7]¶
以 key 儲存長整數。
function set [3/7]¶
以 key 儲存浮點數。
function set [4/7]¶
以 key 儲存布林值。
function set [5/7]¶
以 key 儲存字串。
function set [6/7]¶
以 key 儲存 C 字串;內部會複製為 std::string。
function set [7/7]¶
以 key 儲存指定類型的 vector。
template<typename T>
inline void gridpp::GridObject::set (
const std::string & key,
const std::vector< T > & value
)
function setCollideFunction¶
取代碰撞 callback。
function setColor¶
設定圖片 tint 或幾何形狀的顏色。
function setDirection¶
設定繪製方向;輸入會正規化至 0 到 3。
function setImage¶
設定圖片物件使用的素材名稱。
Exception:
std::runtime_error若此 handler 指向幾何形狀。
function setInitFunction¶
取代初始化 callback;若物件已初始化,新函式不會自動補呼叫。
function setLayer¶
設定繪製層級;數值越大越晚繪製,相同層級保持建立順序。
function setPosition¶
將物件移到指定網格座標。
function setUpdateFunction¶
取代每幀更新 callback。
function show¶
顯示物件。
function visible¶
Returns:
物件是否可見。
function x¶
Returns:
物件的網格 x 座標。
function y¶
Returns:
物件的網格 y 座標。
The documentation for this class was generated from the following file GridObject.h