This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Level类

指关卡逻辑的基类。

Level类的实现存放在路径下文件data/framework/game/level.h中。

Level Class

成员


Level ()

构造函数。 用来创建新Level类的实例。

void init (Game game, LevelData data)

其作用是初始化框架关卡。 创建要被放进虚拟世界的实体。

参数

  • Game game - 指关卡(Level)所属的那个游戏。
  • LevelData data - 指关卡的数据。

void update ()

其作用是更新关卡。

void flush ()

其作用是更新关卡的物理。

void render ()

渲染器会在update()函数之后被调用。 首先,onRender()函数会供实体调用,之后关卡的onRender()函数将被调用。

void shutdown ()

其作用是释放关卡资源。

void setPeriodicUpdate (variable instanse, string function, int frequency, int priority, variable arg0 = 0, variable arg1 = 0, variable arg2 = 0, variable arg3 = 0)

其作用是为函数设置定期更新。

参数

  • variable instanse - 指用户类的实例,也就是函数的调用方。 如果函数是静态的,那就传递NULL值。
  • string function - 指函数名称。
  • int frequency - 指函数调用的频率。 该频率可取1到60间的值。
  • int priority - 指函数调用的优先级。
  • variable arg0 - 指函数参数,可选。
  • variable arg1 - 指函数参数,可选。
  • variable arg2 - 指函数参数,可选。
  • variable arg3 - 指函数参数,可选。

void removePeriodicUpdate (variable instanse, string function, int num_ = 0)

其作用是移除函数的定期更新。

参数

  • variable instanse - 指用户类的实例,也就是函数的调用方。 如果函数是静态的,那就传递NULL值。
  • string function - 指函数名称。
  • int num_ - 指函数参数的数量。

void createEvent (string name)

其作用是创建事件。

参数

  • string name - 指唯一的事件名称。

void removeEvent (string name)

其作用是移除事件。

参数

  • string name - 指唯一的事件名称。

int isEvent (string name)

其作用是返回一个可用来指明带有指定名称的事件是否存在的值。

参数

  • string name - 指事件名称。

返回值

如果指定事件存在就返回1;否则返回0

void setEventEnabled (string name, int mode)

其作用是设置一个可用来指明事件是否被启用或禁用的值。

参数

  • string name - 指事件名称。
  • int mode - 1,表示启用事件;0,表示禁用事件。

int isEventEnabled (string name)

其作用是返回一个可用来指明事件是否被启用的值。

参数

  • string name - 指事件名称。

返回值

如果指定事件被启用就返回1;否则返回0

void callEvent (string name)

其作用是调用事件。

参数

  • string name - 指事件名称。

void callEvent (string name, variable bound)

其作用是调用指定区域内的事件。 根据被作为参数传递的变量的不同,指定区域可以是盒体,球体或视锥。
注意
取消订阅事件的实体,必须具有可获得相交和可被调用的surface_base属性。

参数

  • string name - 指事件名称。
  • variable bound - 指具有如下某个类型的变量:

void subscribe (string name, variable instanse, string function, variable arg0 = 0, variable arg1 = 0, variable arg2 = 0, variable arg3 = 0)

其作用是将函数订阅给事件。

参数

  • string name - 指事件名称。
  • variable instanse - 指用户类的实例,也就是函数的调用方。 如果函数是静态的,那就传递NULL值。
  • string function - 指事件发生时被调用函数的名称。
  • variable arg0 - 指函数参数,可选。
  • variable arg1 - 指函数参数,可选。
  • variable arg2 - 指函数参数,可选。
  • variable arg3 - 指函数参数,可选。

void unsubscribe (string name, variable instanse, string function, int num_args = 0)

其作用是从事件取消订阅函数。

参数

  • string name - 指事件名称。
  • variable instanse - 指用户类的实例,也就是函数的调用方。 如果函数是静态的,就传递NULL值。
  • string function - 指事件发生时被调用函数的名称。
  • int num_args - 指函数参数的数量。

void onWarm ()

指在实体创建之前被调用的虚方法。 该方法默认为空。

void onInit ()

指在关卡初始化之后被调用的虚方法。 该方法默认为空。

void onPreUpdate ()

指在实体更新之前被调用的虚方法。 该方法默认为空。

void onPostUpdate ()

指在实体更新之后被调用的虚方法。 该方法默认为空。

void onFlush ()

指在实体的物理更新之后被调用的虚方法。 该方法默认为空。

void onShutdown ()

指在关卡资源释放之后被调用的虚方法。 在此方法中,您需要从事件取消订阅并移除函数的定期更新。 该方法默认为空。

void onRender ()

指在render()调用之后被调用的虚方法。

Entity createEntity (string type, string name = "")

其作用是创建具有指定类型的实体(entity)。 该函数会检查内存池中是否存在具有指定类型的实体,如果存在就返回这种实体;否则,该函数将创建新实体并加载新的节点引用,该引用与新的entity类相对应。

