1 / 9

Cocos2d

Cocos2d . cocos2D 框架分 析 框架 中的设计模式. 框架 VS 程序库. 1. Library: 子程序的集合 , 意在代码复用 . 2. Framework: 预定 义控制流 , 等待用户代码填充的复杂系统 . 3. Key difference: Inversion of control 4. Relation: Both defined API …. Cocos2d 框架. Director: 负责 scenes 之间的前进或 后退 . 唯一实例 .

juan
Download Presentation

Cocos2d

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cocos2d cocos2D框架分析 框架中的设计模式

  2. 框架 VS 程序库 1. Library: 子程序的集合,意在代码复用. 2. Framework: 预定义控制流,等待用户代码填充的复杂系统. 3. Key difference: Inversion of control 4. Relation: Both defined API …

  3. Cocos2d 框架 Director: 负责scenes之间的前进或后退. 唯一实例. Scene: 任何时候只有一个是处于激活状态,由一个或多个layer组成. 负责场景画面的运 行,暂停,还原等功能. Layer: 用于定义外观和事件behavior. 当编写cocos2d程序的时候,大部分工作就是编写 CCLayer的子类去实现所要的效果. Sprite: 可以移动、选择、伸缩、动画的2d图形.CCSprite对象的子成员中可以包含其它 的CCSprite对象.

  4. 组合模式 动机:一致对待容器对象与单个对象 结构:抽象构件,叶子构件,容器构件 实例:XML文档解析,系统文件浏览 优点:方便层次结构的控制,易扩展

  5. 扩展:透明组合模式与安全组合模式 透明组合模式不够安全,安全组合模式不够透明

  6. 单例模式 动机:让类自身负责保存它的唯一实例. 结构:只包含一个Singleton,提供一个静态的getInstance()工厂方法. 实例:windows 任务管理器 优点:受控访问,节约资源,允许可变数目的实例. 适用情况:系统只需要一个实例对象;客户端调用类的单个实例只允许使用一个公共访问点.

  7. 状态模式 动机:将拥有状态的对象与状态对应的行为分离. 结构:Context上下文类,State抽象状态类, ConcreteState具体状态类 实例:论坛用户等级, 银行账户.

  8. Thank you!

More Related