Coder Social home page Coder Social logo

skynet-cocos-creator's Introduction

skynet-cocos-creator-client

本项目是基于cocos-creator-puremvc 为基础 搭建的一个cocos creator 可以与skynet通信的 基础架构项目。

技术栈

安装

使用npm install

script目录结构

  • controller
    • bootstrap 需要初始化的MVC
    • commands 游戏内Command,增加Command基本都应该在这里
    • StartupCommand.ts 启动Command
  • lib
    • puremvc
    • state-machine状态机
    • behavior3行为树
  • model
    • GameProxy.ts ws数据代理
    • HttpProxy.ts http数据代理
    • GameProxy.ts 游戏数据代理示例
  • view
    • component 视图组件
    • StartViewMediator.ts Start场景中介
  • AppFacade.ts puremvc入口
  • Start.ts 开始场景启动脚本,AppFacade在这里初始化

注意点

  1. Command与Proxy、Mediator
    Command管理应用程序的 Business Logic(业务逻辑),要协调Model 与视图状态。

    Model 通过使用 Proxy 来保证数据的完整性、一致性 。Proxy 集中程序的Domain Logic(域逻辑),并对外公布操作数据对象的API。它封装了所有对数据模型的操作,不管数据是客户端还是服务器端的。

    Mediator 和Proxy 可以提供一些操作接口让Command 调用来管理View Component 和Data Object ,同时对 Command隐藏具体操作的细节。

  2. 一般一个Mediator(handleNotification方法)处理的Notification应该在4、5个之内。
    还要注意的是,Mediator的职责应该要细分。如果处理的Notification很多,则意味着Mediator需要被拆分,在拆分后的子模块的Mediator里处理要比全部放在一起更好。

  3. 应该避免Mediator与Proxy 直接交互。
    通常应该遵从了这个规则,但实际上项目Mediator中不可避免需要获取Proxy数据,如果每次都通过一个Notification去获取数据,然后返回数据给Mediator,这样无形中增加了通信次数、带反馈数据的通信加重通信负担。所以可以适当是的在Mediator中facade.retrieveProxy获取Proxy然后拿到数据,而且从proxy直接拿数据,可以保证拿到最新数据。

  4. 与skynet交互是 先http验证然后拿到 ws 相关所需的信息 再以 rpcId(大端4字节) + body 形式的数据结构

参考文档

skynet-cocos-creator's People

Contributors

cloudfreexiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

skynet-cocos-creator's Issues

cocos2.2.1无法打开此工程,会报以下错误

Failed to load package at D:\work\gameframework\skynet-cocos-creator-client\packages\i18n: Failed to load main.js: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
Failed to load package at D:\work\gameframework\skynet-cocos-creator-client\packages\i18n: Failed to load main.js: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
load script [protobufjs] failed : Error: Cannot find module 'protobufjs'

load script [isomorphic-fetch] failed : Error: Cannot find module 'isomorphic-fetch'
load script [../../../../packages/i18n/runtime-scripts/LanguageData] failed : Error: Cannot find module '../../../../packages/i18n/runtime-scripts/LanguageData'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.