参数

  • string type - 指实体类型。
  • string name = "" - 指实体名称,可选。

返回值

实体。

void removeEntity (Entity entity, int mode = 0)

其作用是通过某一个删除选项删除实体。

参数

void appendEntity (Entity entity)

其作用是将实体追加到实体列表。

参数

  • Entity entity - 指要追加的实体。

int getNumEntities ()

其作用是返回实体的数量。

返回值

实体的数量。

Entity getEntity (variable index)

其作用是通过实体自身的索引(index)返回该实体。

参数

  • variable index - 该参数可以是实体索引,前提是index为整型;它也可以是实体名称,前提是index为string型。

返回值

如果存在某个实体则返回该实体;否则返回NULL

void getEntities (string type = "", Entity ret[])

其作用是从所有的关卡实体中选择指定的实体。

参数

  • string type = "" - 指实体类的名称。 如果type为空string型,那所有的实体类型都会被添加给内存池。
  • Entity ret[] - 指实体将被放到的数组。

void getEntities (string type = "", int childs = 1, Entity ret[])

其作用是从所有的关卡实体中选择指定的实体。

参数

  • string type = "" - 指实体类的名称。 如果type为空string型,那所有的实体类型都会被添加给内存池。
  • int childs - 指可用来指明实体类的子类是否被添加给数组的标记。
  • Entity ret[] - 指实体将被放到的数组。

void getIntersectionNodesEntity (variable bound, variable type, int childs = 1, int filter, Entity ret[])

其作用是在指定区域内搜索节点之中的实体。 根据被作为参数传递的变量的不同,指定区域可以是盒体,球体或视锥。
注意
绑定了实体的节点引用的根节点,必须具有可获得相交和可被返回的surface_base属性。

参数

  • variable bound - 指具有如下某个类型的变量:
  • variable type - 指具有如下某个类型的变量:
    • string - 指实体类的名称。
    • int - 指实体类的ID。
    注意
    如果参数值为空,那所有的实体类型都将被添加给内存池。
  • int childs - 指可用来指明实体类的子类是否被添加给数组的标记。
  • int filter - 指节点类型过滤器(某一个NODE_*变量),若为-1则不使用过滤器。
  • Entity ret[] - 指实体将被放到的数组。

void getIntersectionObjectsEntity (variable bound, variable type, int childs = 1, Entity ret[])

其作用是在指定区域内搜索对象之中的实体。根据被作为参数传递的变量的不同,指定区域可以是盒体,球体或视锥。
注意
绑定了实体的节点引用的根节点,必须具有可获得相交和可被返回的surface_base属性。

参数

  • variable bound - 指具有如下某个类型的变量:
  • variable type - 指具有如下某个类型的变量:
    • string - 指实体类的名称。
    • int - 指实体类的ID。
    注意
    如果参数值为空,那所有的实体类型都将被添加给内存池。
  • int childs = 1 - 指可用来指明实体类的子类是否被添加给数组的标记。
  • Entity ret[] - 指实体将被放到的数组。

void setEntityEventEnabled (Entity entity, int event, int mode)

其作用是开关实体的特殊函数的调用。

参数

  • Entity entity - 指实体。
  • int event - 指某一个ENTITY_EVENT_*值。
  • int mode - 1,表示启用函数的调用,该函数由ENTITY_EVENT_*值指定;0表示禁用函数的调用。

void setEntityEnabled (Entity entity, int mode)

其作用是开关实体。

参数

  • Entity entity - 指实体。
  • int mode - 1,表示启用实体;0,表示禁用实体。

void setEntityUpadeOrder (Entity entity, int order)

其作用是为实体设置更新顺序。

参数

  • Entity entity - 指实体。
  • int order - 指更新顺序。 该参数可取016间的值。 其默认值为8

string getName ()

其作用是返回关卡名称。

返回值

关卡名称。

Game getGame ()

其作用是返回关卡所属的游戏。

返回值

游戏。

int ENTITY_EVENT_UPDATE

说明/描 述

代表的是onUpdate()函数。

int ENTITY_EVENT_FLUSH

说明/描 述

代表的是onFlush()函数。

int ENTITY_EVENT_RENDER

说明/描 述

代表的是onRender()函数。

int REMOVE_ENTITY_MODE_DEFAULT

说明/描 述

其作用是删除实体(entity),而不是节点引用。

int REMOVE_ENTITY_MODE_DELETE_NODE

说明/描 述

其作用是删除实体(entity)和节点引用。

int REMOVE_ENTITY_MODE_POOL

说明/描 述

其作用是将实体(entity)和节点引用添加给内存池。 内存池能用来更快速地创建新实体:如果内存池中有实体,那就无需从文件创建节点引用,因为池中就有节点引用。
最新更新: 2017-07-03
Build: ()