OT源代码的分析,OrtHello 迟早攻破你 (二)OT的基本属性和基本流程
2011-12-05 14:56
351 查看
OT三大基本物体:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202010/10/e2c95f891d3918614fc813d5640fbadf.gif)
首先我们看OT:它继承了最基本的MonoBehaviour,它是放置在场景中的,提供一些基本的属性
它的4大功能:
Check if framework is initialized (isValid)
Find your objects, animations, (sprite)containers and materials programmaticly.
Set your default solid/transparent and additive material. (这点大概是最重要的,不用设置繁琐的材质了)
Create a sprite programmaticly.
属性有:
objectPrototypes,就是我们在unity看到的预设的5个种类的物体,materials就是预设的材质了
![](https://oscdn.geek-share.com/Uploads/Images/Content/201112/05/51c20ea399e95fd05c696629121c8c20.gif)
以下是全局变量了-,-
public static bool dirtyChecks = true; 检查每一个物体的肢体是否绑定成功 ,会花费10fps (very rough estimate).
public static bool objectPooling = true; 创建和销毁物体的时候会 Pooling 放到缓冲池-,-暂定
public static bool debug = false;
public static bool isValid (在updata会检查)
public static float fps 返回fps
public static int objectCount
public static int containerCount 注册的containers 数量
public static int animationCount 注册的animation 数量
public static OTView view //摄像机的控制
public static bool Over(GameObject g)
public static bool Over(OTObject o) 划过一个物体
public static bool Clicked(GameObject g, int button) 是否我们的mouse点下了一个sprite
public static bool Clicked(GameObject g)
public static bool Clicked(OTObject o)
public static bool Touched(GameObject g) 物体是否可touch
public static bool Touched(OTObject o)
GetMaterial(string name) 和一些列材质的函数
查找函数
ContainerByName(string name) 返回OTContainer
AnimationByName(string name) 返回OTAnimation
ObjectByName(string name) 返回OTObject
public static void PreFabricate(string objectPrototype, int numberOfInstances) 创建一个物体缓冲池
public static GameObject CreateObject(string objectPrototype) 创建物体 (放入缓冲池中)
public static void DestroyObject(OTObject o) 销毁物体 (放入缓冲池中)
public static void DestroyContainer(OTContainer container)
public static void DestroyAnimation(OTAnimation animation)
public static void RemoveObject(OTObject o)
public static void RemoveAnimation(OTAnimation o)
public static void RemoveContainer(OTContainer o) //一系列重载
public static OTObject[] ObjectsUnderPoint(Vector2 screenPoint, OTObject[] checkObjects, OTObject[] ignoreObjects)
//Get all orthello objects under a specific point 是不是用来做某些检测用的,有一系列重载
public static OTController Controller(string controllerType, string name)
它自己的updata函数
![](https://oscdn.geek-share.com/Uploads/Images/Content/202010/10/e2c95f891d3918614fc813d5640fbadf.gif)
首先我们看OT:它继承了最基本的MonoBehaviour,它是放置在场景中的,提供一些基本的属性
它的4大功能:
Check if framework is initialized (isValid)
Find your objects, animations, (sprite)containers and materials programmaticly.
Set your default solid/transparent and additive material. (这点大概是最重要的,不用设置繁琐的材质了)
Create a sprite programmaticly.
属性有:
objectPrototypes,就是我们在unity看到的预设的5个种类的物体,materials就是预设的材质了
![](https://oscdn.geek-share.com/Uploads/Images/Content/201112/05/51c20ea399e95fd05c696629121c8c20.gif)
以下是全局变量了-,-
public static bool dirtyChecks = true; 检查每一个物体的肢体是否绑定成功 ,会花费10fps (very rough estimate).
public static bool objectPooling = true; 创建和销毁物体的时候会 Pooling 放到缓冲池-,-暂定
public static bool debug = false;
public static bool isValid (在updata会检查)
public static float fps 返回fps
public static int objectCount
public static int containerCount 注册的containers 数量
public static int animationCount 注册的animation 数量
public static OTView view //摄像机的控制
public static bool Over(GameObject g)
public static bool Over(OTObject o) 划过一个物体
public static bool Clicked(GameObject g, int button) 是否我们的mouse点下了一个sprite
public static bool Clicked(GameObject g)
public static bool Clicked(OTObject o)
public static bool Touched(GameObject g) 物体是否可touch
public static bool Touched(OTObject o)
GetMaterial(string name) 和一些列材质的函数
查找函数
ContainerByName(string name) 返回OTContainer
AnimationByName(string name) 返回OTAnimation
ObjectByName(string name) 返回OTObject
public static void PreFabricate(string objectPrototype, int numberOfInstances) 创建一个物体缓冲池
public static GameObject CreateObject(string objectPrototype) 创建物体 (放入缓冲池中)
public static void DestroyObject(OTObject o) 销毁物体 (放入缓冲池中)
public static void DestroyContainer(OTContainer container)
public static void DestroyAnimation(OTAnimation animation)
public static void RemoveObject(OTObject o)
public static void RemoveAnimation(OTAnimation o)
public static void RemoveContainer(OTContainer o) //一系列重载
public static OTObject[] ObjectsUnderPoint(Vector2 screenPoint, OTObject[] checkObjects, OTObject[] ignoreObjects)
//Get all orthello objects under a specific point 是不是用来做某些检测用的,有一系列重载
public static OTController Controller(string controllerType, string name)
它自己的updata函数
void Update() { if (instance == null) instance = this; if (Application.isEditor) { if (!Vector3.Equals(transform.position, Vector3.zero)) transform.position = Vector3.zero; } // check for clicks if (inputObjects.Count > 0) { if (Input.touchCount > 0 || Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButton(2) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2) || Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1) || Input.GetMouseButtonUp(2)) { if (Input.touchCount > 0) HandleInput(Input.touches[0].position); else HandleInput(Input.mousePosition); } } // calculate fps every 100ms fpsTime += Time.deltaTime; if (fpsTime >= 0.1f) { _fps = 1 / Time.deltaTime; fpsTime = 0; } if (controllers.Count > 0) { for (int c = 0; c < controllers.Count; c++) { OTController co = controllers[c]; if (co.enabled) co.Update(Time.deltaTime); } } }OT就是酱紫了
相关文章推荐
- OT源代码的分析,OrtHello 迟早攻破你 (三)OTObjectType 和OTMatRef 和OTObject
- OT源代码的分析,OrtHello 迟早攻破你 (十三)ortHello的代码执行顺序
- OT源代码的分析,OrtHello 迟早攻破你 (五)OTContainer相关
- OT源代码的分析,OrtHello 迟早攻破你 (七)第2个例子,碰撞和简单运动
- OT源代码的分析,OrtHello 迟早攻破你 (四)OTController
- OT源代码的分析,OrtHello 迟早攻破你 (九)第4个例子,镜头缩放,路径运动
- OT源代码的分析,OrtHello 迟早攻破你 (一)OTTween类参透
- OT源代码的分析,OrtHello 迟早攻破你 (五)默认的五种材质 和OTView
- OT源代码的分析,OrtHello 迟早攻破你 (十)第5个例子,用代码来创建物体(未完)
- OT源代码的分析,OrtHello 迟早攻破你 (十一)第6个例子,物理引擎和ortHello的结合(未完)
- OT源代码的分析,OrtHello 迟早攻破你 (六)重要的OTSprite
- OT源代码的分析,OrtHello 迟早攻破你 (八)第3个例子,碰撞检测和动画
- OT源代码的分析,OrtHello 迟早攻破你 (十二)第7个例子,ortHello的动作类OTTween(未完)
- RxJava && Agera 从源码简要分析基本调用流程(2)
- RxJava基本流程和lift源码分析
- UIScrollView 基本属性分析
- RxJava && Agera 从源码简要分析基本调用流程(1)
- Android RxJava基本流程和lift源码分析
- 数据分析的基本流程和方法
- MonoRail学习笔记四:MonoRail基本流程分析