2013-02-22 11:04:09 +08:00
|
|
|
//
|
|
|
|
// AssetsManagerTestAppDelegate.h
|
|
|
|
// AssetsManagerTest
|
|
|
|
//
|
|
|
|
// Created by minggo on 2/5/13.
|
|
|
|
// Copyright __MyCompanyName__ 2013. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef _APP_DELEGATE_H_
|
|
|
|
#define _APP_DELEGATE_H_
|
|
|
|
|
|
|
|
#include "CCApplication.h"
|
|
|
|
#include "cocos2d.h"
|
2013-10-17 18:39:37 +08:00
|
|
|
#include "extensions/assets-manager/AssetsManager.h"
|
2013-02-22 11:04:09 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief The cocos2d Application.
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
The reason to implement with private inheritance is to hide some interface details of Director.
|
2013-02-22 11:04:09 +08:00
|
|
|
*/
|
2013-06-20 14:17:10 +08:00
|
|
|
class AppDelegate : private cocos2d::Application
|
2013-02-22 11:04:09 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
AppDelegate();
|
|
|
|
virtual ~AppDelegate();
|
|
|
|
|
|
|
|
/**
|
2013-06-20 14:17:10 +08:00
|
|
|
@brief Implement Director and Scene init code here.
|
2013-02-22 11:04:09 +08:00
|
|
|
@return true Initialize success, app continue.
|
|
|
|
@return false Initialize failed, app terminate.
|
|
|
|
*/
|
|
|
|
virtual bool applicationDidFinishLaunching();
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief The function is called when the application enters the background
|
|
|
|
@param the pointer of the application instance
|
|
|
|
*/
|
|
|
|
virtual void applicationDidEnterBackground();
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief The function is called when the application enters the foreground
|
|
|
|
@param the pointer of the application instance
|
|
|
|
*/
|
|
|
|
virtual void applicationWillEnterForeground();
|
|
|
|
};
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class UpdateLayer : public cocos2d::Layer, public cocos2d::extension::AssetsManagerDelegateProtocol
|
2013-02-22 11:04:09 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
UpdateLayer();
|
|
|
|
~UpdateLayer();
|
|
|
|
virtual bool init();
|
2013-02-26 16:29:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void enter(cocos2d::Object *pSender);
|
|
|
|
void reset(cocos2d::Object *pSender);
|
|
|
|
void update(cocos2d::Object *pSender);
|
2013-05-15 17:09:28 +08:00
|
|
|
|
|
|
|
virtual void onError(cocos2d::extension::AssetsManager::ErrorCode errorCode);
|
|
|
|
virtual void onProgress(int percent);
|
|
|
|
virtual void onSuccess();
|
2013-02-22 11:04:09 +08:00
|
|
|
|
|
|
|
private:
|
2013-08-16 18:03:27 +08:00
|
|
|
cocos2d::extension::AssetsManager* pAssetsManager;
|
2013-02-26 16:29:52 +08:00
|
|
|
void createDownloadedDir();
|
2013-02-22 16:02:53 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
cocos2d::MenuItemFont *pItemEnter;
|
|
|
|
cocos2d::MenuItemFont *pItemReset;
|
|
|
|
cocos2d::MenuItemFont *pItemUpdate;
|
|
|
|
cocos2d::LabelTTF *pProgressLabel;
|
2013-02-22 16:02:53 +08:00
|
|
|
std::string pathToSave;
|
|
|
|
bool isUpdateItemClicked;
|
2013-02-22 11:04:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _APP_DELEGATE_H_
|
|
|
|
|