mirror of https://github.com/axmolengine/axmol.git
Merge pull request #2944 from dumganhar/iss2129-format-codes3
issue #2129: Removing CC prefix and renaming member variables for plugin module.
This commit is contained in:
commit
d2199e85a9
|
@ -30,7 +30,7 @@ public:
|
|||
dataVal[1] = std_string_to_jsval(cx, strMsgInfo);
|
||||
dataVal[2] = TProductInfo_to_jsval(cx, info);
|
||||
|
||||
JSObject* obj = m_pJSDelegate;
|
||||
JSObject* obj = _JSDelegate;
|
||||
|
||||
if (JS_HasProperty(cx, obj, "onPayResult", &hasAction) && hasAction) {
|
||||
if(!JS_GetProperty(cx, obj, "onPayResult", &temp_retval)) {
|
||||
|
@ -47,11 +47,11 @@ public:
|
|||
|
||||
void setJSDelegate(JSObject* pJSDelegate)
|
||||
{
|
||||
m_pJSDelegate = pJSDelegate;
|
||||
_JSDelegate = pJSDelegate;
|
||||
}
|
||||
|
||||
private:
|
||||
JSObject* m_pJSDelegate;
|
||||
JSObject* _JSDelegate;
|
||||
};
|
||||
|
||||
JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
std::string strMsgInfo = msg;
|
||||
dataVal[1] = std_string_to_jsval(cx, strMsgInfo);
|
||||
|
||||
JSObject* obj = m_pJSDelegate;
|
||||
JSObject* obj = _JSDelegate;
|
||||
JSBool bRet = JS_HasProperty(cx, obj, "onAdsResult", &hasAction);
|
||||
if (bRet && hasAction) {
|
||||
if(!JS_GetProperty(cx, obj, "onAdsResult", &temp_retval)) {
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
dataVal[0] = arg;
|
||||
dataVal[1] = INT_TO_JSVAL(points);
|
||||
|
||||
JSObject* obj = m_pJSDelegate;
|
||||
JSObject* obj = _JSDelegate;
|
||||
JSBool bRet = JS_HasProperty(cx, obj, "onPlayerGetPoints", &hasAction);
|
||||
if (bRet && hasAction) {
|
||||
if(!JS_GetProperty(cx, obj, "onPlayerGetPoints", &temp_retval)) {
|
||||
|
@ -143,11 +143,11 @@ public:
|
|||
|
||||
void setJSDelegate(JSObject* pJSDelegate)
|
||||
{
|
||||
m_pJSDelegate = pJSDelegate;
|
||||
_JSDelegate = pJSDelegate;
|
||||
}
|
||||
|
||||
private:
|
||||
JSObject* m_pJSDelegate;
|
||||
JSObject* _JSDelegate;
|
||||
};
|
||||
|
||||
JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
|
@ -188,7 +188,7 @@ public:
|
|||
std::string strMsgInfo = msg;
|
||||
dataVal[1] = std_string_to_jsval(cx, strMsgInfo);
|
||||
|
||||
JSObject* obj = m_pJSDelegate;
|
||||
JSObject* obj = _JSDelegate;
|
||||
|
||||
if (JS_HasProperty(cx, obj, "onShareResult", &hasAction) && hasAction) {
|
||||
if(!JS_GetProperty(cx, obj, "onShareResult", &temp_retval)) {
|
||||
|
@ -205,11 +205,11 @@ public:
|
|||
|
||||
void setJSDelegate(JSObject* pJSDelegate)
|
||||
{
|
||||
m_pJSDelegate = pJSDelegate;
|
||||
_JSDelegate = pJSDelegate;
|
||||
}
|
||||
|
||||
private:
|
||||
JSObject* m_pJSDelegate;
|
||||
JSObject* _JSDelegate;
|
||||
};
|
||||
|
||||
JSBool js_pluginx_ProtocolSocial_setResultListener(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
|
|
|
@ -34,15 +34,15 @@ PluginManager::PluginManager(void)
|
|||
|
||||
PluginManager::~PluginManager()
|
||||
{
|
||||
std::map<std::string, PluginProtocol*>::iterator it = m_pluginsMap.begin();
|
||||
for (;it != m_pluginsMap.end();++it)
|
||||
std::map<std::string, PluginProtocol*>::iterator it = _pluginsMap.begin();
|
||||
for (;it != _pluginsMap.end();++it)
|
||||
{
|
||||
if (it->second != NULL) {
|
||||
delete it->second;
|
||||
it->second = NULL;
|
||||
}
|
||||
}
|
||||
m_pluginsMap.clear();
|
||||
_pluginsMap.clear();
|
||||
}
|
||||
|
||||
PluginManager* PluginManager::getInstance()
|
||||
|
@ -70,8 +70,8 @@ PluginProtocol* PluginManager::loadPlugin(const char* name)
|
|||
PluginProtocol* pRet = NULL;
|
||||
do {
|
||||
if (name == NULL || strlen(name) == 0) break;
|
||||
std::map<std::string, PluginProtocol*>::iterator it = m_pluginsMap.find(name);
|
||||
if (it != m_pluginsMap.end())
|
||||
std::map<std::string, PluginProtocol*>::iterator it = _pluginsMap.find(name);
|
||||
if (it != _pluginsMap.end())
|
||||
{
|
||||
if (it->second == NULL) {
|
||||
it->second = PluginFactory::getInstance()->createPlugin(name);
|
||||
|
@ -80,7 +80,7 @@ PluginProtocol* PluginManager::loadPlugin(const char* name)
|
|||
} else
|
||||
{
|
||||
pRet = PluginFactory::getInstance()->createPlugin(name);
|
||||
m_pluginsMap[name] = pRet;
|
||||
_pluginsMap[name] = pRet;
|
||||
}
|
||||
} while (false);
|
||||
|
||||
|
@ -91,8 +91,8 @@ void PluginManager::unloadPlugin(const char* name)
|
|||
{
|
||||
do {
|
||||
if (name == NULL || strlen(name) == 0) break;
|
||||
std::map<std::string, PluginProtocol*>::iterator it = m_pluginsMap.find(name);
|
||||
if (it != m_pluginsMap.end())
|
||||
std::map<std::string, PluginProtocol*>::iterator it = _pluginsMap.find(name);
|
||||
if (it != _pluginsMap.end())
|
||||
{
|
||||
if (it->second != NULL) {
|
||||
delete it->second;
|
||||
|
|
|
@ -28,43 +28,43 @@ namespace cocos2d { namespace plugin {
|
|||
|
||||
PluginParam::PluginParam()
|
||||
{
|
||||
m_type = kParamTypeNull;
|
||||
_type = kParamTypeNull;
|
||||
}
|
||||
|
||||
PluginParam::PluginParam(int nValue)
|
||||
: m_nValue(nValue)
|
||||
: _intValue(nValue)
|
||||
{
|
||||
m_type = kParamTypeInt;
|
||||
_type = kParamTypeInt;
|
||||
}
|
||||
|
||||
PluginParam::PluginParam(float fValue)
|
||||
: m_fValue(fValue)
|
||||
: _floatValue(fValue)
|
||||
{
|
||||
m_type = kParamTypeFloat;
|
||||
_type = kParamTypeFloat;
|
||||
}
|
||||
|
||||
PluginParam::PluginParam(bool bValue)
|
||||
: m_bValue(bValue)
|
||||
: _boolValue(bValue)
|
||||
{
|
||||
m_type = kParamTypeBool;
|
||||
_type = kParamTypeBool;
|
||||
}
|
||||
|
||||
PluginParam::PluginParam(const char* strValue)
|
||||
: m_strValue(strValue)
|
||||
: _strValue(strValue)
|
||||
{
|
||||
m_type = kParamTypeString;
|
||||
_type = kParamTypeString;
|
||||
}
|
||||
|
||||
PluginParam::PluginParam(std::map<std::string, PluginParam*> mapValue)
|
||||
: m_mapValue(mapValue)
|
||||
: _mapValue(mapValue)
|
||||
{
|
||||
m_type = kParamTypeMap;
|
||||
_type = kParamTypeMap;
|
||||
}
|
||||
|
||||
PluginParam::PluginParam(StringMap strMapValue)
|
||||
: m_strMapValue(strMapValue)
|
||||
: _strMapValue(strMapValue)
|
||||
{
|
||||
m_type = kParamTypeStringMap;
|
||||
_type = kParamTypeStringMap;
|
||||
}
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
private:
|
||||
PluginManager(void);
|
||||
std::map<std::string, PluginProtocol*> m_pluginsMap;
|
||||
std::map<std::string, PluginProtocol*> _pluginsMap;
|
||||
};
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
||||
|
|
|
@ -53,31 +53,31 @@ public:
|
|||
} ParamType;
|
||||
|
||||
inline ParamType getCurrentType() {
|
||||
return m_type;
|
||||
return _type;
|
||||
}
|
||||
|
||||
inline int getIntValue() {
|
||||
return m_nValue;
|
||||
return _intValue;
|
||||
}
|
||||
|
||||
inline float getFloatValue() {
|
||||
return m_fValue;
|
||||
return _floatValue;
|
||||
}
|
||||
|
||||
inline bool getBoolValue() {
|
||||
return m_bValue;
|
||||
return _boolValue;
|
||||
}
|
||||
|
||||
inline const char* getStringValue() {
|
||||
return m_strValue.c_str();
|
||||
return _strValue.c_str();
|
||||
}
|
||||
|
||||
inline std::map<std::string, PluginParam*> getMapValue() {
|
||||
return m_mapValue;
|
||||
return _mapValue;
|
||||
}
|
||||
|
||||
inline StringMap getStrMapValue() {
|
||||
return m_strMapValue;
|
||||
return _strMapValue;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -85,14 +85,14 @@ private:
|
|||
PluginParam(std::map<std::string, PluginParam*> mapValue);
|
||||
|
||||
private:
|
||||
ParamType m_type;
|
||||
ParamType _type;
|
||||
|
||||
int m_nValue;
|
||||
float m_fValue;
|
||||
bool m_bValue;
|
||||
std::string m_strValue;
|
||||
std::map<std::string, PluginParam*> m_mapValue;
|
||||
StringMap m_strMapValue;
|
||||
int _intValue;
|
||||
float _floatValue;
|
||||
bool _boolValue;
|
||||
std::string _strValue;
|
||||
std::map<std::string, PluginParam*> _mapValue;
|
||||
StringMap _strMapValue;
|
||||
};
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
/**
|
||||
@brief plug-in info methods(name, version, SDK version)
|
||||
*/
|
||||
inline const char* getPluginName() { return m_pPluginName.c_str(); }
|
||||
inline const char* getPluginName() { return _pluginName.c_str(); }
|
||||
const char* getPluginVersion();
|
||||
const char* getSDKVersion();
|
||||
|
||||
|
@ -74,9 +74,9 @@ protected:
|
|||
private:
|
||||
friend class PluginFactory;
|
||||
inline void setPluginName(const char* name) {
|
||||
m_pPluginName = name;
|
||||
_pluginName = name;
|
||||
}
|
||||
std::string m_pPluginName;
|
||||
std::string _pluginName;
|
||||
};
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
void onPlayerGetPoints(int points);
|
||||
|
||||
protected:
|
||||
AdsListener* m_pListener;
|
||||
AdsListener* _listener;
|
||||
};
|
||||
|
||||
}} // namespace cocos2d { namespace plugin {
|
||||
|
|
|
@ -86,10 +86,10 @@ public:
|
|||
void onPayResult(PayResultCode ret, const char* msg);
|
||||
|
||||
protected:
|
||||
static bool m_bPaying;
|
||||
static bool _paying;
|
||||
|
||||
TProductInfo m_curInfo;
|
||||
PayResultListener* m_pListener;
|
||||
TProductInfo _curInfo;
|
||||
PayResultListener* _listener;
|
||||
};
|
||||
|
||||
}} // namespace cocos2d { namespace plugin {
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
void onShareResult(ShareResultCode ret, const char* msg);
|
||||
|
||||
protected:
|
||||
ShareResultListener* m_pListener;
|
||||
ShareResultListener* _listener;
|
||||
};
|
||||
|
||||
}} // namespace cocos2d { namespace plugin {
|
||||
|
|
|
@ -189,16 +189,16 @@ extern "C"
|
|||
|
||||
namespace cocos2d {
|
||||
|
||||
JavaVM* PluginJniHelper::m_psJavaVM = NULL;
|
||||
JavaVM* PluginJniHelper::_psJavaVM = NULL;
|
||||
|
||||
JavaVM* PluginJniHelper::getJavaVM()
|
||||
{
|
||||
return m_psJavaVM;
|
||||
return _psJavaVM;
|
||||
}
|
||||
|
||||
void PluginJniHelper::setJavaVM(JavaVM *javaVM)
|
||||
{
|
||||
m_psJavaVM = javaVM;
|
||||
_psJavaVM = javaVM;
|
||||
}
|
||||
|
||||
jclass PluginJniHelper::getClassID(const char *className, JNIEnv *env)
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
static std::string jstring2string(jstring str);
|
||||
|
||||
private:
|
||||
static JavaVM *m_psJavaVM;
|
||||
static JavaVM *_psJavaVM;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -100,13 +100,7 @@ public:
|
|||
, funcName
|
||||
, paramCode))
|
||||
{
|
||||
jstring strRet = NULL;
|
||||
if (param != NULL)
|
||||
{
|
||||
strRet = (jstring) t.env->CallObjectMethod(pData->jobj, t.methodID, param);
|
||||
} else {
|
||||
strRet = (jstring) t.env->CallObjectMethod(pData->jobj, t.methodID);
|
||||
}
|
||||
jstring strRet = (jstring)t.env->CallObjectMethod(pData->jobj, t.methodID, param);
|
||||
ret = PluginJniHelper::jstring2string(strRet).c_str();
|
||||
t.env->DeleteLocalRef(t.classID);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
ProtocolAds::ProtocolAds()
|
||||
: m_pListener(NULL)
|
||||
: _listener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -131,24 +131,24 @@ void ProtocolAds::spendPoints(int points)
|
|||
|
||||
void ProtocolAds::setAdsListener(AdsListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
_listener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolAds::onAdsResult(AdsResultCode code, const char* msg)
|
||||
{
|
||||
PluginUtils::outputLog("ProtocolAds", "ProtocolAds::adsResult invoked!");
|
||||
if (m_pListener != NULL)
|
||||
if (_listener != NULL)
|
||||
{
|
||||
m_pListener->onAdsResult(code, msg);
|
||||
_listener->onAdsResult(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolAds::onPlayerGetPoints(int points)
|
||||
{
|
||||
PluginUtils::outputLog("ProtocolAds", "ProtocolAds::onPlayerGetPoints invoked!");
|
||||
if (m_pListener != NULL)
|
||||
if (_listener != NULL)
|
||||
{
|
||||
m_pListener->onPlayerGetPoints(this, points);
|
||||
_listener->onPlayerGetPoints(this, points);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
bool ProtocolIAP::m_bPaying = false;
|
||||
bool ProtocolIAP::_paying = false;
|
||||
|
||||
ProtocolIAP::ProtocolIAP()
|
||||
: m_pListener(NULL)
|
||||
: _listener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ void ProtocolIAP::configDeveloperInfo(TIAPDeveloperInfo devInfo)
|
|||
|
||||
void ProtocolIAP::payForProduct(TProductInfo info)
|
||||
{
|
||||
if (m_bPaying)
|
||||
if (_paying)
|
||||
{
|
||||
PluginUtils::outputLog("ProtocolIAP", "Now is paying");
|
||||
return;
|
||||
|
@ -96,7 +96,7 @@ void ProtocolIAP::payForProduct(TProductInfo info)
|
|||
|
||||
if (info.empty())
|
||||
{
|
||||
if (NULL != m_pListener)
|
||||
if (NULL != _listener)
|
||||
{
|
||||
onPayResult(kPayFail, "Product info error");
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ void ProtocolIAP::payForProduct(TProductInfo info)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_bPaying = true;
|
||||
m_curInfo = info;
|
||||
_paying = true;
|
||||
_curInfo = info;
|
||||
|
||||
PluginJavaData* pData = PluginUtils::getPluginJavaData(this);
|
||||
PluginJniMethodInfo t;
|
||||
|
@ -128,21 +128,21 @@ void ProtocolIAP::payForProduct(TProductInfo info)
|
|||
|
||||
void ProtocolIAP::setResultListener(PayResultListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
_listener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolIAP::onPayResult(PayResultCode ret, const char* msg)
|
||||
{
|
||||
m_bPaying = false;
|
||||
if (m_pListener)
|
||||
_paying = false;
|
||||
if (_listener)
|
||||
{
|
||||
m_pListener->onPayResult(ret, msg, m_curInfo);
|
||||
_listener->onPayResult(ret, msg, _curInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginUtils::outputLog("ProtocolIAP", "Result listener is null!");
|
||||
}
|
||||
m_curInfo.clear();
|
||||
_curInfo.clear();
|
||||
PluginUtils::outputLog("ProtocolIAP", "Pay result is : %d(%s)", (int) ret, msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
ProtocolSocial::ProtocolSocial()
|
||||
: m_pListener(NULL)
|
||||
: _listener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ void ProtocolSocial::share(TShareInfo info)
|
|||
{
|
||||
if (info.empty())
|
||||
{
|
||||
if (NULL != m_pListener)
|
||||
if (NULL != _listener)
|
||||
{
|
||||
onShareResult(kShareFail, "Share info error");
|
||||
}
|
||||
|
@ -117,14 +117,14 @@ void ProtocolSocial::share(TShareInfo info)
|
|||
|
||||
void ProtocolSocial::setResultListener(ShareResultListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
_listener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolSocial::onShareResult(ShareResultCode ret, const char* msg)
|
||||
{
|
||||
if (m_pListener)
|
||||
if (_listener)
|
||||
{
|
||||
m_pListener->onShareResult(ret, msg);
|
||||
_listener->onShareResult(ret, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
namespace cocos2d { namespace plugin {
|
||||
|
||||
ProtocolAds::ProtocolAds()
|
||||
: m_pListener(NULL)
|
||||
: _listener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -97,22 +97,22 @@ void ProtocolAds::spendPoints(int points)
|
|||
// For the callbak methods
|
||||
void ProtocolAds::setAdsListener(AdsListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
_listener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolAds::onAdsResult(AdsResultCode code, const char* msg)
|
||||
{
|
||||
if (m_pListener != NULL)
|
||||
if (_listener != NULL)
|
||||
{
|
||||
m_pListener->onAdsResult(code, msg);
|
||||
_listener->onAdsResult(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolAds::onPlayerGetPoints(int points)
|
||||
{
|
||||
if (m_pListener != NULL)
|
||||
if (_listener != NULL)
|
||||
{
|
||||
m_pListener->onPlayerGetPoints(this, points);
|
||||
_listener->onPlayerGetPoints(this, points);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
bool ProtocolIAP::m_bPaying = false;
|
||||
bool ProtocolIAP::_paying = false;
|
||||
|
||||
ProtocolIAP::ProtocolIAP()
|
||||
: m_pListener(NULL)
|
||||
: _listener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ void ProtocolIAP::configDeveloperInfo(TIAPDeveloperInfo devInfo)
|
|||
|
||||
void ProtocolIAP::payForProduct(TProductInfo info)
|
||||
{
|
||||
if (m_bPaying)
|
||||
if (_paying)
|
||||
{
|
||||
PluginUtilsIOS::outputLog("Now is paying");
|
||||
return;
|
||||
|
@ -70,7 +70,7 @@ void ProtocolIAP::payForProduct(TProductInfo info)
|
|||
|
||||
if (info.empty())
|
||||
{
|
||||
if (NULL != m_pListener)
|
||||
if (NULL != _listener)
|
||||
{
|
||||
onPayResult(kPayFail, "Product info error");
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ void ProtocolIAP::payForProduct(TProductInfo info)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_bPaying = true;
|
||||
m_curInfo = info;
|
||||
_paying = true;
|
||||
_curInfo = info;
|
||||
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
assert(pData != NULL);
|
||||
|
@ -96,22 +96,22 @@ void ProtocolIAP::payForProduct(TProductInfo info)
|
|||
|
||||
void ProtocolIAP::setResultListener(PayResultListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
_listener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolIAP::onPayResult(PayResultCode ret, const char* msg)
|
||||
{
|
||||
m_bPaying = false;
|
||||
if (m_pListener)
|
||||
_paying = false;
|
||||
if (_listener)
|
||||
{
|
||||
m_pListener->onPayResult(ret, msg, m_curInfo);
|
||||
_listener->onPayResult(ret, msg, _curInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginUtilsIOS::outputLog("Pay result listener of %s is null!", this->getPluginName());
|
||||
}
|
||||
|
||||
m_curInfo.clear();
|
||||
_curInfo.clear();
|
||||
PluginUtilsIOS::outputLog("Pay result of %s is : %d(%s)", this->getPluginName(), (int) ret, msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ THE SOFTWARE.
|
|||
namespace cocos2d { namespace plugin {
|
||||
|
||||
ProtocolSocial::ProtocolSocial()
|
||||
: m_pListener(NULL)
|
||||
: _listener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ void ProtocolSocial::share(TShareInfo info)
|
|||
{
|
||||
if (info.empty())
|
||||
{
|
||||
if (NULL != m_pListener)
|
||||
if (NULL != _listener)
|
||||
{
|
||||
onShareResult(kShareFail, "Share info error");
|
||||
}
|
||||
|
@ -84,14 +84,14 @@ void ProtocolSocial::share(TShareInfo info)
|
|||
|
||||
void ProtocolSocial::setResultListener(ShareResultListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
_listener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolSocial::onShareResult(ShareResultCode ret, const char* msg)
|
||||
{
|
||||
if (m_pListener)
|
||||
if (_listener)
|
||||
{
|
||||
m_pListener->onShareResult(ret, msg);
|
||||
_listener->onShareResult(ret, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -36,8 +36,8 @@ AppDelegate::~AppDelegate()
|
|||
|
||||
bool AppDelegate::applicationDidFinishLaunching() {
|
||||
// initialize director
|
||||
CCDirector* pDirector = CCDirector::sharedDirector();
|
||||
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
|
||||
Director* pDirector = Director::sharedDirector();
|
||||
EGLView* pEGLView = EGLView::sharedOpenGLView();
|
||||
|
||||
pDirector->setOpenGLView(pEGLView);
|
||||
|
||||
|
@ -50,7 +50,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
|||
pDirector->setAnimationInterval(1.0 / 60);
|
||||
|
||||
// create a scene. it's an autorelease object
|
||||
CCScene *pScene = HelloWorld::scene();
|
||||
Scene *pScene = HelloWorld::scene();
|
||||
|
||||
// run
|
||||
pDirector->runWithScene(pScene);
|
||||
|
@ -60,7 +60,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
|||
|
||||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||
void AppDelegate::applicationDidEnterBackground() {
|
||||
CCDirector::sharedDirector()->stopAnimation();
|
||||
Director::sharedDirector()->stopAnimation();
|
||||
|
||||
// if you use SimpleAudioEngine, it must be pause
|
||||
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||
|
@ -68,7 +68,7 @@ void AppDelegate::applicationDidEnterBackground() {
|
|||
|
||||
// this function will be called when the app is active again
|
||||
void AppDelegate::applicationWillEnterForeground() {
|
||||
CCDirector::sharedDirector()->startAnimation();
|
||||
Director::sharedDirector()->startAnimation();
|
||||
|
||||
// if you use SimpleAudioEngine, it must resume here
|
||||
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
||||
|
|
|
@ -29,16 +29,16 @@ THE SOFTWARE.
|
|||
/**
|
||||
@brief The cocos2d Application.
|
||||
|
||||
The reason for implement as private inheritance is to hide some interface call by CCDirector.
|
||||
The reason for implement as private inheritance is to hide some interface call by Director.
|
||||
*/
|
||||
class AppDelegate : private cocos2d::CCApplication
|
||||
class AppDelegate : private cocos2d::Application
|
||||
{
|
||||
public:
|
||||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
@return false Initialize failed, app terminate.
|
||||
*/
|
||||
|
|
|
@ -47,10 +47,10 @@ const std::string s_aTestPoses[] = {
|
|||
"Pos: BottomRight",
|
||||
};
|
||||
|
||||
CCScene* HelloWorld::scene()
|
||||
Scene* HelloWorld::scene()
|
||||
{
|
||||
// 'scene' is an autorelease object
|
||||
CCScene *scene = CCScene::create();
|
||||
Scene *scene = Scene::create();
|
||||
|
||||
// 'layer' is an autorelease object
|
||||
HelloWorld *layer = HelloWorld::create();
|
||||
|
@ -67,12 +67,12 @@ bool HelloWorld::init()
|
|||
{
|
||||
//////////////////////////////
|
||||
// 1. super init first
|
||||
if ( !CCLayer::init() )
|
||||
if ( !Layer::init() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pAdmob = dynamic_cast<ProtocolAds*>(PluginManager::getInstance()->loadPlugin("AdsAdmob"));
|
||||
_admob = dynamic_cast<ProtocolAds*>(PluginManager::getInstance()->loadPlugin("AdsAdmob"));
|
||||
TAdsDeveloperInfo devInfo;
|
||||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS
|
||||
|
@ -81,21 +81,21 @@ bool HelloWorld::init()
|
|||
devInfo["AdmobID"] = "a1516fb6b16b12f";
|
||||
#endif
|
||||
|
||||
m_pAdmob->configDeveloperInfo(devInfo);
|
||||
m_pListener = new MyAdsListener();
|
||||
m_pAdmob->setAdsListener(m_pListener);
|
||||
m_pAdmob->setDebugMode(true);
|
||||
_admob->configDeveloperInfo(devInfo);
|
||||
_listener = new MyAdsListener();
|
||||
_admob->setAdsListener(_listener);
|
||||
_admob->setDebugMode(true);
|
||||
|
||||
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
|
||||
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
|
||||
CCPoint posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
|
||||
Size visibleSize = Director::sharedDirector()->getVisibleSize();
|
||||
Point origin = Director::sharedDirector()->getVisibleOrigin();
|
||||
Point posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
|
||||
|
||||
/////////////////////////////
|
||||
// 2. add a menu item with "X" image, which is clicked to quit the program
|
||||
// you may modify it.
|
||||
|
||||
// add a "close" icon to exit the progress. it's an autorelease object
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
|
||||
MenuItemImage *pCloseItem = MenuItemImage::create(
|
||||
"CloseNormal.png",
|
||||
"CloseSelected.png",
|
||||
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
|
||||
|
@ -104,101 +104,101 @@ bool HelloWorld::init()
|
|||
origin.y + pCloseItem->getContentSize().height/2));
|
||||
|
||||
// create menu, it's an autorelease object
|
||||
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
|
||||
pMenu->setPosition(CCPointZero);
|
||||
Menu* pMenu = Menu::create(pCloseItem, NULL);
|
||||
pMenu->setPosition(PointZero);
|
||||
|
||||
CCLabelTTF* label1 = CCLabelTTF::create("ShowAds", "Arial", 24);
|
||||
CCMenuItemLabel* pItemShow = CCMenuItemLabel::create(label1, CC_CALLBACK_1(HelloWorld::testShow, this));
|
||||
LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24);
|
||||
MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(HelloWorld::testShow, this));
|
||||
pItemShow->setAnchorPoint(ccp(0.5f, 0));
|
||||
pMenu->addChild(pItemShow, 0);
|
||||
pItemShow->setPosition(ccpAdd(posMid, ccp(-100, -120)));
|
||||
|
||||
CCLabelTTF* label2 = CCLabelTTF::create("HideAds", "Arial", 24);
|
||||
CCMenuItemLabel* pItemHide = CCMenuItemLabel::create(label2, CC_CALLBACK_1(HelloWorld::testHide, this));
|
||||
LabelTTF* label2 = LabelTTF::create("HideAds", "Arial", 24);
|
||||
MenuItemLabel* pItemHide = MenuItemLabel::create(label2, CC_CALLBACK_1(HelloWorld::testHide, this));
|
||||
pItemHide->setAnchorPoint(ccp(0.5f, 0));
|
||||
pMenu->addChild(pItemHide, 0);
|
||||
pItemHide->setPosition(ccpAdd(posMid, ccp(100, -120)));
|
||||
|
||||
// create optional menu
|
||||
// cases item
|
||||
m_pCaseItem = CCMenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::caseChanged, this),
|
||||
CCMenuItemFont::create( s_aTestCases[0].c_str() ),
|
||||
_caseItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::caseChanged, this),
|
||||
MenuItemFont::create( s_aTestCases[0].c_str() ),
|
||||
NULL );
|
||||
int caseLen = sizeof(s_aTestCases) / sizeof(std::string);
|
||||
for (int i = 1; i < caseLen; ++i)
|
||||
{
|
||||
m_pCaseItem->getSubItems()->addObject( CCMenuItemFont::create( s_aTestCases[i].c_str() ) );
|
||||
_caseItem->getSubItems()->addObject( MenuItemFont::create( s_aTestCases[i].c_str() ) );
|
||||
}
|
||||
m_pCaseItem->setPosition(ccpAdd(posMid, ccp(-200, 120)));
|
||||
pMenu->addChild(m_pCaseItem);
|
||||
_caseItem->setPosition(ccpAdd(posMid, ccp(-200, 120)));
|
||||
pMenu->addChild(_caseItem);
|
||||
|
||||
// type item
|
||||
m_pTypeItem = CCMenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::typeChanged, this),
|
||||
CCMenuItemFont::create( s_aTestTypes[0].c_str() ),
|
||||
_typeItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::typeChanged, this),
|
||||
MenuItemFont::create( s_aTestTypes[0].c_str() ),
|
||||
NULL );
|
||||
int typeLen = sizeof(s_aTestTypes) / sizeof(std::string);
|
||||
for (int i = 1; i < typeLen; ++i)
|
||||
{
|
||||
m_pTypeItem->getSubItems()->addObject( CCMenuItemFont::create( s_aTestTypes[i].c_str() ) );
|
||||
_typeItem->getSubItems()->addObject( MenuItemFont::create( s_aTestTypes[i].c_str() ) );
|
||||
}
|
||||
m_pTypeItem->setPosition(ccpAdd(posMid, ccp(0, 120)));
|
||||
pMenu->addChild(m_pTypeItem);
|
||||
_typeItem->setPosition(ccpAdd(posMid, ccp(0, 120)));
|
||||
pMenu->addChild(_typeItem);
|
||||
|
||||
// poses item
|
||||
m_pPosItem = CCMenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::posChanged, this),
|
||||
CCMenuItemFont::create( s_aTestPoses[0].c_str() ),
|
||||
_posItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::posChanged, this),
|
||||
MenuItemFont::create( s_aTestPoses[0].c_str() ),
|
||||
NULL );
|
||||
int posLen = sizeof(s_aTestPoses) / sizeof(std::string);
|
||||
for (int i = 1; i < posLen; ++i)
|
||||
{
|
||||
m_pPosItem->getSubItems()->addObject( CCMenuItemFont::create( s_aTestPoses[i].c_str() ) );
|
||||
_posItem->getSubItems()->addObject( MenuItemFont::create( s_aTestPoses[i].c_str() ) );
|
||||
}
|
||||
m_pPosItem->setPosition(ccpAdd(posMid, ccp(200, 120)));
|
||||
pMenu->addChild(m_pPosItem);
|
||||
_posItem->setPosition(ccpAdd(posMid, ccp(200, 120)));
|
||||
pMenu->addChild(_posItem);
|
||||
|
||||
// init options
|
||||
m_pAds = m_pAdmob;
|
||||
m_ePos = ProtocolAds::kPosCenter;
|
||||
m_eType = ProtocolAds::kBannerAd;
|
||||
_ads = _admob;
|
||||
_pos = ProtocolAds::kPosCenter;
|
||||
_type = ProtocolAds::kBannerAd;
|
||||
|
||||
this->addChild(pMenu, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void HelloWorld::testShow(CCObject* pSender)
|
||||
void HelloWorld::testShow(Object* pSender)
|
||||
{
|
||||
int nSize = 0;
|
||||
if (m_pAds == m_pAdmob)
|
||||
if (_ads == _admob)
|
||||
{
|
||||
nSize = 0;
|
||||
}
|
||||
|
||||
if (m_pAds)
|
||||
if (_ads)
|
||||
{
|
||||
m_pAds->showAds(m_eType, nSize, m_ePos);
|
||||
_ads->showAds(_type, nSize, _pos);
|
||||
}
|
||||
}
|
||||
|
||||
void HelloWorld::testHide(CCObject* pSender)
|
||||
void HelloWorld::testHide(Object* pSender)
|
||||
{
|
||||
m_pAds->hideAds(m_eType);
|
||||
_ads->hideAds(_type);
|
||||
}
|
||||
|
||||
void HelloWorld::menuCloseCallback(CCObject* pSender)
|
||||
void HelloWorld::menuCloseCallback(Object* pSender)
|
||||
{
|
||||
CCDirector::sharedDirector()->end();
|
||||
Director::sharedDirector()->end();
|
||||
|
||||
if (m_pAdmob != NULL)
|
||||
if (_admob != NULL)
|
||||
{
|
||||
PluginManager::getInstance()->unloadPlugin("AdsAdmob");
|
||||
m_pAdmob = NULL;
|
||||
_admob = NULL;
|
||||
}
|
||||
|
||||
if (NULL != m_pListener)
|
||||
if (NULL != _listener)
|
||||
{
|
||||
delete m_pListener;
|
||||
m_pListener = NULL;
|
||||
delete _listener;
|
||||
_listener = NULL;
|
||||
}
|
||||
|
||||
PluginManager::end();
|
||||
|
@ -207,13 +207,13 @@ void HelloWorld::menuCloseCallback(CCObject* pSender)
|
|||
#endif
|
||||
}
|
||||
|
||||
void HelloWorld::caseChanged(CCObject* pSender)
|
||||
void HelloWorld::caseChanged(Object* pSender)
|
||||
{
|
||||
std::string strLog = "";
|
||||
switch (m_pCaseItem->getSelectedIndex())
|
||||
switch (_caseItem->getSelectedIndex())
|
||||
{
|
||||
case 0:
|
||||
m_pAds = m_pAdmob;
|
||||
_ads = _admob;
|
||||
strLog = "Admob";
|
||||
break;
|
||||
default:
|
||||
|
@ -222,18 +222,18 @@ void HelloWorld::caseChanged(CCObject* pSender)
|
|||
CCLog("case selected change to : %s", strLog.c_str());
|
||||
}
|
||||
|
||||
void HelloWorld::typeChanged(CCObject* pSender)
|
||||
void HelloWorld::typeChanged(Object* pSender)
|
||||
{
|
||||
int selectIndex = m_pTypeItem->getSelectedIndex();
|
||||
m_eType = (ProtocolAds::AdsType) selectIndex;
|
||||
CCLog("type selected change to : %d", m_eType);
|
||||
int selectIndex = _typeItem->getSelectedIndex();
|
||||
_type = (ProtocolAds::AdsType) selectIndex;
|
||||
CCLog("type selected change to : %d", _type);
|
||||
}
|
||||
|
||||
void HelloWorld::posChanged(CCObject* pSender)
|
||||
void HelloWorld::posChanged(Object* pSender)
|
||||
{
|
||||
int selectIndex = m_pPosItem->getSelectedIndex();
|
||||
m_ePos = (ProtocolAds::AdsPos) selectIndex;
|
||||
CCLog("pos selected change to : %d", m_ePos);
|
||||
int selectIndex = _posItem->getSelectedIndex();
|
||||
_pos = (ProtocolAds::AdsPos) selectIndex;
|
||||
CCLog("pos selected change to : %d", _pos);
|
||||
}
|
||||
|
||||
void MyAdsListener::onAdsResult(AdsResultCode code, const char* msg)
|
||||
|
|
|
@ -34,39 +34,39 @@ public:
|
|||
virtual void onPlayerGetPoints(cocos2d::plugin::ProtocolAds* pAdsPlugin, int points);
|
||||
};
|
||||
|
||||
class HelloWorld : public cocos2d::CCLayer
|
||||
class HelloWorld : public cocos2d::Layer
|
||||
{
|
||||
public:
|
||||
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
|
||||
virtual bool init();
|
||||
|
||||
// there's no 'id' in cpp, so we recommend returning the class instance pointer
|
||||
static cocos2d::CCScene* scene();
|
||||
static cocos2d::Scene* scene();
|
||||
|
||||
// a selector callback
|
||||
void menuCloseCallback(CCObject* pSender);
|
||||
void testShow(CCObject* pSender);
|
||||
void testHide(CCObject* pSender);
|
||||
void menuCloseCallback(Object* pSender);
|
||||
void testShow(Object* pSender);
|
||||
void testHide(Object* pSender);
|
||||
|
||||
// option changed callback
|
||||
void caseChanged(CCObject* pSender);
|
||||
void posChanged(CCObject* pSender);
|
||||
void typeChanged(CCObject* pSender);
|
||||
void caseChanged(Object* pSender);
|
||||
void posChanged(Object* pSender);
|
||||
void typeChanged(Object* pSender);
|
||||
|
||||
// implement the "static node()" method manually
|
||||
CREATE_FUNC(HelloWorld);
|
||||
|
||||
private:
|
||||
cocos2d::plugin::ProtocolAds* m_pAdmob;
|
||||
MyAdsListener* m_pListener;
|
||||
cocos2d::plugin::ProtocolAds* _admob;
|
||||
MyAdsListener* _listener;
|
||||
|
||||
cocos2d::CCMenuItemToggle* m_pCaseItem;
|
||||
cocos2d::CCMenuItemToggle* m_pTypeItem;
|
||||
cocos2d::CCMenuItemToggle* m_pPosItem;
|
||||
cocos2d::MenuItemToggle* _caseItem;
|
||||
cocos2d::MenuItemToggle* _typeItem;
|
||||
cocos2d::MenuItemToggle* _posItem;
|
||||
|
||||
cocos2d::plugin::ProtocolAds* m_pAds;
|
||||
cocos2d::plugin::ProtocolAds::AdsPos m_ePos;
|
||||
cocos2d::plugin::ProtocolAds::AdsType m_eType;
|
||||
cocos2d::plugin::ProtocolAds* _ads;
|
||||
cocos2d::plugin::ProtocolAds::AdsPos _pos;
|
||||
cocos2d::plugin::ProtocolAds::AdsType _type;
|
||||
};
|
||||
|
||||
#endif // __HELLOWORLD_SCENE_H__
|
||||
|
|
|
@ -23,23 +23,23 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
|||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||
if (!Director::sharedDirector()->getOpenGLView())
|
||||
{
|
||||
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||
EGLView *view = EGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication()->run();
|
||||
Application::sharedApplication()->run();
|
||||
}
|
||||
else
|
||||
{
|
||||
ccDrawInit();
|
||||
ccGLInvalidateStateCache();
|
||||
|
||||
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
CCTextureCache::reloadAllTextures();
|
||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
TextureCache::reloadAllTextures();
|
||||
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
Director::sharedDirector()->setGLDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ static AppDelegate s_sharedApplication;
|
|||
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:true];
|
||||
|
||||
cocos2d::CCApplication::sharedApplication()->run();
|
||||
cocos2d::Application::sharedApplication()->run();
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
@ -60,14 +60,14 @@ static AppDelegate s_sharedApplication;
|
|||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
*/
|
||||
cocos2d::CCDirector::sharedDirector()->pause();
|
||||
cocos2d::Director::sharedDirector()->pause();
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
/*
|
||||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
*/
|
||||
cocos2d::CCDirector::sharedDirector()->resume();
|
||||
cocos2d::Director::sharedDirector()->resume();
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
|
@ -75,14 +75,14 @@ static AppDelegate s_sharedApplication;
|
|||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||
*/
|
||||
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||
cocos2d::Application::sharedApplication()->applicationDidEnterBackground();
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
/*
|
||||
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
|
||||
*/
|
||||
cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||
cocos2d::Application::sharedApplication()->applicationWillEnterForeground();
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
|
|
|
@ -23,14 +23,14 @@ AppDelegate::AppDelegate()
|
|||
|
||||
AppDelegate::~AppDelegate()
|
||||
{
|
||||
CCScriptEngineManager::purgeSharedManager();
|
||||
ScriptEngineManager::purgeSharedManager();
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||
Director *pDirector = Director::sharedDirector();
|
||||
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
|
||||
|
||||
// turn on display FPS
|
||||
pDirector->setDisplayStats(true);
|
||||
|
@ -50,8 +50,8 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
sc->addRegisterCallback(register_pluginx_js_extensions);
|
||||
sc->start();
|
||||
CCLOG("applicationDidFinishLaunching 02");
|
||||
CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
|
||||
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||
ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
|
||||
ScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||
ScriptingCore::getInstance()->runScript("main.js");
|
||||
CCLOG("applicationDidFinishLaunching 03");
|
||||
return true;
|
||||
|
@ -60,7 +60,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||
void AppDelegate::applicationDidEnterBackground()
|
||||
{
|
||||
CCDirector::sharedDirector()->stopAnimation();
|
||||
Director::sharedDirector()->stopAnimation();
|
||||
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
|
||||
|
||||
|
@ -75,7 +75,7 @@ void AppDelegate::applicationDidEnterBackground()
|
|||
// this function will be called when the app is active again
|
||||
void AppDelegate::applicationWillEnterForeground()
|
||||
{
|
||||
CCDirector::sharedDirector()->startAnimation();
|
||||
Director::sharedDirector()->startAnimation();
|
||||
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
||||
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
|
||||
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
/**
|
||||
@brief The cocos2d Application.
|
||||
|
||||
The reason for implement as private inheritance is to hide some interface call by CCDirector.
|
||||
The reason for implement as private inheritance is to hide some interface call by Director.
|
||||
*/
|
||||
class AppDelegate : private cocos2d::CCApplication
|
||||
class AppDelegate : private cocos2d::Application
|
||||
{
|
||||
public:
|
||||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
@return false Initialize failed, app terminate.
|
||||
*/
|
||||
|
|
|
@ -24,23 +24,23 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
|||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||
if (!Director::sharedDirector()->getOpenGLView())
|
||||
{
|
||||
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||
EGLView *view = EGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication()->run();
|
||||
Application::sharedApplication()->run();
|
||||
}
|
||||
else
|
||||
{
|
||||
ccDrawInit();
|
||||
ccGLInvalidateStateCache();
|
||||
|
||||
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
CCTextureCache::reloadAllTextures();
|
||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
TextureCache::reloadAllTextures();
|
||||
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
Director::sharedDirector()->setGLDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ AppDelegate::~AppDelegate()
|
|||
void AppDelegate::loadAnalyticsPlugin()
|
||||
{
|
||||
PluginProtocol* pPlugin = NULL;
|
||||
ccLanguageType langType = CCApplication::sharedApplication()->getCurrentLanguage();
|
||||
ccLanguageType langType = Application::sharedApplication()->getCurrentLanguage();
|
||||
|
||||
std::string umengKey = "";
|
||||
std::string flurryKey = "";
|
||||
|
@ -113,8 +113,8 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
g_pAnalytics->callFuncWithParam("setUseHttps", &pParam6, NULL);
|
||||
|
||||
// initialize director
|
||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||
Director *pDirector = Director::sharedDirector();
|
||||
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
|
||||
|
||||
// turn on display FPS
|
||||
//pDirector->setDisplayStats(true);
|
||||
|
@ -123,7 +123,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
pDirector->setAnimationInterval(1.0 / 60);
|
||||
|
||||
// create a scene. it's an autorelease object
|
||||
CCScene *pScene = HelloWorld::scene();
|
||||
Scene *pScene = HelloWorld::scene();
|
||||
|
||||
// run
|
||||
pDirector->runWithScene(pScene);
|
||||
|
@ -134,7 +134,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||
void AppDelegate::applicationDidEnterBackground()
|
||||
{
|
||||
CCDirector::sharedDirector()->pause();
|
||||
Director::sharedDirector()->pause();
|
||||
|
||||
// if you use SimpleAudioEngine, it must be pause
|
||||
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||
|
@ -144,7 +144,7 @@ void AppDelegate::applicationDidEnterBackground()
|
|||
// this function will be called when the app is active again
|
||||
void AppDelegate::applicationWillEnterForeground()
|
||||
{
|
||||
CCDirector::sharedDirector()->resume();
|
||||
Director::sharedDirector()->resume();
|
||||
if (g_pAnalytics)
|
||||
{
|
||||
g_pAnalytics->startSession(s_strAppKey.c_str());
|
||||
|
|
|
@ -29,16 +29,16 @@ THE SOFTWARE.
|
|||
/**
|
||||
@brief The cocos2d Application.
|
||||
|
||||
The reason for implement as private inheritance is to hide some interface call by CCDirector.
|
||||
The reason for implement as private inheritance is to hide some interface call by Director.
|
||||
*/
|
||||
class AppDelegate : private cocos2d::CCApplication
|
||||
class AppDelegate : private cocos2d::Application
|
||||
{
|
||||
public:
|
||||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
@return false Initialize failed, app terminate.
|
||||
*/
|
||||
|
|
|
@ -57,10 +57,10 @@ static EventMenuItem s_EventMenuItem[] = {
|
|||
{"MakeMeCrash", TAG_MAKE_ME_CRASH}
|
||||
};
|
||||
|
||||
CCScene* HelloWorld::scene()
|
||||
Scene* HelloWorld::scene()
|
||||
{
|
||||
// 'scene' is an autorelease object
|
||||
CCScene *scene = CCScene::create();
|
||||
Scene *scene = Scene::create();
|
||||
|
||||
// 'layer' is an autorelease object
|
||||
HelloWorld *layer = HelloWorld::create();
|
||||
|
@ -77,19 +77,19 @@ bool HelloWorld::init()
|
|||
{
|
||||
//////////////////////////////
|
||||
// 1. super init first
|
||||
if ( !CCLayer::init() )
|
||||
if ( !Layer::init() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
Size size = Director::sharedDirector()->getWinSize();
|
||||
|
||||
/////////////////////////////
|
||||
// 2. add a menu item with "X" image, which is clicked to quit the program
|
||||
// you may modify it.
|
||||
|
||||
// add a "close" icon to exit the progress. it's an autorelease object
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
|
||||
MenuItemImage *pCloseItem = MenuItemImage::create(
|
||||
"CloseNormal.png",
|
||||
"CloseSelected.png",
|
||||
this,
|
||||
|
@ -97,14 +97,14 @@ bool HelloWorld::init()
|
|||
pCloseItem->setPosition( ccp(size.width - 20, 20) );
|
||||
|
||||
// create menu, it's an autorelease object
|
||||
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
|
||||
pMenu->setPosition( CCPointZero );
|
||||
Menu* pMenu = Menu::create(pCloseItem, NULL);
|
||||
pMenu->setPosition( PointZero );
|
||||
this->addChild(pMenu, 1);
|
||||
|
||||
float yPos = 0;
|
||||
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
|
||||
CCLabelTTF* label = CCLabelTTF::create(s_EventMenuItem[i].id.c_str(), "Arial", 24);
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(HelloWorld::eventMenuCallback));
|
||||
LabelTTF* label = LabelTTF::create(s_EventMenuItem[i].id.c_str(), "Arial", 24);
|
||||
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::eventMenuCallback));
|
||||
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
|
||||
yPos = size.height - 35*i - 100;
|
||||
pMenuItem->setPosition( ccp(size.width / 2, yPos));
|
||||
|
@ -114,12 +114,12 @@ bool HelloWorld::init()
|
|||
std::string strVer = g_pAnalytics->getSDKVersion();
|
||||
char ret[256] = { 0 };
|
||||
sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str());
|
||||
CCLabelTTF* pLabel = CCLabelTTF::create(ret, "Arial", 18, CCSizeMake(size.width, 0), kCCTextAlignmentCenter);
|
||||
LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, CCSizeMake(size.width, 0), kTextAlignmentCenter);
|
||||
pLabel->setPosition(ccp(size.width / 2, yPos - 80));
|
||||
addChild(pLabel);
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create("reload all plugins", "Arial", 24);
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
|
||||
LabelTTF* label = LabelTTF::create("reload all plugins", "Arial", 24);
|
||||
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
|
||||
pMenuItem->setAnchorPoint(ccp(0.5f, 0));
|
||||
pMenu->addChild(pMenuItem, 0);
|
||||
pMenuItem->setPosition( ccp(size.width / 2, 0));
|
||||
|
@ -127,7 +127,7 @@ bool HelloWorld::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void HelloWorld::reloadPluginMenuCallback(CCObject* pSender)
|
||||
void HelloWorld::reloadPluginMenuCallback(Object* pSender)
|
||||
{
|
||||
PluginManager::getInstance()->unloadPlugin("AnalyticsFlurry");
|
||||
PluginManager::getInstance()->unloadPlugin("AnalyticsUmeng");
|
||||
|
@ -135,9 +135,9 @@ void HelloWorld::reloadPluginMenuCallback(CCObject* pSender)
|
|||
AppDelegate::loadAnalyticsPlugin();
|
||||
}
|
||||
|
||||
void HelloWorld::eventMenuCallback(CCObject* pSender)
|
||||
void HelloWorld::eventMenuCallback(Object* pSender)
|
||||
{
|
||||
CCMenuItemLabel* pMenuItem = (CCMenuItemLabel*)pSender;
|
||||
MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender;
|
||||
|
||||
switch (pMenuItem->getTag())
|
||||
{
|
||||
|
@ -228,13 +228,13 @@ void HelloWorld::eventMenuCallback(CCObject* pSender)
|
|||
}
|
||||
}
|
||||
|
||||
void HelloWorld::menuCloseCallback(CCObject* pSender)
|
||||
void HelloWorld::menuCloseCallback(Object* pSender)
|
||||
{
|
||||
if (g_pAnalytics)
|
||||
g_pAnalytics->stopSession();
|
||||
|
||||
PluginManager::end();
|
||||
CCDirector::sharedDirector()->end();
|
||||
Director::sharedDirector()->end();
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
exit(0);
|
||||
#endif
|
||||
|
|
|
@ -26,19 +26,19 @@ THE SOFTWARE.
|
|||
|
||||
#include "cocos2d.h"
|
||||
|
||||
class HelloWorld : public cocos2d::CCLayer
|
||||
class HelloWorld : public cocos2d::Layer
|
||||
{
|
||||
public:
|
||||
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
|
||||
virtual bool init();
|
||||
|
||||
// there's no 'id' in cpp, so we recommand to return the exactly class pointer
|
||||
static cocos2d::CCScene* scene();
|
||||
static cocos2d::Scene* scene();
|
||||
|
||||
// a selector callback
|
||||
void menuCloseCallback(CCObject* pSender);
|
||||
void eventMenuCallback(CCObject* pSender);
|
||||
void reloadPluginMenuCallback(CCObject* pSender);
|
||||
void menuCloseCallback(Object* pSender);
|
||||
void eventMenuCallback(Object* pSender);
|
||||
void reloadPluginMenuCallback(Object* pSender);
|
||||
|
||||
// implement the "static node()" method manually
|
||||
CREATE_FUNC(HelloWorld);
|
||||
|
|
|
@ -24,23 +24,23 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
|||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||
if (!Director::sharedDirector()->getOpenGLView())
|
||||
{
|
||||
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||
EGLView *view = EGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication()->run();
|
||||
Application::sharedApplication()->run();
|
||||
}
|
||||
else
|
||||
{
|
||||
ccDrawInit();
|
||||
ccGLInvalidateStateCache();
|
||||
|
||||
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
CCTextureCache::reloadAllTextures();
|
||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
TextureCache::reloadAllTextures();
|
||||
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
Director::sharedDirector()->setGLDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ static AppDelegate s_sharedApplication;
|
|||
|
||||
[[UIApplication sharedApplication] setStatusBarHidden: YES];
|
||||
|
||||
cocos2d::CCApplication::sharedApplication()->run();
|
||||
cocos2d::Application::sharedApplication()->run();
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -82,14 +82,14 @@ static AppDelegate s_sharedApplication;
|
|||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
*/
|
||||
cocos2d::CCDirector::sharedDirector()->pause();
|
||||
cocos2d::Director::sharedDirector()->pause();
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
/*
|
||||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
*/
|
||||
cocos2d::CCDirector::sharedDirector()->resume();
|
||||
cocos2d::Director::sharedDirector()->resume();
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
|
@ -97,14 +97,14 @@ static AppDelegate s_sharedApplication;
|
|||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||
*/
|
||||
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||
cocos2d::Application::sharedApplication()->applicationDidEnterBackground();
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
/*
|
||||
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
|
||||
*/
|
||||
cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||
cocos2d::Application::sharedApplication()->applicationWillEnterForeground();
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
|
|
|
@ -23,14 +23,14 @@ AppDelegate::AppDelegate()
|
|||
|
||||
AppDelegate::~AppDelegate()
|
||||
{
|
||||
CCScriptEngineManager::purgeSharedManager();
|
||||
ScriptEngineManager::purgeSharedManager();
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// initialize director
|
||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||
Director *pDirector = Director::sharedDirector();
|
||||
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
|
||||
|
||||
// turn on display FPS
|
||||
pDirector->setDisplayStats(true);
|
||||
|
@ -52,8 +52,8 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
|
||||
sc->start();
|
||||
|
||||
CCScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
|
||||
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||
ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
|
||||
ScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||
ScriptingCore::getInstance()->runScript("main.js");
|
||||
|
||||
return true;
|
||||
|
@ -62,7 +62,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||
void AppDelegate::applicationDidEnterBackground()
|
||||
{
|
||||
CCDirector::sharedDirector()->stopAnimation();
|
||||
Director::sharedDirector()->stopAnimation();
|
||||
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ void AppDelegate::applicationDidEnterBackground()
|
|||
// this function will be called when the app is active again
|
||||
void AppDelegate::applicationWillEnterForeground()
|
||||
{
|
||||
CCDirector::sharedDirector()->startAnimation();
|
||||
Director::sharedDirector()->startAnimation();
|
||||
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
||||
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
|
||||
}
|
||||
|
|
|
@ -13,16 +13,16 @@
|
|||
/**
|
||||
@brief The cocos2d Application.
|
||||
|
||||
The reason for implement as private inheritance is to hide some interface call by CCDirector.
|
||||
The reason for implement as private inheritance is to hide some interface call by Director.
|
||||
*/
|
||||
class AppDelegate : private cocos2d::CCApplication
|
||||
class AppDelegate : private cocos2d::Application
|
||||
{
|
||||
public:
|
||||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
@return false Initialize failed, app terminate.
|
||||
*/
|
||||
|
|
|
@ -24,23 +24,23 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
|||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||
if (!Director::sharedDirector()->getOpenGLView())
|
||||
{
|
||||
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||
EGLView *view = EGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication()->run();
|
||||
Application::sharedApplication()->run();
|
||||
}
|
||||
else
|
||||
{
|
||||
ccDrawInit();
|
||||
ccGLInvalidateStateCache();
|
||||
|
||||
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
CCTextureCache::reloadAllTextures();
|
||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
TextureCache::reloadAllTextures();
|
||||
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
Director::sharedDirector()->setGLDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
MyPurchase::sharedPurchase()->loadIAPPlugin();
|
||||
|
||||
// initialize director
|
||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
|
||||
Director *pDirector = Director::sharedDirector();
|
||||
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
|
||||
EGLView* pEGLView = EGLView::sharedOpenGLView();
|
||||
pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder);
|
||||
// turn on display FPS
|
||||
pDirector->setDisplayStats(true);
|
||||
|
@ -56,7 +56,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
pDirector->setAnimationInterval(1.0 / 60);
|
||||
|
||||
// create a scene. it's an autorelease object
|
||||
CCScene *pScene = HelloWorld::scene();
|
||||
Scene *pScene = HelloWorld::scene();
|
||||
|
||||
// run
|
||||
pDirector->runWithScene(pScene);
|
||||
|
@ -67,7 +67,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||
void AppDelegate::applicationDidEnterBackground()
|
||||
{
|
||||
CCDirector::sharedDirector()->pause();
|
||||
Director::sharedDirector()->pause();
|
||||
|
||||
// if you use SimpleAudioEngine, it must be pause
|
||||
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||
|
@ -76,7 +76,7 @@ void AppDelegate::applicationDidEnterBackground()
|
|||
// this function will be called when the app is active again
|
||||
void AppDelegate::applicationWillEnterForeground()
|
||||
{
|
||||
CCDirector::sharedDirector()->resume();
|
||||
Director::sharedDirector()->resume();
|
||||
|
||||
// if you use SimpleAudioEngine, it must resume here
|
||||
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
||||
|
|
|
@ -29,16 +29,16 @@ THE SOFTWARE.
|
|||
/**
|
||||
@brief The cocos2d Application.
|
||||
|
||||
The reason for implement as private inheritance is to hide some interface call by CCDirector.
|
||||
The reason for implement as private inheritance is to hide some interface call by Director.
|
||||
*/
|
||||
class AppDelegate : private cocos2d::CCApplication
|
||||
class AppDelegate : private cocos2d::Application
|
||||
{
|
||||
public:
|
||||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
@return false Initialize failed, app terminate.
|
||||
*/
|
||||
|
|
|
@ -44,10 +44,10 @@ static EventMenuItem s_EventMenuItem[] = {
|
|||
{"BtnND91.png", TAG_PAY_BY_ND91},
|
||||
};
|
||||
|
||||
CCScene* HelloWorld::scene()
|
||||
Scene* HelloWorld::scene()
|
||||
{
|
||||
// 'scene' is an autorelease object
|
||||
CCScene *scene = CCScene::create();
|
||||
Scene *scene = Scene::create();
|
||||
|
||||
// 'layer' is an autorelease object
|
||||
HelloWorld *layer = HelloWorld::create();
|
||||
|
@ -64,26 +64,26 @@ bool HelloWorld::init()
|
|||
{
|
||||
//////////////////////////////
|
||||
// 1. super init first
|
||||
if ( !CCLayer::init() )
|
||||
if ( !Layer::init() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
Size size = Director::sharedDirector()->getWinSize();
|
||||
|
||||
CCSprite* pBackground = CCSprite::create("background.png");
|
||||
Sprite* pBackground = Sprite::create("background.png");
|
||||
pBackground->setPosition(ccp(size.width / 2, size.height / 2));
|
||||
addChild(pBackground);
|
||||
/////////////////////////////
|
||||
// 2. add a menu item with "X" image, which is clicked to quit the program
|
||||
// you may modify it.
|
||||
|
||||
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
|
||||
CCPoint posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
|
||||
CCPoint posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
|
||||
EGLView* pEGLView = EGLView::sharedOpenGLView();
|
||||
Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
|
||||
Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
|
||||
|
||||
// add a "close" icon to exit the progress. it's an autorelease object
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
|
||||
MenuItemImage *pCloseItem = MenuItemImage::create(
|
||||
"CloseNormal.png",
|
||||
"CloseSelected.png",
|
||||
this,
|
||||
|
@ -91,21 +91,21 @@ bool HelloWorld::init()
|
|||
pCloseItem->setPosition( ccp(posBR.x - 20, posBR.y + 20) );
|
||||
|
||||
// create menu, it's an autorelease object
|
||||
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
|
||||
pMenu->setPosition( CCPointZero );
|
||||
Menu* pMenu = Menu::create(pCloseItem, NULL);
|
||||
pMenu->setPosition( PointZero );
|
||||
this->addChild(pMenu, 1);
|
||||
|
||||
CCPoint posStep = ccp(220, -150);
|
||||
CCPoint beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f));
|
||||
Point posStep = ccp(220, -150);
|
||||
Point beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f));
|
||||
int line = 0;
|
||||
int row = 0;
|
||||
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
|
||||
CCMenuItemImage* pMenuItem = CCMenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(),
|
||||
MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(),
|
||||
this, menu_selector(HelloWorld::eventMenuCallback));
|
||||
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
|
||||
|
||||
CCPoint pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
|
||||
CCSize itemSize = pMenuItem->getContentSize();
|
||||
Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
|
||||
Size itemSize = pMenuItem->getContentSize();
|
||||
if ((pos.x + itemSize.width / 2) > posBR.x)
|
||||
{
|
||||
line += 1;
|
||||
|
@ -116,8 +116,8 @@ bool HelloWorld::init()
|
|||
pMenuItem->setPosition(pos);
|
||||
}
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create("reload all plugins", "Arial", 24);
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
|
||||
LabelTTF* label = LabelTTF::create("reload all plugins", "Arial", 24);
|
||||
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
|
||||
pMenuItem->setAnchorPoint(ccp(0.5f, 0));
|
||||
pMenu->addChild(pMenuItem, 0);
|
||||
pMenuItem->setPosition( ccp(size.width / 2, 0));
|
||||
|
@ -125,15 +125,15 @@ bool HelloWorld::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void HelloWorld::reloadPluginMenuCallback(CCObject* pSender)
|
||||
void HelloWorld::reloadPluginMenuCallback(Object* pSender)
|
||||
{
|
||||
MyPurchase::sharedPurchase()->unloadIAPPlugin();
|
||||
MyPurchase::sharedPurchase()->loadIAPPlugin();
|
||||
}
|
||||
|
||||
void HelloWorld::eventMenuCallback(CCObject* pSender)
|
||||
void HelloWorld::eventMenuCallback(Object* pSender)
|
||||
{
|
||||
CCMenuItemLabel* pMenuItem = (CCMenuItemLabel*)pSender;
|
||||
MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender;
|
||||
TProductInfo pInfo;
|
||||
MyPurchase::MyPayMode mode = (MyPurchase::MyPayMode) (pMenuItem->getTag() - TAG_PAY_BY_ALIPAY + 1);
|
||||
pInfo["productName"] = "100金币";
|
||||
|
@ -143,11 +143,11 @@ void HelloWorld::eventMenuCallback(CCObject* pSender)
|
|||
MyPurchase::sharedPurchase()->payByMode(pInfo, mode);
|
||||
}
|
||||
|
||||
void HelloWorld::menuCloseCallback(CCObject* pSender)
|
||||
void HelloWorld::menuCloseCallback(Object* pSender)
|
||||
{
|
||||
MyPurchase::purgePurchase();
|
||||
|
||||
CCDirector::sharedDirector()->end();
|
||||
Director::sharedDirector()->end();
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
exit(0);
|
||||
#endif
|
||||
|
|
|
@ -26,19 +26,19 @@ THE SOFTWARE.
|
|||
|
||||
#include "cocos2d.h"
|
||||
|
||||
class HelloWorld : public cocos2d::CCLayer
|
||||
class HelloWorld : public cocos2d::Layer
|
||||
{
|
||||
public:
|
||||
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
|
||||
virtual bool init();
|
||||
|
||||
// there's no 'id' in cpp, so we recommand to return the exactly class pointer
|
||||
static cocos2d::CCScene* scene();
|
||||
static cocos2d::Scene* scene();
|
||||
|
||||
// a selector callback
|
||||
void menuCloseCallback(CCObject* pSender);
|
||||
void eventMenuCallback(CCObject* pSender);
|
||||
void reloadPluginMenuCallback(CCObject* pSender);
|
||||
void menuCloseCallback(Object* pSender);
|
||||
void eventMenuCallback(Object* pSender);
|
||||
void reloadPluginMenuCallback(Object* pSender);
|
||||
|
||||
// implement the "static node()" method manually
|
||||
CREATE_FUNC(HelloWorld);
|
||||
|
|
|
@ -81,7 +81,7 @@ void MyPurchase::loadIAPPlugin()
|
|||
{
|
||||
char msg[256] = { 0 };
|
||||
sprintf(msg, "Developer info is empty. PLZ fill your alipay info in %s(nearby line %d)", __FILE__, __LINE__);
|
||||
CCMessageBox(msg, "Alipay Warning");
|
||||
MessageBox(msg, "Alipay Warning");
|
||||
}
|
||||
s_pAlipay->setDebugMode(true);
|
||||
s_pAlipay->configDeveloperInfo(pAlipayInfo);
|
||||
|
@ -96,7 +96,7 @@ void MyPurchase::loadIAPPlugin()
|
|||
if (pNdInfo.empty()) {
|
||||
char msg[256] = { 0 };
|
||||
sprintf(msg, "Developer info is empty. PLZ fill your Nd91 info in %s(nearby line %d)", __FILE__, __LINE__);
|
||||
CCMessageBox(msg, "Nd91 Warning");
|
||||
MessageBox(msg, "Nd91 Warning");
|
||||
}
|
||||
s_pNd91 = dynamic_cast<ProtocolIAP*>(PluginManager::getInstance()->loadPlugin("IAPNd91"));
|
||||
s_pNd91->setDebugMode(true);
|
||||
|
@ -147,5 +147,5 @@ void MyPurchaseResult::onPayResult(PayResultCode ret, const char* msg, TProductI
|
|||
info.find("productName")->second.c_str(),
|
||||
info.find("productPrice")->second.c_str(),
|
||||
info.find("productDesc")->second.c_str());
|
||||
CCMessageBox(goodInfo , msg);
|
||||
MessageBox(goodInfo , msg);
|
||||
}
|
||||
|
|
|
@ -47,23 +47,23 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
|||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||
if (!Director::sharedDirector()->getOpenGLView())
|
||||
{
|
||||
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||
EGLView *view = EGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication()->run();
|
||||
Application::sharedApplication()->run();
|
||||
}
|
||||
else
|
||||
{
|
||||
ccDrawInit();
|
||||
ccGLInvalidateStateCache();
|
||||
|
||||
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
CCTextureCache::reloadAllTextures();
|
||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
TextureCache::reloadAllTextures();
|
||||
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
Director::sharedDirector()->setGLDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
MySocialManager::sharedSocialManager()->loadSocialPlugin();
|
||||
|
||||
// initialize director
|
||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
|
||||
Director *pDirector = Director::sharedDirector();
|
||||
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
|
||||
EGLView* pEGLView = EGLView::sharedOpenGLView();
|
||||
pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder);
|
||||
// turn on display FPS
|
||||
pDirector->setDisplayStats(true);
|
||||
|
@ -56,7 +56,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
pDirector->setAnimationInterval(1.0 / 60);
|
||||
|
||||
// create a scene. it's an autorelease object
|
||||
CCScene *pScene = HelloWorld::scene();
|
||||
Scene *pScene = HelloWorld::scene();
|
||||
|
||||
// run
|
||||
pDirector->runWithScene(pScene);
|
||||
|
@ -67,7 +67,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||
void AppDelegate::applicationDidEnterBackground()
|
||||
{
|
||||
CCDirector::sharedDirector()->pause();
|
||||
Director::sharedDirector()->pause();
|
||||
|
||||
// if you use SimpleAudioEngine, it must be pause
|
||||
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||
|
@ -76,7 +76,7 @@ void AppDelegate::applicationDidEnterBackground()
|
|||
// this function will be called when the app is active again
|
||||
void AppDelegate::applicationWillEnterForeground()
|
||||
{
|
||||
CCDirector::sharedDirector()->resume();
|
||||
Director::sharedDirector()->resume();
|
||||
|
||||
// if you use SimpleAudioEngine, it must resume here
|
||||
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
||||
|
|
|
@ -29,16 +29,16 @@ THE SOFTWARE.
|
|||
/**
|
||||
@brief The cocos2d Application.
|
||||
|
||||
The reason for implement as private inheritance is to hide some interface call by CCDirector.
|
||||
The reason for implement as private inheritance is to hide some interface call by Director.
|
||||
*/
|
||||
class AppDelegate : private cocos2d::CCApplication
|
||||
class AppDelegate : private cocos2d::Application
|
||||
{
|
||||
public:
|
||||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
/**
|
||||
@brief Implement CCDirector and CCScene init code here.
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
@return false Initialize failed, app terminate.
|
||||
*/
|
||||
|
|
|
@ -44,10 +44,10 @@ static EventMenuItem s_EventMenuItem[] = {
|
|||
{"weibo.png", TAG_SHARE_BY_WEIBO}
|
||||
};
|
||||
|
||||
CCScene* HelloWorld::scene()
|
||||
Scene* HelloWorld::scene()
|
||||
{
|
||||
// 'scene' is an autorelease object
|
||||
CCScene *scene = CCScene::create();
|
||||
Scene *scene = Scene::create();
|
||||
|
||||
// 'layer' is an autorelease object
|
||||
HelloWorld *layer = HelloWorld::create();
|
||||
|
@ -64,27 +64,27 @@ bool HelloWorld::init()
|
|||
{
|
||||
//////////////////////////////
|
||||
// 1. super init first
|
||||
if ( !CCLayer::init() )
|
||||
if ( !Layer::init() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CCSize size = CCDirector::sharedDirector()->getVisibleSize();
|
||||
Size size = Director::sharedDirector()->getVisibleSize();
|
||||
|
||||
CCSprite* pBackground = CCSprite::create("background.png");
|
||||
Sprite* pBackground = Sprite::create("background.png");
|
||||
pBackground->setPosition(ccp(size.width / 2, size.height / 2));
|
||||
addChild(pBackground);
|
||||
/////////////////////////////
|
||||
// 2. add a menu item with "X" image, which is clicked to quit the program
|
||||
// you may modify it.
|
||||
|
||||
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
|
||||
CCPoint posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
|
||||
CCPoint posBC = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width/2, pEGLView->getVisibleOrigin().y);
|
||||
CCPoint posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
|
||||
EGLView* pEGLView = EGLView::sharedOpenGLView();
|
||||
Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
|
||||
Point posBC = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width/2, pEGLView->getVisibleOrigin().y);
|
||||
Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
|
||||
|
||||
// add a "close" icon to exit the progress. it's an autorelease object
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
|
||||
MenuItemImage *pCloseItem = MenuItemImage::create(
|
||||
"CloseNormal.png",
|
||||
"CloseSelected.png",
|
||||
this,
|
||||
|
@ -92,21 +92,21 @@ bool HelloWorld::init()
|
|||
pCloseItem->setPosition( ccp(posBR.x - 20, posBR.y + 20) );
|
||||
|
||||
// create menu, it's an autorelease object
|
||||
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
|
||||
pMenu->setPosition( CCPointZero );
|
||||
Menu* pMenu = Menu::create(pCloseItem, NULL);
|
||||
pMenu->setPosition( PointZero );
|
||||
this->addChild(pMenu, 1);
|
||||
|
||||
CCPoint posStep = ccp(150, -150);
|
||||
CCPoint beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f));
|
||||
Point posStep = ccp(150, -150);
|
||||
Point beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f));
|
||||
int line = 0;
|
||||
int row = 0;
|
||||
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
|
||||
CCMenuItemImage* pMenuItem = CCMenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(),
|
||||
MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(),
|
||||
this, menu_selector(HelloWorld::eventMenuCallback));
|
||||
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
|
||||
|
||||
CCPoint pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
|
||||
CCSize itemSize = pMenuItem->getContentSize();
|
||||
Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
|
||||
Size itemSize = pMenuItem->getContentSize();
|
||||
if ((pos.x + itemSize.width / 2) > posBR.x)
|
||||
{
|
||||
line += 1;
|
||||
|
@ -117,8 +117,8 @@ bool HelloWorld::init()
|
|||
pMenuItem->setPosition(pos);
|
||||
}
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create("Reload all plugins", "Arial", 24);
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
|
||||
LabelTTF* label = LabelTTF::create("Reload all plugins", "Arial", 24);
|
||||
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
|
||||
pMenuItem->setAnchorPoint(ccp(0.5f, 0));
|
||||
pMenu->addChild(pMenuItem, 0);
|
||||
pMenuItem->setPosition(posBC);
|
||||
|
@ -126,15 +126,15 @@ bool HelloWorld::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void HelloWorld::reloadPluginMenuCallback(CCObject* pSender)
|
||||
void HelloWorld::reloadPluginMenuCallback(Object* pSender)
|
||||
{
|
||||
MySocialManager::sharedSocialManager()->unloadSocialPlugin();
|
||||
MySocialManager::sharedSocialManager()->loadSocialPlugin();
|
||||
}
|
||||
|
||||
void HelloWorld::eventMenuCallback(CCObject* pSender)
|
||||
void HelloWorld::eventMenuCallback(Object* pSender)
|
||||
{
|
||||
CCMenuItemLabel* pMenuItem = (CCMenuItemLabel*)pSender;
|
||||
MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender;
|
||||
TShareInfo pInfo;
|
||||
pInfo["SharedText"] = "Share message : HelloSocial!";
|
||||
// pInfo["SharedImagePath"] = "Full/path/to/image";
|
||||
|
@ -142,10 +142,10 @@ void HelloWorld::eventMenuCallback(CCObject* pSender)
|
|||
MySocialManager::sharedSocialManager()->shareByMode(pInfo, mode);
|
||||
}
|
||||
|
||||
void HelloWorld::menuCloseCallback(CCObject* pSender)
|
||||
void HelloWorld::menuCloseCallback(Object* pSender)
|
||||
{
|
||||
MySocialManager::purgeManager();
|
||||
CCDirector::sharedDirector()->end();
|
||||
Director::sharedDirector()->end();
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||
exit(0);
|
||||
#endif
|
||||
|
|
|
@ -26,19 +26,19 @@ THE SOFTWARE.
|
|||
|
||||
#include "cocos2d.h"
|
||||
|
||||
class HelloWorld : public cocos2d::CCLayer
|
||||
class HelloWorld : public cocos2d::Layer
|
||||
{
|
||||
public:
|
||||
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
|
||||
virtual bool init();
|
||||
|
||||
// there's no 'id' in cpp, so we recommand to return the exactly class pointer
|
||||
static cocos2d::CCScene* scene();
|
||||
static cocos2d::Scene* scene();
|
||||
|
||||
// a selector callback
|
||||
void menuCloseCallback(CCObject* pSender);
|
||||
void eventMenuCallback(CCObject* pSender);
|
||||
void reloadPluginMenuCallback(CCObject* pSender);
|
||||
void menuCloseCallback(Object* pSender);
|
||||
void eventMenuCallback(Object* pSender);
|
||||
void reloadPluginMenuCallback(Object* pSender);
|
||||
|
||||
// implement the "static node()" method manually
|
||||
CREATE_FUNC(HelloWorld);
|
||||
|
|
|
@ -88,7 +88,7 @@ void MySocialManager::loadSocialPlugin()
|
|||
{
|
||||
char msg[256] = { 0 };
|
||||
sprintf(msg, "Developer info is empty. PLZ fill your twitter info in %s(nearby line %d)", __FILE__, __LINE__);
|
||||
CCMessageBox(msg, "Twitter Warning");
|
||||
MessageBox(msg, "Twitter Warning");
|
||||
}
|
||||
s_pTwitter->setDebugMode(true);
|
||||
s_pTwitter->configDeveloperInfo(pTwitterInfo);
|
||||
|
@ -109,7 +109,7 @@ void MySocialManager::loadSocialPlugin()
|
|||
{
|
||||
char msg[256] = { 0 };
|
||||
sprintf(msg, "Developer info is empty. PLZ fill your weibo info in %s(nearby line %d)", __FILE__, __LINE__);
|
||||
CCMessageBox(msg, "Weibo Warning");
|
||||
MessageBox(msg, "Weibo Warning");
|
||||
}
|
||||
|
||||
s_pWeibo->setDebugMode(true);
|
||||
|
@ -158,5 +158,5 @@ void MyShareResult::onShareResult(ShareResultCode ret, const char* msg)
|
|||
{
|
||||
char shareStatus[1024] = { 0 };
|
||||
sprintf(shareStatus, "Share %s", (ret == kShareSuccess)? "Successed" : "Failed");
|
||||
CCMessageBox(msg, shareStatus);
|
||||
MessageBox(msg, shareStatus);
|
||||
}
|
||||
|
|
|
@ -24,23 +24,23 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
|||
|
||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
|
||||
{
|
||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||
if (!Director::sharedDirector()->getOpenGLView())
|
||||
{
|
||||
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||
EGLView *view = EGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication()->run();
|
||||
Application::sharedApplication()->run();
|
||||
}
|
||||
else
|
||||
{
|
||||
ccDrawInit();
|
||||
ccGLInvalidateStateCache();
|
||||
|
||||
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
CCTextureCache::reloadAllTextures();
|
||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
CCDirector::sharedDirector()->setGLDefaultValues();
|
||||
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
|
||||
TextureCache::reloadAllTextures();
|
||||
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
|
||||
Director::sharedDirector()->setGLDefaultValues();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ static AppDelegate s_sharedApplication;
|
|||
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:true];
|
||||
|
||||
cocos2d::CCApplication::sharedApplication()->run();
|
||||
cocos2d::Application::sharedApplication()->run();
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
@ -85,14 +85,14 @@ static AppDelegate s_sharedApplication;
|
|||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
*/
|
||||
cocos2d::CCDirector::sharedDirector()->pause();
|
||||
cocos2d::Director::sharedDirector()->pause();
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
/*
|
||||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
*/
|
||||
cocos2d::CCDirector::sharedDirector()->resume();
|
||||
cocos2d::Director::sharedDirector()->resume();
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
|
@ -100,14 +100,14 @@ static AppDelegate s_sharedApplication;
|
|||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||
*/
|
||||
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||
cocos2d::Application::sharedApplication()->applicationDidEnterBackground();
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
/*
|
||||
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
|
||||
*/
|
||||
cocos2d::CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||
cocos2d::Application::sharedApplication()->applicationWillEnterForeground();
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
|
|
Loading…
Reference in New Issue