资源简介

Cocos2d-x 3.2 自动更新 使用AssetsManager更新游戏资源包

资源截图

代码片段和文件信息

#include “AppDelegate.h“

#include 
#include 

#include “Upgrade.h“
#include “AppMacros.h“

USING_NS_CC;
using namespace std;

AppDelegate::AppDelegate() {

}

AppDelegate::~AppDelegate() 
{
}

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLView::create(“Cpp Empty Test“);
        director->setOpenGLView(glview);
    }

    director->setOpenGLView(glview);

    // Set the design resolution
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
    // a bug in DirectX 11 level9-x on the device prevents ResolutionPolicy::NO_BORDER from working correctly
    glview->setDesignResolutionSize(designResolutionSize.width designResolutionSize.height ResolutionPolicy::SHOW_ALL);
#else
    glview->setDesignResolutionSize(designResolutionSize.width designResolutionSize.height ResolutionPolicy::NO_BORDER);
#endif

Size frameSize = glview->getframeSize();
    
    vector searchPath;

    // In this demo we select resource according to the frame‘s height.
    // If the resource size is different from design resolution size you need to set contentScaleFactor.
    // We use the ratio of resource‘s height to the height of design resolution
    // this can make sure that the resource‘s height could fit for the height of design resolution.

    // if the frame‘s height is larger than the height of medium resource size select large resource.
if (frameSize.height > mediumResource.size.height)
{
        searchPath.push_back(largeResource.directory);

        director->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height largeResource.size.width/designResolutionSize.width));
}
    // if the frame‘s height is larger than the height of small resource size select medium resource.
    else if (frameSize.height > smallResource.size.height)
    {
        searchPath.push_back(mediumResource.directory);
        
        director->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height mediumResource.size.width/designResolutionSize.width));
    }
    // if the frame‘s height is smaller than the height of medium resource size select small resource.
else
    {
        searchPath.push_back(smallResource.directory);

        director->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height smallResource.size.width/designResolutionSize.width));
    }
    
    // set searching path
    FileUtils::getInstance()->setSearchPaths(searchPath);

    // turn on display FPS
    director->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don‘t call this
    director->setAnimationInterval(1.0 / 60);

    // create a scene. it‘s an autorelease object
    auto scene = Scene::create();
auto layer = Upgrade::create();
scene->addChild(layer);
    // run
    director->runWithScene(scene);

    return true;
}

// 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        3609  2014-07-28 08:40  Classes\AppDelegate.cpp
     文件         947  2014-07-11 10:15  Classes\AppDelegate.h
     文件        2732  2014-07-11 10:15  Classes\AppMacros.h
     文件        3201  2014-07-28 09:00  Classes\HelloWorldScene.cpp
     文件         594  2014-07-15 10:32  Classes\HelloWorldScene.h
     文件        3908  2014-07-28 08:56  Classes\Upgrade.cpp
     文件         884  2014-07-28 08:41  Classes\Upgrade.h
     目录           0  2014-07-28 09:00  Classes\

评论

共有 条评论