Game类
Game类用来管理游戏。 该类用来加载关卡逻辑和所有的用户实体逻辑。
Game类的实现存放在路径下文件data/framework/game/game.h中。
Game Class
成员
Game ()
构造函数。 用来创建新Game类的实例。void init (GameData data, int level_index)
其作用是创建游戏并初始化游戏启动时的必要资源。参数
- GameData data - 指游戏的数据。
- int level_index - 指已加载的关卡的索引(index)。
void update ()
其作用是更新游戏。void flush ()
其作用是更新游戏的物理。void shutdown ()
其作用是释放游戏资源。void render ()
其作用是在update()函数被调用(invoke)之后更新游戏。GameData getGameData ()
其作用是返回游戏的数据。返回值
游戏的数据。Entity createEntity (string type)
其作用是创建Entity类的实例。参数
- string type - Entity type。
返回值
Entity类的实例。float getGameIFps ()
其作用是返回引擎的ifps。 这是获取ifps的最快方式。返回值
引擎的ifps。float getPhysicsIFps ()
其作用是返回物理的ifps。 这是获取物理的ifps的最快方式。返回值
物理的ifps。void setFields (Entity entity)
其作用是调用(invoke)带有相应实体值的,实体的所有setter字段(fields)方法。参数
- Entity entity - 指实体。
int getActiveLevelIndex ()
其作用是返回激活关卡的索引。返回值
激活关卡的索引。void loadLevel (variable index)
其作用是加载关卡。参数
- variable index - 该参数可以是关卡序号,前提是index为整型;它也可以是关卡名称,前提是index为string型。
void setGameParameter (string name, variable value)
其作用是设置游戏的自定义参数。参数
- string name - 指唯一的参数名称。
- variable value - 指参数值。 该值的类型可以是:int,float,double,vec3,vec4和string。
variable getGameParameter (string name)
其作用是返回自定义参数值。参数
- string name - 指参数名称。
返回值
如果找到了指定参数就返回自定义参数值;否则返回0。variable getGameParameter (string name, int default_value)
其作用是返回参数值。参数
- string name - 指参数名称。
- int default_value - 指默认值。
返回值
如果找到了指定参数就返回自定义参数值;否则返回默认值。string getLogicNamespaceName ()
其作用是返回包含了自定义逻辑的命名空间的名称。返回值
命名空间的名称。int isGameParameter (string name)
其作用是返回一个可用来指明游戏参数是否存在的值。参数
- string name - 指参数名称。
返回值
如果指定参数存在就返回1;否则返回0。最新更新: 2017-07-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)