Cocos2d-x  v3.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
AssetsManagerEx Class Reference

This class is used for resources hot update, you can update images or scripts during runtime of the game. More...

Inherits Ref.

Public Types

enum  State {
  UNCHECKED, PREDOWNLOAD_VERSION, DOWNLOADING_VERSION, VERSION_LOADED,
  PREDOWNLOAD_MANIFEST, DOWNLOADING_MANIFEST, MANIFEST_LOADED, NEED_UPDATE,
  UPDATING, UP_TO_DATE, FAIL_TO_UPDATE
}
 Update states. More...
 

Public Member Functions

void checkUpdate ()
 Check out if there is a new version of manifest. More...
 
void update ()
 Update with the current local manifest.
 
var update ()
 Update with the current local manifest.
 
local update ()
 Update with the current local manifest.
 
void downloadFailedAssets ()
 Reupdate all failed assets under the current AssetsManagerEx context, failed assets are noted in the previous update process.
 
var downloadFailedAssets ()
 Reupdate all failed assets under the current AssetsManagerEx context, failed assets are noted in the previous update process.
 
local downloadFailedAssets ()
 Reupdate all failed assets under the current AssetsManagerEx context, failed assets are noted in the previous update process.
 
State getState () const
 Gets the current update state. More...
 
const std::string & getStoragePath () const
 Gets storage path. More...
 
var getStoragePath ()
 Gets storage path. More...
 
local getStoragePath ()
 Gets storage path. More...
 
const ManifestgetLocalManifest () const
 Function for retrieve the local manifest object. More...
 
const ManifestgetRemoteManifest () const
 Function for retrieve the remote manifest object The remote manifest.
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
local retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor.
 

Static Public Member Functions

static AssetsManagerExcreate (const std::string &manifestUrl, const std::string &storagePath)
 Create function for creating a new AssetsManagerEx, use local manifest path and storage path as parameters. More...
 
local create ( local manifestUrl, local storagePath)
 Create function for creating a new AssetsManagerEx, use local manifest path and storage path as parameters. More...
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
local _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
local _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
local _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
local _rooted
 When true, it means that the object was already rooted.
 
bool _scriptOwned
 The life of the object is scrolled by the scripting engine. More...
 
local _scriptOwned
 The life of the object is scrolled by the scripting engine. More...
 

Detailed Description

This class is used for resources hot update, you can update images or scripts during runtime of the game.

Compare to AssetsManager class, it's a upgraded version. It's based on manifest configuration files to compare between local version and remote version, then generate a list of assets which need to be upgraded, download them then finish the update process. It contains the following features:

  • Multi thread downloading support
  • Two levels progression support: File level progression and byte level progression
  • Zip compressed file support
  • Download resuming
  • Detailed progression informations and error informations
  • Possibility to retry failed assets Please refer to this detailed document for its usage: http://cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en

Member Function Documentation

static AssetsManagerEx* create ( const std::string &  manifestUrl,
const std::string &  storagePath 
)
static

Create function for creating a new AssetsManagerEx, use local manifest path and storage path as parameters.

The url for the local manifest file The storage path for downloaded assetes The cached manifest in your storage path have higher priority and will be searched first, only if it doesn't exist, AssetsManagerEx will use the given manifestUrl.

var create ( var  manifestUrl,
var  storagePath 
)
static

Create function for creating a new AssetsManagerEx, use local manifest path and storage path as parameters.

The url for the local manifest file The storage path for downloaded assetes The cached manifest in your storage path have higher priority and will be searched first, only if it doesn't exist, AssetsManagerEx will use the given manifestUrl.

local create ( local  manifestUrl,
local  storagePath 
)
static

Create function for creating a new AssetsManagerEx, use local manifest path and storage path as parameters.

The url for the local manifest file The storage path for downloaded assetes The cached manifest in your storage path have higher priority and will be searched first, only if it doesn't exist, AssetsManagerEx will use the given manifestUrl.

void checkUpdate ( )

Check out if there is a new version of manifest.

You may use this method before updating, then let user determine whether he wants to update resources.

var checkUpdate ( )

Check out if there is a new version of manifest.

You may use this method before updating, then let user determine whether he wants to update resources.

local checkUpdate ( )

Check out if there is a new version of manifest.

You may use this method before updating, then let user determine whether he wants to update resources.

State getState ( ) const

Gets the current update state.

The current update state.

var getState ( )

Gets the current update state.

The current update state.

local getState ( )

Gets the current update state.

The current update state.

const std::string& getStoragePath ( ) const

Gets storage path.

The storage path.

var getStoragePath ( )

Gets storage path.

The storage path.

local getStoragePath ( )

Gets storage path.

The storage path.

const Manifest* getLocalManifest ( ) const

Function for retrieve the local manifest object.

The local manifest.

var getLocalManifest ( )

Function for retrieve the local manifest object.

The local manifest.

local getLocalManifest ( )

Function for retrieve the local manifest object.

The local manifest.


The documentation for this class was generated from the following file: