• 烈焰遮天 cocos 手游mmo 源码 解析


    20160820011207843

    引擎: cocos2.x

    代码: c++ 混合 lua

    游戏类型: mmo

    工程结构:

    game : 游戏启动地方

    gamelogic:接sdk相关,登陆支付统计等

    libFramework:主要本游戏相关c++库

    uicontrol:

    zpack:一个开源的打包文件工具

    -----------------------------------------------------------------------------------------

    分析libFramework:

    base目录

    sfapp.h : 框架app,继承了一个scene,这是本游戏的主scene基类。

    cpp:

    [cpp] view plain copy

    1. #include "sofia/utils/SFLog.h"
    2. #include "include/utils/SFTimeAxis.h"
    3. #include "map/StructCommon.h"
    4. #include "base/SFApp.h"
    5. #include "SFSimulator.h"
    6. //#include "download/mfDownloader.h"
    7. using namespace cocos2d; 
    8. SFApp::SFApp() 
    9. //this->init();
    10. SFApp::~SFApp() 
    11. void SFApp::startRun() 
    12.     cocos2d::CCSize size = cocos2d::CCEGLView::sharedOpenGLView()->getFrameSize(); 
    13.     m_width = size.width; 
    14.     m_height = size.height; 
    15. //执行update循环!
    16.     getScheduler()->scheduleUpdateForTarget(this, kCCPrioritySystem, false); 
    17. //虚函数,调用子类的实现
    18. this->onInit(); 
    19. // void SFApp::stopRun()
    20. // {
    21. //  getScheduler()->unscheduleUpdateForTarget(this);
    22. // }
    23. //屏幕宽,
    24. int SFApp::getScreenResolutionX() 
    25. return m_width; 
    26. int SFApp::getScreenResolutionY() 
    27. return m_height; 
    28. //这个simulator,难道是cocos3.x 增加的simulator,待会看看
    29. void SFApp::onTick( int microSecs ) 
    30. //SFLog("SFApp::onTick %d", microSecs);
    31.     SFGameSimulator::sharedGameSimulator()->tick();//网络tick//难道这里只是网络监听而已?
    32. //MFDownloader::instance()->tick();          // 下载的回调依赖tick
    33. void SFApp::onDraw() 
    34. void SFApp::update( float dt ) 
    35. //一个定时器实现。用来干嘛呢?
    36. //字面意思,就是在Timer里面,设了一个delaytime,这个应该全局一致
    37.     SFTimeAxis* pTimeAxis = SFTimeAxis::getInstancePtr(); 
    38.     pTimeAxis->advance(dt* 1000); 
    39.     onTick(pTimeAxis->getDelayTime()); 
    40. void SFApp::draw( void ) 
    41.     cocos2d::CCScene::draw(); 
    42.     onDraw(); 
    43. void SFApp::onDestory() 
    44. void SFApp::onExit() 
    45. this->removeAllChildrenWithCleanup(true); 
    46.     onDestory(); 
    47.     cocos2d::CCScene::onExit(); 
    48. bool SFApp::init() 
    49.     cocos2d::CCScene::init(); 
    50.     startRun(); 
    51. return true; 

    先把基础的一些代码看完,

    ------------------------------------------------------------------------

    utils目录:
    ccstrconv.h 对字符串的一些基本转换处理;不错,这些平时都可以收集起来,自己写的项目可以用到

    ccstrutil.h  更多的字符串处理

    csvfile.h  csv文件的读写

    httptools.h  对cocos提供的http进行了一些封装,这个3.x cocos有xmlhttp,本身都封装过

    sfeasymail  调用curl库,直接发email,这个蛮吊的嘛!!!给客服发邮件吗?

    sfthread  封装了一个线程类,分别为win和Android-iOS写了不同的实现,信号量,互斥锁,读写锁

    singleton 单例模板

    streamdataadapter c++和lua直接传递复杂数据的适配器,搞这么复杂。。。

    sfminihtml html解析,不知哪里用到

    sfexecutionthreadservice  线程的进一步封装

    sfprioritynotificationcenter

    sfstringutil 更详细的string处理

    sftouchdispatcher

    ----------------------------------------------------------------

    stream目录  二进制文件读写操作封装

    package  热更新相关

    scene scene管理

    net 网络

    eventset  事件

    core 单独写了一个sprite类;用来显示地图上的sprite,有什么好处?

    map 主要的mmo地图等元素逻辑

  • 相关阅读:
    JavaScript提供了哪些定时器
    谈谈对CSS盒子模型的理解
    我们来谈谈类的加载机制
    谈谈你对ThreadLocal的理解
    谈谈你对线程安全的理解?
    JDK提供的线程池有哪些?实际开发我们该怎么使用?
    Pytest系列(7)
    Pytest系列(6)
    Pytest系列(5)
    Pytest系列(4)
  • 原文地址:https://www.cnblogs.com/Siegel/p/7204888.html
Copyright © 2020-2023  润新知