mirror of https://github.com/axmolengine/axmol.git
Merge branch 'gles20' of https://github.com/cocos2d/cocos2d-x into android_editbox
This commit is contained in:
commit
ee3e68014b
|
@ -21,10 +21,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestJavascript", "samples\T
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLua", "samples\TestLua\proj.win32\TestLua.win32.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28}
|
||||||
|
{DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {DDC3E27F-004D-4DD4-9DD3-931A013D2159}
|
||||||
|
{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}
|
||||||
|
{207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25}
|
||||||
|
{929480E7-23C0-4DF6-8456-096D71547116} = {929480E7-23C0-4DF6-8456-096D71547116}
|
||||||
|
{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
|
|
||||||
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
Release|Win32 = Release|Win32
|
Release|Win32 = Release|Win32
|
||||||
|
@ -70,8 +77,15 @@ Global
|
||||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32
|
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32
|
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32
|
{21B2C324-891F-48EA-AD1A-5AE13DE12E28}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}.Release|Win32.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
|
||||||
|
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -733,7 +733,7 @@ void CCDirector::showStats(void)
|
||||||
sprintf(m_pszFPS, "%.1f", m_fFrameRate);
|
sprintf(m_pszFPS, "%.1f", m_fFrameRate);
|
||||||
m_pFPSLabel->setString(m_pszFPS);
|
m_pFPSLabel->setString(m_pszFPS);
|
||||||
|
|
||||||
sprintf(m_pszFPS, "%4d", g_uNumberOfDraws);
|
sprintf(m_pszFPS, "%4lu", (unsigned long)g_uNumberOfDraws);
|
||||||
m_pDrawsLabel->setString(m_pszFPS);
|
m_pDrawsLabel->setString(m_pszFPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,7 +953,7 @@ void CCDisplayLinkDirector::startAnimation(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bInvalid = false;
|
m_bInvalid = false;
|
||||||
CCApplication::sharedApplication().setAnimationInterval(m_dAnimationInterval);
|
CCApplication::sharedApplication()->setAnimationInterval(m_dAnimationInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCDisplayLinkDirector::mainLoop(void)
|
void CCDisplayLinkDirector::mainLoop(void)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "CCActionInstant.h"
|
#include "CCActionInstant.h"
|
||||||
#include "base_nodes/CCNode.h"
|
#include "base_nodes/CCNode.h"
|
||||||
#include "sprite_nodes/CCSprite.h"
|
#include "sprite_nodes/CCSprite.h"
|
||||||
|
#include "script_support/CCScriptSupport.h"
|
||||||
#include "cocoa/CCZone.h"
|
#include "cocoa/CCZone.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
@ -376,6 +377,20 @@ CCCallFunc * CCCallFunc::create(CCObject* pSelectorTarget, SEL_CallFunc selector
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCCallFunc * CCCallFunc::create(int nHandler)
|
||||||
|
{
|
||||||
|
CCCallFunc *pRet = new CCCallFunc();
|
||||||
|
|
||||||
|
if (pRet) {
|
||||||
|
pRet->m_nScriptHandler = nHandler;
|
||||||
|
pRet->autorelease();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
CC_SAFE_DELETE(pRet);
|
||||||
|
}
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
bool CCCallFunc::initWithTarget(CCObject* pSelectorTarget) {
|
bool CCCallFunc::initWithTarget(CCObject* pSelectorTarget) {
|
||||||
if (pSelectorTarget)
|
if (pSelectorTarget)
|
||||||
{
|
{
|
||||||
|
@ -419,6 +434,9 @@ void CCCallFunc::execute() {
|
||||||
if (m_pCallFunc) {
|
if (m_pCallFunc) {
|
||||||
(m_pSelectorTarget->*m_pCallFunc)();
|
(m_pSelectorTarget->*m_pCallFunc)();
|
||||||
}
|
}
|
||||||
|
if (m_nScriptHandler) {
|
||||||
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionByHandler(m_nScriptHandler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -428,6 +446,9 @@ void CCCallFuncN::execute() {
|
||||||
if (m_pCallFuncN) {
|
if (m_pCallFuncN) {
|
||||||
(m_pSelectorTarget->*m_pCallFuncN)(m_pTarget);
|
(m_pSelectorTarget->*m_pCallFuncN)(m_pTarget);
|
||||||
}
|
}
|
||||||
|
if (m_nScriptHandler) {
|
||||||
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionWithCCObject(m_nScriptHandler, m_pTarget, "CCNode");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CCCallFuncN * CCCallFuncN::actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector)
|
CCCallFuncN * CCCallFuncN::actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector)
|
||||||
|
@ -449,6 +470,20 @@ CCCallFuncN * CCCallFuncN::create(CCObject* pSelectorTarget, SEL_CallFuncN selec
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCCallFuncN * CCCallFuncN::create(int nHandler)
|
||||||
|
{
|
||||||
|
CCCallFuncN *pRet = new CCCallFuncN();
|
||||||
|
|
||||||
|
if (pRet) {
|
||||||
|
pRet->m_nScriptHandler = nHandler;
|
||||||
|
pRet->autorelease();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
CC_SAFE_DELETE(pRet);
|
||||||
|
}
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
bool CCCallFuncN::initWithTarget(CCObject* pSelectorTarget,
|
bool CCCallFuncN::initWithTarget(CCObject* pSelectorTarget,
|
||||||
SEL_CallFuncN selector) {
|
SEL_CallFuncN selector) {
|
||||||
if (CCCallFunc::initWithTarget(pSelectorTarget)) {
|
if (CCCallFunc::initWithTarget(pSelectorTarget)) {
|
||||||
|
|
|
@ -215,6 +215,7 @@ public:
|
||||||
CCCallFunc()
|
CCCallFunc()
|
||||||
: m_pSelectorTarget(NULL)
|
: m_pSelectorTarget(NULL)
|
||||||
, m_pCallFunc(NULL)
|
, m_pCallFunc(NULL)
|
||||||
|
, m_nScriptHandler(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~CCCallFunc()
|
virtual ~CCCallFunc()
|
||||||
|
@ -233,7 +234,10 @@ public:
|
||||||
*/
|
*/
|
||||||
static CCCallFunc * create(CCObject* pSelectorTarget, SEL_CallFunc selector);
|
static CCCallFunc * create(CCObject* pSelectorTarget, SEL_CallFunc selector);
|
||||||
|
|
||||||
/** initializes the action with the callback
|
/** creates the action with the handler script function */
|
||||||
|
static CCCallFunc * create(int nHandler);
|
||||||
|
|
||||||
|
/** initializes the action with the callback
|
||||||
|
|
||||||
typedef void (CCObject::*SEL_CallFunc)();
|
typedef void (CCObject::*SEL_CallFunc)();
|
||||||
*/
|
*/
|
||||||
|
@ -263,6 +267,8 @@ protected:
|
||||||
/** Target that will be called */
|
/** Target that will be called */
|
||||||
CCObject* m_pSelectorTarget;
|
CCObject* m_pSelectorTarget;
|
||||||
|
|
||||||
|
int m_nScriptHandler;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
SEL_CallFunc m_pCallFunc;
|
SEL_CallFunc m_pCallFunc;
|
||||||
|
@ -292,6 +298,10 @@ public:
|
||||||
typedef void (CCObject::*SEL_CallFuncN)(CCNode*);
|
typedef void (CCObject::*SEL_CallFuncN)(CCNode*);
|
||||||
*/
|
*/
|
||||||
static CCCallFuncN * create(CCObject* pSelectorTarget, SEL_CallFuncN selector);
|
static CCCallFuncN * create(CCObject* pSelectorTarget, SEL_CallFuncN selector);
|
||||||
|
|
||||||
|
/** creates the action with the handler script function */
|
||||||
|
static CCCallFuncN * create(int nHandler);
|
||||||
|
|
||||||
/** initializes the action with the callback
|
/** initializes the action with the callback
|
||||||
|
|
||||||
typedef void (CCObject::*SEL_CallFuncN)(CCNode*);
|
typedef void (CCObject::*SEL_CallFuncN)(CCNode*);
|
||||||
|
|
|
@ -335,6 +335,12 @@ void CCSequence::update(float t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Last action found and it is done.
|
||||||
|
if( found == m_last && m_pActions[found]->isDone() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// New action. Start it.
|
// New action. Start it.
|
||||||
if( found != m_last )
|
if( found != m_last )
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
const char* cocos2dVersion()
|
const char* cocos2dVersion()
|
||||||
{
|
{
|
||||||
return "cocos2d-2.0-rc2-x-2.0.1";
|
return "cocos2d-2.0-x-2.0.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -214,7 +214,7 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma
|
||||||
//create and attach depth buffer
|
//create and attach depth buffer
|
||||||
glGenRenderbuffers(1, &m_uDepthRenderBufffer);
|
glGenRenderbuffers(1, &m_uDepthRenderBufffer);
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, m_uDepthRenderBufffer);
|
glBindRenderbuffer(GL_RENDERBUFFER, m_uDepthRenderBufffer);
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, uDepthStencilFormat, powW, powH);
|
glRenderbufferStorage(GL_RENDERBUFFER, uDepthStencilFormat, (GLsizei)powW, (GLsizei)powH);
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_uDepthRenderBufffer);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_uDepthRenderBufffer);
|
||||||
|
|
||||||
// if depth format is the one with stencil part, bind same render buffer as stencil attachment
|
// if depth format is the one with stencil part, bind same render buffer as stencil attachment
|
||||||
|
|
|
@ -69,10 +69,10 @@ CCApplication::Orientation CCApplication::setOrientation(Orientation orientation
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// static member function
|
// static member function
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
CCApplication& CCApplication::sharedApplication()
|
CCApplication* CCApplication::sharedApplication()
|
||||||
{
|
{
|
||||||
CC_ASSERT(sm_pSharedApplication);
|
CC_ASSERT(sm_pSharedApplication);
|
||||||
return *sm_pSharedApplication;
|
return sm_pSharedApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccLanguageType CCApplication::getCurrentLanguage()
|
ccLanguageType CCApplication::getCurrentLanguage()
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
@brief Get current applicaiton instance.
|
@brief Get current applicaiton instance.
|
||||||
@return Current application instance pointer.
|
@return Current application instance pointer.
|
||||||
*/
|
*/
|
||||||
static CCApplication& sharedApplication();
|
static CCApplication* sharedApplication();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get current language config
|
@brief Get current language config
|
||||||
|
|
|
@ -77,10 +77,10 @@ void CCEGLView::swapBuffers()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
CCEGLView* CCEGLView::sharedOpenGLView()
|
||||||
{
|
{
|
||||||
static CCEGLView instance;
|
static CCEGLView instance;
|
||||||
return instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCEGLView::setIMEKeyboardState(bool bOpen)
|
void CCEGLView::setIMEKeyboardState(bool bOpen)
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
/**
|
/**
|
||||||
@brief get the shared main open gl window
|
@brief get the shared main open gl window
|
||||||
*/
|
*/
|
||||||
static CCEGLView& sharedOpenGLView();
|
static CCEGLView* sharedOpenGLView();
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -59,7 +59,7 @@ extern "C"
|
||||||
|
|
||||||
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause()
|
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause()
|
||||||
{
|
{
|
||||||
CCApplication::sharedApplication().applicationDidEnterBackground();
|
CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||||
|
|
||||||
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND, NULL);
|
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND, NULL);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ extern "C"
|
||||||
// Shared OpenGL View instance doesn't exist yet when Activity.onResume is first called
|
// Shared OpenGL View instance doesn't exist yet when Activity.onResume is first called
|
||||||
if (CCDirector::sharedDirector()->getOpenGLView())
|
if (CCDirector::sharedDirector()->getOpenGLView())
|
||||||
{
|
{
|
||||||
CCApplication::sharedApplication().applicationWillEnterForeground();
|
CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ int CCApplication::run()
|
||||||
|
|
||||||
while (1) // or device wants to quit
|
while (1) // or device wants to quit
|
||||||
{
|
{
|
||||||
CCEGLView::sharedOpenGLView().handleEvents();
|
CCEGLView::sharedOpenGLView()->handleEvents();
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &time_struct);
|
clock_gettime(CLOCK_REALTIME, &time_struct);
|
||||||
current_time = time2millis(&time_struct);
|
current_time = time2millis(&time_struct);
|
||||||
|
@ -106,10 +106,10 @@ TargetPlatform CCApplication::getTargetPlatform()
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// static member function
|
// static member function
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
CCApplication& CCApplication::sharedApplication()
|
CCApplication* CCApplication::sharedApplication()
|
||||||
{
|
{
|
||||||
CC_ASSERT(sm_pSharedApplication);
|
CC_ASSERT(sm_pSharedApplication);
|
||||||
return *sm_pSharedApplication;
|
return sm_pSharedApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccLanguageType CCApplication::getCurrentLanguage()
|
ccLanguageType CCApplication::getCurrentLanguage()
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
@brief Get current applicaiton instance.
|
@brief Get current applicaiton instance.
|
||||||
@return Current application instance pointer.
|
@return Current application instance pointer.
|
||||||
*/
|
*/
|
||||||
static CCApplication& sharedApplication();
|
static CCApplication* sharedApplication();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get current language config
|
@brief Get current language config
|
||||||
|
|
|
@ -189,7 +189,7 @@ void CCEGLView::swapBuffers()
|
||||||
eglSwapBuffers(m_eglDisplay, m_eglSurface);
|
eglSwapBuffers(m_eglDisplay, m_eglSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
CCEGLView* CCEGLView::sharedOpenGLView()
|
||||||
{
|
{
|
||||||
if (!s_pInstance)
|
if (!s_pInstance)
|
||||||
{
|
{
|
||||||
|
@ -197,7 +197,7 @@ CCEGLView& CCEGLView::sharedOpenGLView()
|
||||||
}
|
}
|
||||||
|
|
||||||
CCAssert(s_pInstance != NULL, "CCEGLView wasn't constructed yet");
|
CCAssert(s_pInstance != NULL, "CCEGLView wasn't constructed yet");
|
||||||
return *s_pInstance;
|
return s_pInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCEGLView::showKeyboard()
|
void CCEGLView::showKeyboard()
|
||||||
|
@ -587,7 +587,7 @@ bool CCEGLView::handleEvents()
|
||||||
case NAVIGATOR_WINDOW_INACTIVE:
|
case NAVIGATOR_WINDOW_INACTIVE:
|
||||||
if (m_isWindowActive)
|
if (m_isWindowActive)
|
||||||
{
|
{
|
||||||
CCApplication::sharedApplication().applicationDidEnterBackground();
|
CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||||
m_isWindowActive = false;
|
m_isWindowActive = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -595,7 +595,7 @@ bool CCEGLView::handleEvents()
|
||||||
case NAVIGATOR_WINDOW_ACTIVE:
|
case NAVIGATOR_WINDOW_ACTIVE:
|
||||||
if (!m_isWindowActive)
|
if (!m_isWindowActive)
|
||||||
{
|
{
|
||||||
CCApplication::sharedApplication().applicationWillEnterForeground();
|
CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||||
m_isWindowActive = true;
|
m_isWindowActive = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -607,14 +607,14 @@ bool CCEGLView::handleEvents()
|
||||||
case NAVIGATOR_WINDOW_FULLSCREEN:
|
case NAVIGATOR_WINDOW_FULLSCREEN:
|
||||||
if (!m_isWindowActive)
|
if (!m_isWindowActive)
|
||||||
{
|
{
|
||||||
CCApplication::sharedApplication().applicationWillEnterForeground();
|
CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||||
m_isWindowActive = true;
|
m_isWindowActive = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NAVIGATOR_WINDOW_THUMBNAIL:
|
case NAVIGATOR_WINDOW_THUMBNAIL:
|
||||||
if (m_isWindowActive)
|
if (m_isWindowActive)
|
||||||
{
|
{
|
||||||
CCApplication::sharedApplication().applicationDidEnterBackground();
|
CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||||
m_isWindowActive = false;
|
m_isWindowActive = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
/**
|
/**
|
||||||
@brief get the shared main open gl window
|
@brief get the shared main open gl window
|
||||||
*/
|
*/
|
||||||
static CCEGLView& sharedOpenGLView();
|
static CCEGLView* sharedOpenGLView();
|
||||||
|
|
||||||
bool handleEvents();
|
bool handleEvents();
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ void CCFileUtils::purgeCachedEntries()
|
||||||
static std::string fullPathFromRelativePathThreadSafe(const char* pszRelativePath)
|
static std::string fullPathFromRelativePathThreadSafe(const char* pszRelativePath)
|
||||||
{
|
{
|
||||||
std::string ret("");
|
std::string ret("");
|
||||||
const char* pszRootPath = CCApplication::sharedApplication().getResourceRootPath();
|
const char* pszRootPath = CCApplication::sharedApplication()->getResourceRootPath();
|
||||||
CCAssert(pszRootPath != NULL, "The resource root path must be set in the main.cpp");
|
CCAssert(pszRootPath != NULL, "The resource root path must be set in the main.cpp");
|
||||||
|
|
||||||
std::string pstrRelativePath = pszRelativePath;
|
std::string pstrRelativePath = pszRelativePath;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
@brief Get current applicaiton instance.
|
@brief Get current applicaiton instance.
|
||||||
@return Current application instance pointer.
|
@return Current application instance pointer.
|
||||||
*/
|
*/
|
||||||
static CCApplication& sharedApplication();
|
static CCApplication* sharedApplication();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Callback by CCDirector for limit FPS.
|
@brief Callback by CCDirector for limit FPS.
|
||||||
|
|
|
@ -63,10 +63,10 @@ void CCApplication::setAnimationInterval(double interval)
|
||||||
// static member function
|
// static member function
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CCApplication& CCApplication::sharedApplication()
|
CCApplication* CCApplication::sharedApplication()
|
||||||
{
|
{
|
||||||
CC_ASSERT(sm_pSharedApplication);
|
CC_ASSERT(sm_pSharedApplication);
|
||||||
return *sm_pSharedApplication;
|
return sm_pSharedApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccLanguageType CCApplication::getCurrentLanguage()
|
ccLanguageType CCApplication::getCurrentLanguage()
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
|
|
||||||
virtual void setIMEKeyboardState(bool bOpen);
|
virtual void setIMEKeyboardState(bool bOpen);
|
||||||
|
|
||||||
static CCEGLView& sharedOpenGLView();
|
static CCEGLView* sharedOpenGLView();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -106,10 +106,10 @@ void CCEGLView::setIMEKeyboardState(bool bOpen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
CCEGLView* CCEGLView::sharedOpenGLView()
|
||||||
{
|
{
|
||||||
static CCEGLView instance;
|
static CCEGLView instance;
|
||||||
return instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -193,20 +193,20 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||||
if( ! [relPath isAbsolutePath] ) {
|
if( ! [relPath isAbsolutePath] ) {
|
||||||
|
|
||||||
// pathForResource also searches in .lproj directories. issue #1230
|
// pathForResource also searches in .lproj directories. issue #1230
|
||||||
NSString *file = [relPath lastPathComponent];
|
NSString *lastPathComponent = [relPath lastPathComponent];
|
||||||
|
|
||||||
NSMutableString *imageDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
|
NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
|
||||||
NSMutableString *imageDirectoryWithDirectory = imageDirectory;
|
NSMutableString *imageDirectoryByAppendDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
|
||||||
[imageDirectoryWithDirectory appendString:[relPath stringByDeletingLastPathComponent]];
|
[imageDirectoryByAppendDirectory appendString:imageDirectory];
|
||||||
|
|
||||||
// search path from directory set by setResourceDirectory
|
// search path from directory set by setResourceDirectory
|
||||||
fullpath = [[NSBundle mainBundle] pathForResource:file
|
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
|
||||||
ofType:nil
|
ofType:nil
|
||||||
inDirectory:imageDirectoryWithDirectory];
|
inDirectory:imageDirectoryByAppendDirectory];
|
||||||
if (fullpath == nil)
|
if (fullpath == nil)
|
||||||
{
|
{
|
||||||
// search from root directory
|
// search from root directory
|
||||||
fullpath = [[NSBundle mainBundle] pathForResource:file
|
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
|
||||||
ofType:nil
|
ofType:nil
|
||||||
inDirectory:imageDirectory];
|
inDirectory:imageDirectory];
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,32 +227,32 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
|
||||||
font = [UIFont fontWithName:fntName size:nSize];
|
font = [UIFont fontWithName:fntName size:nSize];
|
||||||
if (font)
|
if (font)
|
||||||
{
|
{
|
||||||
dim = _calculateStringSizeWithFontOrZFont(str, font, &constrainSize, false);
|
dim = _calculateStringSizeWithFontOrZFont(str, font, &constrainSize, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! font)
|
if (! font)
|
||||||
{
|
{
|
||||||
font = [[FontManager sharedManager] zFontWithName:fntName pointSize:nSize];
|
font = [[FontManager sharedManager] zFontWithName:fntName pointSize:nSize];
|
||||||
if (font)
|
if (font)
|
||||||
{
|
{
|
||||||
dim =_calculateStringSizeWithFontOrZFont(str, font, &constrainSize, true);
|
dim =_calculateStringSizeWithFontOrZFont(str, font, &constrainSize, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! font)
|
if (! font)
|
||||||
{
|
{
|
||||||
fntName = _isValidFontName(pFontName) ? fntName : @"MarkerFelt-Wide";
|
fntName = _isValidFontName(pFontName) ? fntName : @"MarkerFelt-Wide";
|
||||||
font = [UIFont fontWithName:fntName size:nSize];
|
font = [UIFont fontWithName:fntName size:nSize];
|
||||||
|
|
||||||
if (! font)
|
if (! font)
|
||||||
{
|
{
|
||||||
font = [UIFont systemFontOfSize:nSize];
|
font = [UIFont systemFontOfSize:nSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (font)
|
if (font)
|
||||||
{
|
{
|
||||||
dim = _calculateStringSizeWithFontOrZFont(str, font, &constrainSize, false);
|
dim = _calculateStringSizeWithFontOrZFont(str, font, &constrainSize, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CC_BREAK_IF(! font);
|
CC_BREAK_IF(! font);
|
||||||
|
|
|
@ -405,7 +405,7 @@ static EAGLView *view = 0;
|
||||||
ys[i] = [touch locationInView: [touch view]].y;
|
ys[i] = [touch locationInView: [touch view]].y;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
cocos2d::CCEGLView::sharedOpenGLView().handleTouchesBegin(i, ids, xs, ys);
|
cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesBegin(i, ids, xs, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||||
|
@ -425,7 +425,7 @@ static EAGLView *view = 0;
|
||||||
ys[i] = [touch locationInView: [touch view]].y;
|
ys[i] = [touch locationInView: [touch view]].y;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
cocos2d::CCEGLView::sharedOpenGLView().handleTouchesMove(i, ids, xs, ys);
|
cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesMove(i, ids, xs, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||||
|
@ -446,7 +446,7 @@ static EAGLView *view = 0;
|
||||||
ys[i] = [touch locationInView: [touch view]].y;
|
ys[i] = [touch locationInView: [touch view]].y;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
cocos2d::CCEGLView::sharedOpenGLView().handleTouchesEnd(i, ids, xs, ys);
|
cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesEnd(i, ids, xs, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||||
|
@ -467,7 +467,7 @@ static EAGLView *view = 0;
|
||||||
ys[i] = [touch locationInView: [touch view]].y;
|
ys[i] = [touch locationInView: [touch view]].y;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
cocos2d::CCEGLView::sharedOpenGLView().handleTouchesCancel(i, ids, xs, ys);
|
cocos2d::CCEGLView::sharedOpenGLView()->handleTouchesCancel(i, ids, xs, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
@ -797,7 +797,7 @@ static EAGLView *view = 0;
|
||||||
end.size.height);
|
end.size.height);
|
||||||
notiInfo.duration = (float)aniDuration;
|
notiInfo.duration = (float)aniDuration;
|
||||||
|
|
||||||
float offestY = cocos2d::CCEGLView::sharedOpenGLView().getViewPortRect().origin.y;
|
float offestY = cocos2d::CCEGLView::sharedOpenGLView()->getViewPortRect().origin.y;
|
||||||
|
|
||||||
if (offestY > 0.0f)
|
if (offestY > 0.0f)
|
||||||
{
|
{
|
||||||
|
@ -806,10 +806,10 @@ static EAGLView *view = 0;
|
||||||
notiInfo.end.size.height -= offestY;
|
notiInfo.end.size.height -= offestY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cocos2d::CCEGLView::sharedOpenGLView().isRetinaEnabled())
|
if (!cocos2d::CCEGLView::sharedOpenGLView()->isRetinaEnabled())
|
||||||
{
|
{
|
||||||
float scaleX = cocos2d::CCEGLView::sharedOpenGLView().getScaleX();
|
float scaleX = cocos2d::CCEGLView::sharedOpenGLView()->getScaleX();
|
||||||
float scaleY = cocos2d::CCEGLView::sharedOpenGLView().getScaleY();
|
float scaleY = cocos2d::CCEGLView::sharedOpenGLView()->getScaleY();
|
||||||
|
|
||||||
notiInfo.begin.origin.x /= scaleX;
|
notiInfo.begin.origin.x /= scaleX;
|
||||||
notiInfo.begin.origin.y /= scaleY;
|
notiInfo.begin.origin.y /= scaleY;
|
||||||
|
@ -860,9 +860,9 @@ static EAGLView *view = 0;
|
||||||
|
|
||||||
if (dis < 0.0f) dis = 0.0f;
|
if (dis < 0.0f) dis = 0.0f;
|
||||||
|
|
||||||
if (!cocos2d::CCEGLView::sharedOpenGLView().isRetinaEnabled())
|
if (!cocos2d::CCEGLView::sharedOpenGLView()->isRetinaEnabled())
|
||||||
{
|
{
|
||||||
dis *= cocos2d::CCEGLView::sharedOpenGLView().getScaleY();
|
dis *= cocos2d::CCEGLView::sharedOpenGLView()->getScaleY();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ([[UIApplication sharedApplication] statusBarOrientation])
|
switch ([[UIApplication sharedApplication] statusBarOrientation])
|
||||||
|
|
|
@ -92,10 +92,10 @@ TargetPlatform CCApplication::getTargetPlatform()
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// static member function
|
// static member function
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
CCApplication& CCApplication::sharedApplication()
|
CCApplication* CCApplication::sharedApplication()
|
||||||
{
|
{
|
||||||
CC_ASSERT(sm_pSharedApplication);
|
CC_ASSERT(sm_pSharedApplication);
|
||||||
return *sm_pSharedApplication;
|
return sm_pSharedApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccLanguageType CCApplication::getCurrentLanguage()
|
ccLanguageType CCApplication::getCurrentLanguage()
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
@brief Get current applicaiton instance.
|
@brief Get current applicaiton instance.
|
||||||
@return Current application instance pointer.
|
@return Current application instance pointer.
|
||||||
*/
|
*/
|
||||||
static CCApplication& sharedApplication();
|
static CCApplication* sharedApplication();
|
||||||
|
|
||||||
/* override functions */
|
/* override functions */
|
||||||
virtual ccLanguageType getCurrentLanguage();
|
virtual ccLanguageType getCurrentLanguage();
|
||||||
|
|
|
@ -122,10 +122,10 @@ void mouseButtonEventHandle(int iMouseID,int iMouseState) {
|
||||||
*/
|
*/
|
||||||
int id = 0;
|
int id = 0;
|
||||||
if (iMouseState == GLFW_PRESS) {
|
if (iMouseState == GLFW_PRESS) {
|
||||||
CCEGLView::sharedOpenGLView().handleTouchesBegin(1, &id, &oPoint.x, &oPoint.y);
|
CCEGLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &oPoint.x, &oPoint.y);
|
||||||
|
|
||||||
} else if (iMouseState == GLFW_RELEASE) {
|
} else if (iMouseState == GLFW_RELEASE) {
|
||||||
CCEGLView::sharedOpenGLView().handleTouchesEnd(1, &id, &oPoint.x, &oPoint.y);
|
CCEGLView::sharedOpenGLView()->handleTouchesEnd(1, &id, &oPoint.x, &oPoint.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ void mousePosEventHandle(int iPosX,int iPosY) {
|
||||||
int id = 0;
|
int id = 0;
|
||||||
float x = (float)iPosX;
|
float x = (float)iPosX;
|
||||||
float y = (float)iPosY;
|
float y = (float)iPosY;
|
||||||
CCEGLView::sharedOpenGLView().handleTouchesMove(1, &id, &x, &y);
|
CCEGLView::sharedOpenGLView()->handleTouchesMove(1, &id, &x, &y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,14 +292,14 @@ void CCEGLView::destroyGL()
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
CCEGLView* CCEGLView::sharedOpenGLView()
|
||||||
{
|
{
|
||||||
static CCEGLView* s_pEglView = NULL;
|
static CCEGLView* s_pEglView = NULL;
|
||||||
if (s_pEglView == NULL)
|
if (s_pEglView == NULL)
|
||||||
{
|
{
|
||||||
s_pEglView = new CCEGLView();
|
s_pEglView = new CCEGLView();
|
||||||
}
|
}
|
||||||
return *s_pEglView;
|
return s_pEglView;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
/**
|
/**
|
||||||
@brief get the shared main open gl window
|
@brief get the shared main open gl window
|
||||||
*/
|
*/
|
||||||
static CCEGLView& sharedOpenGLView();
|
static CCEGLView* sharedOpenGLView();
|
||||||
private:
|
private:
|
||||||
bool initGL();
|
bool initGL();
|
||||||
void destroyGL();
|
void destroyGL();
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
@brief Get current applicaiton instance.
|
@brief Get current applicaiton instance.
|
||||||
@return Current application instance pointer.
|
@return Current application instance pointer.
|
||||||
*/
|
*/
|
||||||
static CCApplication& sharedApplication();
|
static CCApplication* sharedApplication();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get current language config
|
@brief Get current language config
|
||||||
|
|
|
@ -69,10 +69,10 @@ TargetPlatform CCApplication::getTargetPlatform()
|
||||||
// static member function
|
// static member function
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CCApplication& CCApplication::sharedApplication()
|
CCApplication* CCApplication::sharedApplication()
|
||||||
{
|
{
|
||||||
CC_ASSERT(sm_pSharedApplication);
|
CC_ASSERT(sm_pSharedApplication);
|
||||||
return *sm_pSharedApplication;
|
return sm_pSharedApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccLanguageType CCApplication::getCurrentLanguage()
|
ccLanguageType CCApplication::getCurrentLanguage()
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
|
|
||||||
void setMultiTouchMask(bool mask);
|
void setMultiTouchMask(bool mask);
|
||||||
|
|
||||||
static CCEGLView& sharedOpenGLView();
|
static CCEGLView* sharedOpenGLView();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -83,10 +83,10 @@ void CCEGLView::setMultiTouchMask(bool mask)
|
||||||
//glView.multipleTouchEnabled = mask ? YES : NO;
|
//glView.multipleTouchEnabled = mask ? YES : NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
CCEGLView* CCEGLView::sharedOpenGLView()
|
||||||
{
|
{
|
||||||
static CCEGLView instance;
|
static CCEGLView instance;
|
||||||
return instance;
|
return &instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end of namespace cocos2d;
|
} // end of namespace cocos2d;
|
||||||
|
|
|
@ -193,20 +193,20 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
|
||||||
if( ! [relPath isAbsolutePath] ) {
|
if( ! [relPath isAbsolutePath] ) {
|
||||||
|
|
||||||
// pathForResource also searches in .lproj directories. issue #1230
|
// pathForResource also searches in .lproj directories. issue #1230
|
||||||
NSString *file = [relPath lastPathComponent];
|
NSString *lastPathComponent = [relPath lastPathComponent];
|
||||||
|
|
||||||
NSMutableString *imageDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
|
NSString *imageDirectory = [relPath stringByDeletingLastPathComponent];
|
||||||
NSMutableString *imageDirectoryWithDirectory = imageDirectory;
|
NSMutableString *imageDirectoryByAppendDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
|
||||||
[imageDirectoryWithDirectory appendString:[relPath stringByDeletingLastPathComponent]];
|
[imageDirectoryByAppendDirectory appendString:imageDirectory];
|
||||||
|
|
||||||
// search path from directory set by setResourceDirectory
|
// search path from directory set by setResourceDirectory
|
||||||
fullpath = [[NSBundle mainBundle] pathForResource:file
|
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
|
||||||
ofType:nil
|
ofType:nil
|
||||||
inDirectory:imageDirectoryWithDirectory];
|
inDirectory:imageDirectoryByAppendDirectory];
|
||||||
if (fullpath == nil)
|
if (fullpath == nil)
|
||||||
{
|
{
|
||||||
// search from root directory
|
// search from root directory
|
||||||
fullpath = [[NSBundle mainBundle] pathForResource:file
|
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
|
||||||
ofType:nil
|
ofType:nil
|
||||||
inDirectory:imageDirectory];
|
inDirectory:imageDirectory];
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,12 +168,12 @@ void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
||||||
if (pDelegate)
|
if (pDelegate)
|
||||||
{
|
{
|
||||||
// Register our handler
|
// Register our handler
|
||||||
CCEGLView::sharedOpenGLView().setAccelerometerKeyHook( &myAccelerometerKeyHook );
|
CCEGLView::sharedOpenGLView()->setAccelerometerKeyHook( &myAccelerometerKeyHook );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// De-register our handler
|
// De-register our handler
|
||||||
CCEGLView::sharedOpenGLView().setAccelerometerKeyHook( NULL );
|
CCEGLView::sharedOpenGLView()->setAccelerometerKeyHook( NULL );
|
||||||
resetAccelerometer();
|
resetAccelerometer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,9 @@ int CCApplication::run()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView& mainWnd = CCEGLView::sharedOpenGLView();
|
CCEGLView* pMainWnd = CCEGLView::sharedOpenGLView();
|
||||||
mainWnd.centerWindow();
|
pMainWnd->centerWindow();
|
||||||
ShowWindow(mainWnd.getHWnd(), SW_SHOW);
|
ShowWindow(pMainWnd->getHWnd(), SW_SHOW);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -99,10 +99,10 @@ void CCApplication::setAnimationInterval(double interval)
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// static member function
|
// static member function
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
CCApplication& CCApplication::sharedApplication()
|
CCApplication* CCApplication::sharedApplication()
|
||||||
{
|
{
|
||||||
CC_ASSERT(sm_pSharedApplication);
|
CC_ASSERT(sm_pSharedApplication);
|
||||||
return *sm_pSharedApplication;
|
return sm_pSharedApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccLanguageType CCApplication::getCurrentLanguage()
|
ccLanguageType CCApplication::getCurrentLanguage()
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
@brief Get current applicaiton instance.
|
@brief Get current applicaiton instance.
|
||||||
@return Current application instance pointer.
|
@return Current application instance pointer.
|
||||||
*/
|
*/
|
||||||
static CCApplication& sharedApplication();
|
static CCApplication* sharedApplication();
|
||||||
|
|
||||||
/* override functions */
|
/* override functions */
|
||||||
virtual void setAnimationInterval(double interval);
|
virtual void setAnimationInterval(double interval);
|
||||||
|
|
|
@ -248,10 +248,10 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
switch (wParam)
|
switch (wParam)
|
||||||
{
|
{
|
||||||
case SIZE_RESTORED:
|
case SIZE_RESTORED:
|
||||||
CCApplication::sharedApplication().applicationWillEnterForeground();
|
CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||||
break;
|
break;
|
||||||
case SIZE_MINIMIZED:
|
case SIZE_MINIMIZED:
|
||||||
CCApplication::sharedApplication().applicationDidEnterBackground();
|
CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -446,14 +446,14 @@ bool CCEGLView::setContentScaleFactor(float contentScaleFactor)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCEGLView& CCEGLView::sharedOpenGLView()
|
CCEGLView* CCEGLView::sharedOpenGLView()
|
||||||
{
|
{
|
||||||
static CCEGLView* s_pEglView = NULL;
|
static CCEGLView* s_pEglView = NULL;
|
||||||
if (s_pEglView == NULL)
|
if (s_pEglView == NULL)
|
||||||
{
|
{
|
||||||
s_pEglView = new CCEGLView();
|
s_pEglView = new CCEGLView();
|
||||||
}
|
}
|
||||||
return *s_pEglView;
|
return s_pEglView;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
/**
|
/**
|
||||||
@brief get the shared main open gl window
|
@brief get the shared main open gl window
|
||||||
*/
|
*/
|
||||||
static CCEGLView& sharedOpenGLView();
|
static CCEGLView* sharedOpenGLView();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -1025,7 +1025,7 @@ CCSpriteFrame* CCSprite::displayFrame(void)
|
||||||
return CCSpriteFrame::createWithTexture(m_pobTexture,
|
return CCSpriteFrame::createWithTexture(m_pobTexture,
|
||||||
CC_RECT_POINTS_TO_PIXELS(m_obRect),
|
CC_RECT_POINTS_TO_PIXELS(m_obRect),
|
||||||
m_bRectRotated,
|
m_bRectRotated,
|
||||||
m_obUnflippedOffsetPositionFromCenter,
|
CC_POINT_POINTS_TO_PIXELS(m_obUnflippedOffsetPositionFromCenter),
|
||||||
CC_SIZE_POINTS_TO_PIXELS(m_tContentSize));
|
CC_SIZE_POINTS_TO_PIXELS(m_tContentSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
dataSize = widthBlocks * heightBlocks * ((blockSize * bpp) / 8);
|
dataSize = widthBlocks * heightBlocks * ((blockSize * bpp) / 8);
|
||||||
float packetLength = (dataLength - dataOffset);
|
unsigned int packetLength = (dataLength - dataOffset);
|
||||||
packetLength = packetLength > dataSize ? dataSize : packetLength;
|
packetLength = packetLength > dataSize ? dataSize : packetLength;
|
||||||
|
|
||||||
//Make record to the mipmaps array and increment coutner
|
//Make record to the mipmaps array and increment coutner
|
||||||
|
|
|
@ -349,20 +349,17 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
||||||
std::string externalTilesetFilename = valueForKey("source", attributeDict);
|
std::string externalTilesetFilename = valueForKey("source", attributeDict);
|
||||||
if (externalTilesetFilename != "")
|
if (externalTilesetFilename != "")
|
||||||
{
|
{
|
||||||
if (m_sTMXFileName.length() == 0)
|
if (m_sTMXFileName.find_last_of("/") != string::npos)
|
||||||
{
|
{
|
||||||
string pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(m_sResources.c_str());
|
string dir = m_sTMXFileName.substr(0, m_sTMXFileName.find_last_of("/") + 1);
|
||||||
if (pszFullPath.find_last_of("/\\") != pszFullPath.length()-1)
|
externalTilesetFilename = dir + externalTilesetFilename;
|
||||||
{
|
|
||||||
pszFullPath.append("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(externalTilesetFilename.c_str(), pszFullPath.c_str() );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(externalTilesetFilename.c_str(), pTMXMapInfo->getTMXFileName());
|
externalTilesetFilename = m_sResources + "/" + externalTilesetFilename;
|
||||||
}
|
}
|
||||||
|
externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(externalTilesetFilename.c_str());
|
||||||
|
|
||||||
pTMXMapInfo->parseXMLFile(externalTilesetFilename.c_str());
|
pTMXMapInfo->parseXMLFile(externalTilesetFilename.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -448,19 +445,15 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
||||||
|
|
||||||
// build full path
|
// build full path
|
||||||
std::string imagename = valueForKey("source", attributeDict);
|
std::string imagename = valueForKey("source", attributeDict);
|
||||||
if (m_sTMXFileName.length() == 0)
|
|
||||||
{
|
|
||||||
string pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(m_sResources.c_str());
|
|
||||||
if (pszFullPath.find_last_of("/\\") != pszFullPath.length()-1)
|
|
||||||
{
|
|
||||||
pszFullPath.append("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
tileset->m_sSourceImage = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(imagename.c_str(), pszFullPath.c_str() );
|
if (m_sTMXFileName.find_last_of("/") != string::npos)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
tileset->m_sSourceImage = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(imagename.c_str(), pTMXMapInfo->getTMXFileName());
|
string dir = m_sTMXFileName.substr(0, m_sTMXFileName.find_last_of("/") + 1);
|
||||||
|
tileset->m_sSourceImage = dir + imagename;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tileset->m_sSourceImage = m_sResources + "/" + imagename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(elementName == "data")
|
else if(elementName == "data")
|
||||||
|
|
|
@ -157,7 +157,9 @@ void CCTileMapAtlas::setTile(const ccColor3B& tile, const ccGridSize& position)
|
||||||
|
|
||||||
// XXX: this method consumes a lot of memory
|
// XXX: this method consumes a lot of memory
|
||||||
// XXX: a tree of something like that shall be impolemented
|
// XXX: a tree of something like that shall be impolemented
|
||||||
CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::createWithFormat("%d,%d", position.x, position.y)->getCString());
|
CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::createWithFormat("%ld,%ld",
|
||||||
|
(long)position.x,
|
||||||
|
(long)position.y)->getCString());
|
||||||
this->updateAtlasValueAt(position, tile, num->getValue());
|
this->updateAtlasValueAt(position, tile, num->getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,16 +62,16 @@ bool CCEditBoxImplIOS::initWithSize(const CCSize& size)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CCEGLViewProtocol& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLViewProtocol* eglView = CCEGLView::sharedOpenGLView();
|
||||||
|
|
||||||
CGRect rect;
|
CGRect rect;
|
||||||
if (eglView.isRetinaEnabled())
|
if (eglView->isRetinaEnabled())
|
||||||
{
|
{
|
||||||
rect = CGRectMake(0, 0, size.width,size.height);
|
rect = CGRectMake(0, 0, size.width,size.height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rect = CGRectMake(0, 0, size.width * eglView.getScaleX(),size.height * eglView.getScaleY());
|
rect = CGRectMake(0, 0, size.width * eglView->getScaleX(),size.height * eglView->getScaleY());
|
||||||
}
|
}
|
||||||
m_pSysEdit = [[EditBoxImplIOS alloc] initWithFrame:rect editBox:this];
|
m_pSysEdit = [[EditBoxImplIOS alloc] initWithFrame:rect editBox:this];
|
||||||
if (!m_pSysEdit) break;
|
if (!m_pSysEdit) break;
|
||||||
|
@ -198,18 +198,18 @@ void CCEditBoxImplIOS::setPlaceHolder(const char* pText)
|
||||||
static CGPoint convertDesignCoordToScreenCoord(const CCPoint& designCoord)
|
static CGPoint convertDesignCoordToScreenCoord(const CCPoint& designCoord)
|
||||||
{
|
{
|
||||||
float viewH = (float)[[EAGLView sharedEGLView] getHeight];
|
float viewH = (float)[[EAGLView sharedEGLView] getHeight];
|
||||||
CCEGLViewProtocol& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLViewProtocol* eglView = CCEGLView::sharedOpenGLView();
|
||||||
CCPoint visiblePos;
|
CCPoint visiblePos;
|
||||||
if (eglView.isRetinaEnabled())
|
if (eglView->isRetinaEnabled())
|
||||||
{
|
{
|
||||||
visiblePos = ccp(designCoord.x, designCoord.y);
|
visiblePos = ccp(designCoord.x, designCoord.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
visiblePos = ccp(designCoord.x * eglView.getScaleX(), designCoord.y * eglView.getScaleY());
|
visiblePos = ccp(designCoord.x * eglView->getScaleX(), designCoord.y * eglView->getScaleY());
|
||||||
}
|
}
|
||||||
|
|
||||||
CCPoint screenGLPos = ccpAdd(visiblePos, eglView.getViewPortRect().origin);
|
CCPoint screenGLPos = ccpAdd(visiblePos, eglView->getViewPortRect().origin);
|
||||||
CGPoint screenPos = CGPointMake(screenGLPos.x, viewH - screenGLPos.y);
|
CGPoint screenPos = CGPointMake(screenGLPos.x, viewH - screenGLPos.y);
|
||||||
return screenPos;
|
return screenPos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
// initialize director
|
// initialize director
|
||||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||||
|
|
||||||
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
|
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||||
|
|
||||||
TargetPlatform target = getTargetPlatform();
|
TargetPlatform target = getTargetPlatform();
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
||||||
|
|
||||||
// don't enable retina because we don't have ipad hd resource
|
// don't enable retina because we don't have ipad hd resource
|
||||||
CCEGLView::sharedOpenGLView().setDesignResolutionSize(960, 640, kResolutionNoBorder);
|
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder);
|
||||||
}
|
}
|
||||||
else if (target == kTargetIphone)
|
else if (target == kTargetIphone)
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
// android, windows, blackberry, linux or mac
|
// android, windows, blackberry, linux or mac
|
||||||
// use 960*640 resources as design resolution size
|
// use 960*640 resources as design resolution size
|
||||||
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphonehd");
|
||||||
CCEGLView::sharedOpenGLView().setDesignResolutionSize(960, 640, kResolutionNoBorder);
|
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(960, 640, kResolutionNoBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
|
|
|
@ -41,7 +41,7 @@ bool HelloWorld::init()
|
||||||
this,
|
this,
|
||||||
menu_selector(HelloWorld::menuCloseCallback));
|
menu_selector(HelloWorld::menuCloseCallback));
|
||||||
|
|
||||||
if (CCApplication::sharedApplication().getTargetPlatform() == kTargetIphone)
|
if (CCApplication::sharedApplication()->getTargetPlatform() == kTargetIphone)
|
||||||
{
|
{
|
||||||
pCloseItem->setPosition(ccp(visibleSize.width - 20 + origin.x, 20 + origin.y));
|
pCloseItem->setPosition(ccp(visibleSize.width - 20 + origin.x, 20 + origin.y));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,23 +30,16 @@ done
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
|
|
||||||
if [ -z "${NDK_ROOT+aaa}" ]; then
|
if [ -z "${NDK_ROOT+aaa}" ];then
|
||||||
# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"
|
echo "please define NDK_ROOT"
|
||||||
NDK_ROOT="$HOME/bin/android-ndk"
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${COCOS2DX_ROOT+aaa}" ]; then
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
# ... if COCOS2DX_ROOT is not set
|
|
||||||
# ... find current working directory
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
# ... use paths relative to current directory
|
# ... use paths relative to current directory
|
||||||
COCOS2DX_ROOT="$DIR/../../.."
|
COCOS2DX_ROOT="$DIR/../../.."
|
||||||
APP_ROOT="$DIR/.."
|
APP_ROOT="$DIR/.."
|
||||||
APP_ANDROID_ROOT="$DIR"
|
APP_ANDROID_ROOT="$DIR"
|
||||||
else
|
|
||||||
APP_ROOT="$COCOS2DX_ROOT"/samples/"$APPNAME"
|
|
||||||
APP_ANDROID_ROOT="$COCOS2DX_ROOT"/samples/"$APPNAME"/proj.android
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "NDK_ROOT = $NDK_ROOT"
|
echo "NDK_ROOT = $NDK_ROOT"
|
||||||
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
||||||
|
|
|
@ -24,11 +24,11 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
||||||
{
|
{
|
||||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||||
{
|
{
|
||||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||||
view->setFrameSize(w, h);
|
view->setFrameSize(w, h);
|
||||||
|
|
||||||
AppDelegate *pAppDelegate = new AppDelegate();
|
AppDelegate *pAppDelegate = new AppDelegate();
|
||||||
CCApplication::sharedApplication().run();
|
CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,10 +25,10 @@ int main(int argc, char **argv)
|
||||||
height = 600;
|
height = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::sharedApplication().setResourceRootPath("app/native/Resources/");
|
CCApplication::sharedApplication()->setResourceRootPath("app/native/Resources/");
|
||||||
|
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setFrameSize(width, height);
|
eglView->setFrameSize(width, height);
|
||||||
|
|
||||||
return CCApplication::sharedApplication().run();
|
return CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ static AppDelegate s_sharedApplication;
|
||||||
|
|
||||||
[[UIApplication sharedApplication] setStatusBarHidden: YES];
|
[[UIApplication sharedApplication] setStatusBarHidden: YES];
|
||||||
|
|
||||||
cocos2d::CCApplication::sharedApplication().run();
|
cocos2d::CCApplication::sharedApplication()->run();
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,14 +87,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.
|
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.
|
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||||
*/
|
*/
|
||||||
cocos2d::CCApplication::sharedApplication().applicationDidEnterBackground();
|
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
- (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.
|
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::CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||||
|
|
|
@ -9,8 +9,8 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// create the application instance
|
// create the application instance
|
||||||
AppDelegate app;
|
AppDelegate app;
|
||||||
CCApplication::sharedApplication().setResourceRootPath("../Resources/");
|
CCApplication::sharedApplication()->setResourceRootPath("../Resources/");
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setFrameSize(960, 640);
|
eglView->setFrameSize(960, 640);
|
||||||
return CCApplication::sharedApplication().run();
|
return CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,7 @@ static AppDelegate s_sharedApplication;
|
||||||
[window makeKeyAndOrderFront:self];
|
[window makeKeyAndOrderFront:self];
|
||||||
[window setAcceptsMouseMovedEvents:NO];
|
[window setAcceptsMouseMovedEvents:NO];
|
||||||
|
|
||||||
// set cocos2d-x's opengl view
|
cocos2d::CCApplication::sharedApplication()->run();
|
||||||
cocos2d::CCApplication::sharedApplication().run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
|
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
|
||||||
|
|
|
@ -14,7 +14,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
// create the application instance
|
// create the application instance
|
||||||
AppDelegate app;
|
AppDelegate app;
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setFrameSize(960, 640 );
|
eglView->setFrameSize(960, 640 );
|
||||||
return CCApplication::sharedApplication().run();
|
return CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,9 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
{
|
{
|
||||||
// initialize director
|
// initialize director
|
||||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||||
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
|
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||||
|
|
||||||
|
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionShowAll);
|
||||||
|
|
||||||
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
|
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
|
||||||
// pDirector->enableRetinaDisplay(true);
|
// pDirector->enableRetinaDisplay(true);
|
||||||
|
|
|
@ -30,23 +30,16 @@ done
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
|
|
||||||
if [ -z "${NDK_ROOT+aaa}" ]; then
|
if [ -z "${NDK_ROOT+aaa}" ];then
|
||||||
# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"
|
echo "please define NDK_ROOT"
|
||||||
NDK_ROOT="$HOME/bin/android-ndk"
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${COCOS2DX_ROOT+aaa}" ]; then
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
# ... if COCOS2DX_ROOT is not set
|
|
||||||
# ... find current working directory
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
# ... use paths relative to current directory
|
# ... use paths relative to current directory
|
||||||
COCOS2DX_ROOT="$DIR/../../.."
|
COCOS2DX_ROOT="$DIR/../../.."
|
||||||
APP_ROOT="$DIR/.."
|
APP_ROOT="$DIR/.."
|
||||||
APP_ANDROID_ROOT="$DIR"
|
APP_ANDROID_ROOT="$DIR"
|
||||||
else
|
|
||||||
APP_ROOT="$COCOS2DX_ROOT"/samples/"$APPNAME"
|
|
||||||
APP_ANDROID_ROOT="$COCOS2DX_ROOT"/samples/"$APPNAME"/proj.android
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "NDK_ROOT = $NDK_ROOT"
|
echo "NDK_ROOT = $NDK_ROOT"
|
||||||
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
||||||
|
|
|
@ -23,11 +23,11 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
||||||
{
|
{
|
||||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||||
{
|
{
|
||||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||||
view->setFrameSize(w, h);
|
view->setFrameSize(w, h);
|
||||||
|
|
||||||
AppDelegate *pAppDelegate = new AppDelegate();
|
AppDelegate *pAppDelegate = new AppDelegate();
|
||||||
CCApplication::sharedApplication().run();
|
CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,7 +62,7 @@ static AppDelegate s_sharedApplication;
|
||||||
|
|
||||||
[[UIApplication sharedApplication] setStatusBarHidden: YES];
|
[[UIApplication sharedApplication] setStatusBarHidden: YES];
|
||||||
|
|
||||||
cocos2d::CCApplication::sharedApplication().run();
|
cocos2d::CCApplication::sharedApplication()->run();
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,14 +87,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.
|
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.
|
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||||
*/
|
*/
|
||||||
cocos2d::CCApplication::sharedApplication().applicationDidEnterBackground();
|
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
- (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.
|
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::CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
15426A5B15B5722100712A7F /* CocosDenshion.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426A4815B5722100712A7F /* CocosDenshion.m */; };
|
15426A5B15B5722100712A7F /* CocosDenshion.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426A4815B5722100712A7F /* CocosDenshion.m */; };
|
||||||
15426A5C15B5722100712A7F /* SimpleAudioEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15426A4915B5722100712A7F /* SimpleAudioEngine.mm */; };
|
15426A5C15B5722100712A7F /* SimpleAudioEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 15426A4915B5722100712A7F /* SimpleAudioEngine.mm */; };
|
||||||
15426A5D15B5722100712A7F /* SimpleAudioEngine_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426A4B15B5722100712A7F /* SimpleAudioEngine_objc.m */; };
|
15426A5D15B5722100712A7F /* SimpleAudioEngine_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 15426A4B15B5722100712A7F /* SimpleAudioEngine_objc.m */; };
|
||||||
15DD6D83156DD1EF003E7567 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 15DD6D81156DD1EF003E7567 /* fps_images.png */; };
|
|
||||||
15F990C2159C0DED00848A44 /* fps_images-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = 15F990C0159C0DED00848A44 /* fps_images-hd.png */; };
|
|
||||||
15F990C3159C0DED00848A44 /* fps_images-ipadhd.png in Resources */ = {isa = PBXBuildFile; fileRef = 15F990C1159C0DED00848A44 /* fps_images-ipadhd.png */; };
|
|
||||||
506EDB88102F4C4000A389B3 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EDB87102F4C4000A389B3 /* libz.dylib */; };
|
506EDB88102F4C4000A389B3 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EDB87102F4C4000A389B3 /* libz.dylib */; };
|
||||||
506EDBA5102F4C9F00A389B3 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */; };
|
506EDBA5102F4C9F00A389B3 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */; };
|
||||||
78947C6D14EBB9B100DBD5A6 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 78947C5E14EBB9B000DBD5A6 /* background.mp3 */; };
|
78947C6D14EBB9B100DBD5A6 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 78947C5E14EBB9B000DBD5A6 /* background.mp3 */; };
|
||||||
|
@ -120,9 +117,6 @@
|
||||||
15426A4915B5722100712A7F /* SimpleAudioEngine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleAudioEngine.mm; sourceTree = "<group>"; };
|
15426A4915B5722100712A7F /* SimpleAudioEngine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleAudioEngine.mm; sourceTree = "<group>"; };
|
||||||
15426A4A15B5722100712A7F /* SimpleAudioEngine_objc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine_objc.h; sourceTree = "<group>"; };
|
15426A4A15B5722100712A7F /* SimpleAudioEngine_objc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine_objc.h; sourceTree = "<group>"; };
|
||||||
15426A4B15B5722100712A7F /* SimpleAudioEngine_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleAudioEngine_objc.m; sourceTree = "<group>"; };
|
15426A4B15B5722100712A7F /* SimpleAudioEngine_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleAudioEngine_objc.m; sourceTree = "<group>"; };
|
||||||
15DD6D81156DD1EF003E7567 /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = "<group>"; };
|
|
||||||
15F990C0159C0DED00848A44 /* fps_images-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fps_images-hd.png"; sourceTree = "<group>"; };
|
|
||||||
15F990C1159C0DED00848A44 /* fps_images-ipadhd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fps_images-ipadhd.png"; sourceTree = "<group>"; };
|
|
||||||
1D6058910D05DD3D006BFB54 /* HelloLua.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloLua.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
1D6058910D05DD3D006BFB54 /* HelloLua.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloLua.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
506EDB87102F4C4000A389B3 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
506EDB87102F4C4000A389B3 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
||||||
506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
|
506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
|
||||||
|
@ -356,9 +350,6 @@
|
||||||
D4EF94DA15BD311E00D803EB /* Icon-72.png */,
|
D4EF94DA15BD311E00D803EB /* Icon-72.png */,
|
||||||
D4EF94D815BD311A00D803EB /* Icon-114.png */,
|
D4EF94D815BD311A00D803EB /* Icon-114.png */,
|
||||||
D4EF94D615BD311700D803EB /* Icon-57.png */,
|
D4EF94D615BD311700D803EB /* Icon-57.png */,
|
||||||
15F990C0159C0DED00848A44 /* fps_images-hd.png */,
|
|
||||||
15F990C1159C0DED00848A44 /* fps_images-ipadhd.png */,
|
|
||||||
15DD6D81156DD1EF003E7567 /* fps_images.png */,
|
|
||||||
78947C5E14EBB9B000DBD5A6 /* background.mp3 */,
|
78947C5E14EBB9B000DBD5A6 /* background.mp3 */,
|
||||||
78947C5F14EBB9B000DBD5A6 /* crop.png */,
|
78947C5F14EBB9B000DBD5A6 /* crop.png */,
|
||||||
78DC4C9815490B9500317402 /* Default.png */,
|
78DC4C9815490B9500317402 /* Default.png */,
|
||||||
|
@ -591,9 +582,6 @@
|
||||||
78947C7814EBB9B100DBD5A6 /* menu1.png in Resources */,
|
78947C7814EBB9B100DBD5A6 /* menu1.png in Resources */,
|
||||||
78947C7914EBB9B100DBD5A6 /* menu2.png in Resources */,
|
78947C7914EBB9B100DBD5A6 /* menu2.png in Resources */,
|
||||||
78DC4C9A15490B9500317402 /* Default.png in Resources */,
|
78DC4C9A15490B9500317402 /* Default.png in Resources */,
|
||||||
15DD6D83156DD1EF003E7567 /* fps_images.png in Resources */,
|
|
||||||
15F990C2159C0DED00848A44 /* fps_images-hd.png in Resources */,
|
|
||||||
15F990C3159C0DED00848A44 /* fps_images-ipadhd.png in Resources */,
|
|
||||||
F2837A6C15B9606900A5707B /* Android.mk in Resources */,
|
F2837A6C15B9606900A5707B /* Android.mk in Resources */,
|
||||||
F2837A6D15B9606900A5707B /* liblua.vcproj in Resources */,
|
F2837A6D15B9606900A5707B /* liblua.vcproj in Resources */,
|
||||||
D4EF94D715BD311700D803EB /* Icon-57.png in Resources */,
|
D4EF94D715BD311700D803EB /* Icon-57.png in Resources */,
|
||||||
|
|
|
@ -24,9 +24,9 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
// create the application instance
|
// create the application instance
|
||||||
AppDelegate app;
|
AppDelegate app;
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setFrameSize(480, 320);
|
eglView->setFrameSize(480, 320);
|
||||||
int ret = CCApplication::sharedApplication().run();
|
int ret = CCApplication::sharedApplication()->run();
|
||||||
|
|
||||||
#ifdef USE_WIN32_CONSOLE
|
#ifdef USE_WIN32_CONSOLE
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
|
|
|
@ -20,10 +20,34 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
{
|
{
|
||||||
// initialize director
|
// initialize director
|
||||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||||
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
|
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||||
|
|
||||||
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
|
TargetPlatform target = getTargetPlatform();
|
||||||
// pDirector->enableRetinaDisplay(true);
|
|
||||||
|
if (target == kTargetIpad)
|
||||||
|
{
|
||||||
|
// ipad
|
||||||
|
|
||||||
|
if (pDirector->enableRetinaDisplay(true))
|
||||||
|
{
|
||||||
|
// ipad hd
|
||||||
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipadhd");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (target == kTargetIphone)
|
||||||
|
{
|
||||||
|
// iphone
|
||||||
|
|
||||||
|
if (pDirector->enableRetinaDisplay(true))
|
||||||
|
{
|
||||||
|
// iphone hd
|
||||||
|
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
pDirector->setDisplayStats(true);
|
pDirector->setDisplayStats(true);
|
||||||
|
|
|
@ -10,7 +10,7 @@ CurrentLanguageTest::CurrentLanguageTest()
|
||||||
CCLabelTTF *labelLanguage = CCLabelTTF::create("", "Arial", 20);
|
CCLabelTTF *labelLanguage = CCLabelTTF::create("", "Arial", 20);
|
||||||
labelLanguage->setPosition(ccp(s.width/2, s.height/2));
|
labelLanguage->setPosition(ccp(s.width/2, s.height/2));
|
||||||
|
|
||||||
ccLanguageType currentLanguageType = CCApplication::sharedApplication().getCurrentLanguage();
|
ccLanguageType currentLanguageType = CCApplication::sharedApplication()->getCurrentLanguage();
|
||||||
switch (currentLanguageType)
|
switch (currentLanguageType)
|
||||||
{
|
{
|
||||||
case kLanguageEnglish:
|
case kLanguageEnglish:
|
||||||
|
|
|
@ -15,8 +15,8 @@ USING_NS_CC_EXT;
|
||||||
|
|
||||||
EditBoxTest::EditBoxTest()
|
EditBoxTest::EditBoxTest()
|
||||||
{
|
{
|
||||||
CCPoint visibleOrigin = CCEGLView::sharedOpenGLView().getVisibleOrigin();
|
CCPoint visibleOrigin = CCEGLView::sharedOpenGLView()->getVisibleOrigin();
|
||||||
CCSize visibleSize = CCEGLView::sharedOpenGLView().getVisibleSize();
|
CCSize visibleSize = CCEGLView::sharedOpenGLView()->getVisibleSize();
|
||||||
|
|
||||||
CCSprite* pBg = CCSprite::create("Images/HelloWorld.png");
|
CCSprite* pBg = CCSprite::create("Images/HelloWorld.png");
|
||||||
pBg->setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2));
|
pBg->setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2));
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
a6ca8414e453957fa2fbc456b47160ac402ea35e
|
|
@ -30,23 +30,16 @@ done
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
|
|
||||||
if [ -z "${NDK_ROOT+aaa}" ]; then
|
if [ -z "${NDK_ROOT+aaa}" ];then
|
||||||
# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"
|
echo "please define NDK_ROOT"
|
||||||
NDK_ROOT="$HOME/bin/android-ndk"
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${COCOS2DX_ROOT+aaa}" ]; then
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
# ... if COCOS2DX_ROOT is not set
|
|
||||||
# ... find current working directory
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
# ... use paths relative to current directory
|
# ... use paths relative to current directory
|
||||||
COCOS2DX_ROOT="$DIR/../../.."
|
COCOS2DX_ROOT="$DIR/../../.."
|
||||||
APP_ROOT="$DIR/.."
|
APP_ROOT="$DIR/.."
|
||||||
APP_ANDROID_ROOT="$DIR"
|
APP_ANDROID_ROOT="$DIR"
|
||||||
else
|
|
||||||
APP_ROOT="$COCOS2DX_ROOT"/samples/"$APPNAME"
|
|
||||||
APP_ANDROID_ROOT="$COCOS2DX_ROOT"/samples/"$APPNAME"/proj.android
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "NDK_ROOT = $NDK_ROOT"
|
echo "NDK_ROOT = $NDK_ROOT"
|
||||||
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
||||||
|
|
|
@ -24,11 +24,11 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
||||||
{
|
{
|
||||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||||
{
|
{
|
||||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||||
view->setFrameSize(w, h);
|
view->setFrameSize(w, h);
|
||||||
|
|
||||||
AppDelegate *pAppDelegate = new AppDelegate();
|
AppDelegate *pAppDelegate = new AppDelegate();
|
||||||
CCApplication::sharedApplication().run();
|
CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,10 +23,10 @@ int main(int argc, char **argv)
|
||||||
height = 600;
|
height = 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCApplication::sharedApplication().setResourceRootPath("app/native/Resources/");
|
CCApplication::sharedApplication()->setResourceRootPath("app/native/Resources/");
|
||||||
|
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setFrameSize(width, height);
|
eglView->setFrameSize(width, height);
|
||||||
|
|
||||||
return CCApplication::sharedApplication().run();
|
return CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ static AppDelegate s_sharedApplication;
|
||||||
|
|
||||||
[[UIApplication sharedApplication] setStatusBarHidden:true];
|
[[UIApplication sharedApplication] setStatusBarHidden:true];
|
||||||
|
|
||||||
cocos2d::CCApplication::sharedApplication().run();
|
cocos2d::CCApplication::sharedApplication()->run();
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -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.
|
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.
|
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||||
*/
|
*/
|
||||||
cocos2d::CCApplication::sharedApplication().applicationDidEnterBackground();
|
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
- (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.
|
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::CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
9dc4229a0e1a4577d300081dc8e3abc2a1e2f1f2
|
13fb5118be504c0cb162fe003715353d23316944
|
|
@ -6,9 +6,9 @@ USING_NS_CC;
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
// create the application instance
|
// create the application instance
|
||||||
AppDelegate app;
|
AppDelegate app;
|
||||||
CCApplication::sharedApplication().setResourceRootPath("../Resources/");
|
CCApplication::sharedApplication()->setResourceRootPath("../Resources/");
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setFrameSize(480, 320);
|
eglView->setFrameSize(480, 320);
|
||||||
|
|
||||||
return CCApplication::sharedApplication().run();
|
return CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,7 @@
|
||||||
[window makeKeyAndOrderFront:self];
|
[window makeKeyAndOrderFront:self];
|
||||||
[window setAcceptsMouseMovedEvents:NO];
|
[window setAcceptsMouseMovedEvents:NO];
|
||||||
|
|
||||||
// set cocos2d-x's opengl view
|
cocos2d::CCApplication::sharedApplication()->run();
|
||||||
cocos2d::CCApplication::sharedApplication().run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
|
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
756534a58c37d049b7033828eccf2ec0fb0a221a
|
dbcfed31d505836a286d749e72f74276b36a50e7
|
|
@ -14,7 +14,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
// create the application instance
|
// create the application instance
|
||||||
AppDelegate app;
|
AppDelegate app;
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setFrameSize(480, 320);
|
eglView->setFrameSize(480, 320);
|
||||||
return CCApplication::sharedApplication().run();
|
return CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
{
|
{
|
||||||
// initialize director
|
// initialize director
|
||||||
CCDirector *pDirector = CCDirector::sharedDirector();
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||||
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
|
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||||
|
|
||||||
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
|
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
|
||||||
// pDirector->enableRetinaDisplay(true);
|
// pDirector->enableRetinaDisplay(true);
|
||||||
|
|
|
@ -30,23 +30,16 @@ done
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
|
|
||||||
if [ -z "${NDK_ROOT+aaa}" ]; then
|
if [ -z "${NDK_ROOT+aaa}" ];then
|
||||||
# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"
|
echo "please define NDK_ROOT"
|
||||||
NDK_ROOT="$HOME/bin/android-ndk"
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${COCOS2DX_ROOT+aaa}" ]; then
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
# ... if COCOS2DX_ROOT is not set
|
|
||||||
# ... find current working directory
|
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
# ... use paths relative to current directory
|
# ... use paths relative to current directory
|
||||||
COCOS2DX_ROOT="$DIR/../../.."
|
COCOS2DX_ROOT="$DIR/../../.."
|
||||||
APP_ROOT="$DIR/.."
|
APP_ROOT="$DIR/.."
|
||||||
APP_ANDROID_ROOT="$DIR"
|
APP_ANDROID_ROOT="$DIR"
|
||||||
else
|
|
||||||
APP_ROOT="$COCOS2DX_ROOT"/samples/"$APPNAME"
|
|
||||||
APP_ANDROID_ROOT="$COCOS2DX_ROOT"/samples/"$APPNAME"/proj.android
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "NDK_ROOT = $NDK_ROOT"
|
echo "NDK_ROOT = $NDK_ROOT"
|
||||||
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
|
||||||
|
|
|
@ -24,11 +24,11 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
||||||
{
|
{
|
||||||
if (!CCDirector::sharedDirector()->getOpenGLView())
|
if (!CCDirector::sharedDirector()->getOpenGLView())
|
||||||
{
|
{
|
||||||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
CCEGLView *view = CCEGLView::sharedOpenGLView();
|
||||||
view->setFrameSize(w, h);
|
view->setFrameSize(w, h);
|
||||||
|
|
||||||
AppDelegate *pAppDelegate = new AppDelegate();
|
AppDelegate *pAppDelegate = new AppDelegate();
|
||||||
CCApplication::sharedApplication().run();
|
CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,7 +46,7 @@ static AppDelegate s_sharedApplication;
|
||||||
|
|
||||||
[[UIApplication sharedApplication] setStatusBarHidden: YES];
|
[[UIApplication sharedApplication] setStatusBarHidden: YES];
|
||||||
|
|
||||||
cocos2d::CCApplication::sharedApplication().run();
|
cocos2d::CCApplication::sharedApplication()->run();
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,14 +71,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.
|
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.
|
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||||
*/
|
*/
|
||||||
cocos2d::CCApplication::sharedApplication().applicationDidEnterBackground();
|
cocos2d::CCApplication::sharedApplication()->applicationDidEnterBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
- (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.
|
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::CCApplication::sharedApplication()->applicationWillEnterForeground();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||||
|
|
|
@ -9,8 +9,8 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
// create the application instance
|
// create the application instance
|
||||||
AppDelegate app;
|
AppDelegate app;
|
||||||
CCApplication::sharedApplication().setResourceRootPath("../Resources/");
|
CCApplication::sharedApplication()->setResourceRootPath("../Resources/");
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setFrameSize(480, 320);
|
eglView->setFrameSize(480, 320);
|
||||||
return CCApplication::sharedApplication().run();
|
return CCApplication::sharedApplication()->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,10 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
// create the application instance
|
// create the application instance
|
||||||
AppDelegate app;
|
AppDelegate app;
|
||||||
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
|
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
|
||||||
eglView.setFrameSize(480, 320);
|
eglView->setFrameSize(480, 320);
|
||||||
|
|
||||||
int ret = CCApplication::sharedApplication().run();
|
int ret = CCApplication::sharedApplication()->run();
|
||||||
|
|
||||||
#ifdef USE_WIN32_CONSOLE
|
#ifdef USE_WIN32_CONSOLE
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
#include "cocos2d.h"
|
||||||
|
#include "CCEGLView.h"
|
||||||
|
#include "AppDelegate.h"
|
||||||
|
#include "CCLuaEngine.h"
|
||||||
|
#include "SimpleAudioEngine.h"
|
||||||
|
|
||||||
|
using namespace CocosDenshion;
|
||||||
|
|
||||||
|
USING_NS_CC;
|
||||||
|
|
||||||
|
AppDelegate::AppDelegate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AppDelegate::~AppDelegate()
|
||||||
|
{
|
||||||
|
SimpleAudioEngine::end();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppDelegate::applicationDidFinishLaunching()
|
||||||
|
{
|
||||||
|
// initialize director
|
||||||
|
CCDirector *pDirector = CCDirector::sharedDirector();
|
||||||
|
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
|
||||||
|
|
||||||
|
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
|
||||||
|
// pDirector->enableRetinaDisplay(true);
|
||||||
|
|
||||||
|
// turn on display FPS
|
||||||
|
pDirector->setDisplayStats(true);
|
||||||
|
|
||||||
|
// set FPS. the default value is 1.0/60 if you don't call this
|
||||||
|
pDirector->setAnimationInterval(1.0 / 60);
|
||||||
|
|
||||||
|
// register lua engine
|
||||||
|
CCScriptEngineProtocol* pEngine = CCLuaEngine::engine();
|
||||||
|
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||||
|
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
|
CCString* pstrFileContent = CCString::createWithContentsOfFile("luaScript/controller.lua");
|
||||||
|
if (pstrFileContent)
|
||||||
|
{
|
||||||
|
pEngine->executeString(pstrFileContent->getCString());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
std::string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("luaScript/controller.lua");
|
||||||
|
pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
|
||||||
|
pEngine->executeScriptFile(path.c_str());
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
// this function will be called when the app is active again
|
||||||
|
void AppDelegate::applicationWillEnterForeground()
|
||||||
|
{
|
||||||
|
CCDirector::sharedDirector()->startAnimation();
|
||||||
|
|
||||||
|
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef __APP_DELEGATE_H__
|
||||||
|
#define __APP_DELEGATE_H__
|
||||||
|
|
||||||
|
#include "cocos2d.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The cocos2d Application.
|
||||||
|
|
||||||
|
The reason for implement as private inheritance is to hide some interface call by CCDirector.
|
||||||
|
*/
|
||||||
|
class AppDelegate : private cocos2d::CCApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AppDelegate();
|
||||||
|
virtual ~AppDelegate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Implement CCDirector and CCScene init code here.
|
||||||
|
@return true Initialize success, app continue.
|
||||||
|
@return false Initialize failed, app terminate.
|
||||||
|
*/
|
||||||
|
virtual bool applicationDidFinishLaunching();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The function be called when the application enter background
|
||||||
|
@param the pointer of the application
|
||||||
|
*/
|
||||||
|
virtual void applicationDidEnterBackground();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The function be called when the application enter foreground
|
||||||
|
@param the pointer of the application
|
||||||
|
*/
|
||||||
|
virtual void applicationWillEnterForeground();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __APP_DELEGATE_H__
|
||||||
|
|
|
@ -0,0 +1,397 @@
|
||||||
|
|
||||||
|
local SceneIdx = -1
|
||||||
|
local MAX_LAYER = 7
|
||||||
|
local s = CCDirector:sharedDirector():getWinSize()
|
||||||
|
|
||||||
|
local function initWithLayer(layer)
|
||||||
|
titleLabel = CCLabelTTF:create("ActionsProgressTest", "Arial", 18)
|
||||||
|
layer:addChild(titleLabel, 1)
|
||||||
|
titleLabel:setPosition(CCPointMake(s.width / 2, s.height - 50))
|
||||||
|
|
||||||
|
subtitleLabel = CCLabelTTF:create("", "Thonburi", 22)
|
||||||
|
layer:addChild(subtitleLabel, 1)
|
||||||
|
subtitleLabel:setPosition( CCPointMake(s.width / 2, s.height - 80))
|
||||||
|
|
||||||
|
-- menu
|
||||||
|
local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2)
|
||||||
|
local item2 = CCMenuItemImage:create(s_pPathR1, s_pPathR2)
|
||||||
|
local item3 = CCMenuItemImage:create(s_pPathF1, s_pPathF2)
|
||||||
|
item1:registerScriptHandler(backCallback)
|
||||||
|
item2:registerScriptHandler(restartCallback)
|
||||||
|
item3:registerScriptHandler(nextCallback)
|
||||||
|
|
||||||
|
local menu = CCMenu:create()
|
||||||
|
menu:addChild(item1)
|
||||||
|
menu:addChild(item2)
|
||||||
|
menu:addChild(item3)
|
||||||
|
menu:setPosition(CCPointMake(0, 0))
|
||||||
|
item1:setPosition(CCPointMake(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
||||||
|
item2:setPosition(CCPointMake(s.width / 2, item2:getContentSize().height / 2))
|
||||||
|
item3:setPosition(CCPointMake(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2))
|
||||||
|
layer:addChild(menu, 1)
|
||||||
|
|
||||||
|
local background = CCLayerColor:create(ccc4(255,0,0,255))
|
||||||
|
layer:addChild(background, -10)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function nextAction()
|
||||||
|
SceneIdx = SceneIdx + 1
|
||||||
|
SceneIdx = math.mod(SceneIdx, MAX_LAYER)
|
||||||
|
return CreateActionProgressLayer(SceneIdx)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function restartAction()
|
||||||
|
return CreateActionProgressLayer(SceneIdx)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function backAction()
|
||||||
|
SceneIdx = SceneIdx - 1
|
||||||
|
if SceneIdx < 0 then
|
||||||
|
SceneIdx = SceneIdx + MAX_LAYER
|
||||||
|
end
|
||||||
|
return CreateActionProgressLayer(SceneIdx)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function nextCallback()
|
||||||
|
local scene = CCScene:create()
|
||||||
|
|
||||||
|
scene:addChild(CreateBackMenuItem())
|
||||||
|
scene:addChild(nextAction())
|
||||||
|
|
||||||
|
CCDirector:sharedDirector():replaceScene(scene)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function restartCallback()
|
||||||
|
local scene = CCScene:create()
|
||||||
|
|
||||||
|
scene:addChild(CreateBackMenuItem())
|
||||||
|
scene:addChild(restartAction())
|
||||||
|
|
||||||
|
CCDirector:sharedDirector():replaceScene(scene)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function backCallback()
|
||||||
|
local scene = CCScene:create()
|
||||||
|
|
||||||
|
scene:addChild(CreateBackMenuItem())
|
||||||
|
scene:addChild(backAction())
|
||||||
|
|
||||||
|
CCDirector:sharedDirector():replaceScene(scene)
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
-- SpriteProgressToRadial
|
||||||
|
------------------------------------
|
||||||
|
local function SpriteProgressToRadial()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
initWithLayer(layer)
|
||||||
|
|
||||||
|
local to1 = CCProgressTo:create(2, 100)
|
||||||
|
local to2 = CCProgressTo:create(2, 100)
|
||||||
|
|
||||||
|
local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1))
|
||||||
|
left:setType(kCCProgressTimerTypeRadial)
|
||||||
|
left:setPosition(CCPointMake(100, s.height / 2))
|
||||||
|
left:runAction(CCRepeatForever:create(to1))
|
||||||
|
layer:addChild(left)
|
||||||
|
|
||||||
|
local right = CCProgressTimer:create(CCSprite:create(s_pPathBlock))
|
||||||
|
right:setType(kCCProgressTimerTypeRadial)
|
||||||
|
-- Makes the ridial CCW
|
||||||
|
right:setReverseProgress(true)
|
||||||
|
right:setPosition(CCPointMake(s.width - 100, s.height / 2))
|
||||||
|
right:runAction(CCRepeatForever:create(to2))
|
||||||
|
layer:addChild(right)
|
||||||
|
|
||||||
|
subtitleLabel:setString("ProgressTo Radial")
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
-- SpriteProgressToHorizontal
|
||||||
|
------------------------------------
|
||||||
|
local function SpriteProgressToHorizontal()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
initWithLayer(layer)
|
||||||
|
|
||||||
|
local to1 = CCProgressTo:create(2, 100)
|
||||||
|
local to2 = CCProgressTo:create(2, 100)
|
||||||
|
|
||||||
|
local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1))
|
||||||
|
left:setType(kCCProgressTimerTypeBar)
|
||||||
|
-- Setup for a bar starting from the left since the midpoint is 0 for the x
|
||||||
|
left:setMidpoint(CCPointMake(0, 0))
|
||||||
|
-- Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
|
||||||
|
left:setBarChangeRate(CCPointMake(1, 0))
|
||||||
|
left:setPosition(CCPointMake(100, s.height / 2))
|
||||||
|
left:runAction(CCRepeatForever:create(to1))
|
||||||
|
layer:addChild(left)
|
||||||
|
|
||||||
|
local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2))
|
||||||
|
right:setType(kCCProgressTimerTypeBar)
|
||||||
|
-- Setup for a bar starting from the left since the midpoint is 1 for the x
|
||||||
|
right:setMidpoint(CCPointMake(1, 0))
|
||||||
|
-- Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
|
||||||
|
right:setBarChangeRate(CCPointMake(1, 0))
|
||||||
|
right:setPosition(CCPointMake(s.width - 100, s.height / 2))
|
||||||
|
right:runAction(CCRepeatForever:create(to2))
|
||||||
|
layer:addChild(right)
|
||||||
|
|
||||||
|
subtitleLabel:setString("ProgressTo Horizontal")
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
-- SpriteProgressToVertical
|
||||||
|
------------------------------------
|
||||||
|
local function SpriteProgressToVertical()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
initWithLayer(layer)
|
||||||
|
|
||||||
|
local to1 = CCProgressTo:create(2, 100)
|
||||||
|
local to2 = CCProgressTo:create(2, 100)
|
||||||
|
|
||||||
|
local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1))
|
||||||
|
left:setType(kCCProgressTimerTypeBar)
|
||||||
|
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
left:setMidpoint(CCPointMake(0,0))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
left:setBarChangeRate(CCPointMake(0, 1))
|
||||||
|
left:setPosition(CCPointMake(100, s.height / 2))
|
||||||
|
left:runAction(CCRepeatForever:create(to1))
|
||||||
|
layer:addChild(left)
|
||||||
|
|
||||||
|
local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2))
|
||||||
|
right:setType(kCCProgressTimerTypeBar)
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
right:setMidpoint(CCPointMake(0, 1))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
right:setBarChangeRate(CCPointMake(0, 1))
|
||||||
|
right:setPosition(CCPointMake(s.width - 100, s.height / 2))
|
||||||
|
right:runAction(CCRepeatForever:create(to2))
|
||||||
|
layer:addChild(right)
|
||||||
|
|
||||||
|
subtitleLabel:setString("ProgressTo Vertical")
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
-- SpriteProgressToRadialMidpointChanged
|
||||||
|
------------------------------------
|
||||||
|
local function SpriteProgressToRadialMidpointChanged()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
initWithLayer(layer)
|
||||||
|
|
||||||
|
local action = CCProgressTo:create(2, 100)
|
||||||
|
|
||||||
|
-- Our image on the left should be a radial progress indicator, clockwise
|
||||||
|
local left = CCProgressTimer:create(CCSprite:create(s_pPathBlock))
|
||||||
|
left:setType(kCCProgressTimerTypeRadial)
|
||||||
|
left:setMidpoint(CCPointMake(0.25, 0.75))
|
||||||
|
left:setPosition(CCPointMake(100, s.height / 2))
|
||||||
|
left:runAction(CCRepeatForever:create(action:copy():autorelease()))
|
||||||
|
layer:addChild(left)
|
||||||
|
|
||||||
|
-- Our image on the left should be a radial progress indicator, counter clockwise
|
||||||
|
local right = CCProgressTimer:create(CCSprite:create(s_pPathBlock))
|
||||||
|
right:setType(kCCProgressTimerTypeRadial)
|
||||||
|
right:setMidpoint(CCPointMake(0.75, 0.25))
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Note the reverse property (default=NO) is only added to the right image. That's how
|
||||||
|
we get a counter clockwise progress.
|
||||||
|
]]
|
||||||
|
right:setPosition(CCPointMake(s.width - 100, s.height / 2))
|
||||||
|
right:runAction(CCRepeatForever:create(action:copy():autorelease()))
|
||||||
|
layer:addChild(right)
|
||||||
|
|
||||||
|
subtitleLabel:setString("Radial w/ Different Midpoints")
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
-- SpriteProgressBarVarious
|
||||||
|
------------------------------------
|
||||||
|
local function SpriteProgressBarVarious()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
initWithLayer(layer)
|
||||||
|
|
||||||
|
local to = CCProgressTo:create(2, 100)
|
||||||
|
|
||||||
|
local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1))
|
||||||
|
left:setType(kCCProgressTimerTypeBar)
|
||||||
|
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
left:setMidpoint(CCPointMake(0.5, 0.5))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
left:setBarChangeRate(CCPointMake(1, 0))
|
||||||
|
left:setPosition(CCPointMake(100, s.height / 2))
|
||||||
|
left:runAction(CCRepeatForever:create(to:copy():autorelease()))
|
||||||
|
layer:addChild(left)
|
||||||
|
|
||||||
|
local middle = CCProgressTimer:create(CCSprite:create(s_pPathSister2))
|
||||||
|
middle:setType(kCCProgressTimerTypeBar)
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
middle:setMidpoint(CCPointMake(0.5, 0.5))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
middle:setBarChangeRate(CCPointMake(1, 1))
|
||||||
|
middle:setPosition(CCPointMake(s.width/2, s.height/2))
|
||||||
|
middle:runAction(CCRepeatForever:create(to:copy():autorelease()))
|
||||||
|
layer:addChild(middle)
|
||||||
|
|
||||||
|
local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2))
|
||||||
|
right:setType(kCCProgressTimerTypeBar)
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
right:setMidpoint(CCPointMake(0.5, 0.5))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
right:setBarChangeRate(CCPointMake(0, 1))
|
||||||
|
right:setPosition(CCPointMake(s.width-100, s.height/2))
|
||||||
|
right:runAction(CCRepeatForever:create(to:copy():autorelease()))
|
||||||
|
layer:addChild(right)
|
||||||
|
|
||||||
|
subtitleLabel:setString("ProgressTo Bar Mid")
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
-- SpriteProgressBarTintAndFade
|
||||||
|
------------------------------------
|
||||||
|
local function SpriteProgressBarTintAndFade()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
initWithLayer(layer)
|
||||||
|
|
||||||
|
local to = CCProgressTo:create(6, 100)
|
||||||
|
local array = CCArray:create()
|
||||||
|
array:addObject(CCTintTo:create(1, 255, 0, 0))
|
||||||
|
array:addObject(CCTintTo:create(1, 0, 255, 0))
|
||||||
|
array:addObject(CCTintTo:create(1, 0, 0, 255))
|
||||||
|
local tint = CCSequence:create(array)
|
||||||
|
local fade = CCSequence:createWithTwoActions(
|
||||||
|
CCFadeTo:create(1.0, 0),
|
||||||
|
CCFadeTo:create(1.0, 255))
|
||||||
|
|
||||||
|
local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1))
|
||||||
|
left:setType(kCCProgressTimerTypeBar)
|
||||||
|
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
left:setMidpoint(CCPointMake(0.5, 0.5))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
left:setBarChangeRate(CCPointMake(1, 0))
|
||||||
|
left:setPosition(CCPointMake(100, s.height / 2))
|
||||||
|
left:runAction(CCRepeatForever:create(to:copy():autorelease()))
|
||||||
|
left:runAction(CCRepeatForever:create(tint:copy():autorelease()))
|
||||||
|
layer:addChild(left)
|
||||||
|
|
||||||
|
left:addChild(CCLabelTTF:create("Tint", "Marker Felt", 20.0))
|
||||||
|
|
||||||
|
local middle = CCProgressTimer:create(CCSprite:create(s_pPathSister2))
|
||||||
|
middle:setType(kCCProgressTimerTypeBar)
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
middle:setMidpoint(CCPointMake(0.5, 0.5))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
middle:setBarChangeRate(CCPointMake(1, 1))
|
||||||
|
middle:setPosition(CCPointMake(s.width / 2, s.height / 2))
|
||||||
|
middle:runAction(CCRepeatForever:create(to:copy():autorelease()))
|
||||||
|
middle:runAction(CCRepeatForever:create(fade:copy():autorelease()))
|
||||||
|
layer:addChild(middle)
|
||||||
|
|
||||||
|
middle:addChild(CCLabelTTF:create("Fade", "Marker Felt", 20.0))
|
||||||
|
|
||||||
|
local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2))
|
||||||
|
right:setType(kCCProgressTimerTypeBar)
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
right:setMidpoint(CCPointMake(0.5, 0.5))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
right:setBarChangeRate(CCPointMake(0, 1))
|
||||||
|
right:setPosition(CCPointMake(s.width - 100, s.height / 2))
|
||||||
|
right:runAction(CCRepeatForever:create(to:copy():autorelease()))
|
||||||
|
right:runAction(CCRepeatForever:create(tint:copy():autorelease()))
|
||||||
|
right:runAction(CCRepeatForever:create(fade:copy():autorelease()))
|
||||||
|
layer:addChild(right)
|
||||||
|
|
||||||
|
right:addChild(CCLabelTTF:create("Tint and Fade", "Marker Felt", 20.0))
|
||||||
|
|
||||||
|
subtitleLabel:setString("ProgressTo Bar Mid")
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
-- SpriteProgressWithSpriteFrame
|
||||||
|
------------------------------------
|
||||||
|
local function SpriteProgressWithSpriteFrame()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
initWithLayer(layer)
|
||||||
|
|
||||||
|
local to = CCProgressTo:create(6, 100)
|
||||||
|
|
||||||
|
CCSpriteFrameCache:sharedSpriteFrameCache():addSpriteFramesWithFile("zwoptex/grossini.plist")
|
||||||
|
|
||||||
|
local left = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_01.png"))
|
||||||
|
left:setType(kCCProgressTimerTypeBar)
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
left:setMidpoint(CCPointMake(0.5, 0.5))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
left:setBarChangeRate(CCPointMake(1, 0))
|
||||||
|
left:setPosition(CCPointMake(100, s.height / 2))
|
||||||
|
left:runAction(CCRepeatForever:create(to:copy():autorelease()))
|
||||||
|
layer:addChild(left)
|
||||||
|
|
||||||
|
local middle = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_02.png"))
|
||||||
|
middle:setType(kCCProgressTimerTypeBar)
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
middle:setMidpoint(CCPointMake(0.5, 0.5))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
middle:setBarChangeRate(CCPointMake(1, 1))
|
||||||
|
middle:setPosition(CCPointMake(s.width / 2, s.height / 2))
|
||||||
|
middle:runAction(CCRepeatForever:create(to:copy():autorelease()))
|
||||||
|
layer:addChild(middle)
|
||||||
|
|
||||||
|
local right = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_03.png"))
|
||||||
|
right:setType(kCCProgressTimerTypeRadial)
|
||||||
|
-- Setup for a bar starting from the bottom since the midpoint is 0 for the y
|
||||||
|
right:setMidpoint(CCPointMake(0.5, 0.5))
|
||||||
|
-- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
|
||||||
|
right:setBarChangeRate(CCPointMake(0, 1))
|
||||||
|
right:setPosition(CCPointMake(s.width - 100, s.height / 2))
|
||||||
|
right:runAction(CCRepeatForever:create(to:copy():autorelease()))
|
||||||
|
layer:addChild(right)
|
||||||
|
|
||||||
|
subtitleLabel:setString("Progress With Sprite Frame")
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
-- Entrance
|
||||||
|
------------------------------------
|
||||||
|
function CreateActionProgressLayer(index)
|
||||||
|
local layer = nil
|
||||||
|
|
||||||
|
if index == 0 then
|
||||||
|
layer = SpriteProgressToRadial()
|
||||||
|
elseif index == 1 then
|
||||||
|
layer = SpriteProgressToHorizontal()
|
||||||
|
elseif index == 2 then
|
||||||
|
layer = SpriteProgressToVertical()
|
||||||
|
elseif index == 3 then
|
||||||
|
layer = SpriteProgressToRadialMidpointChanged()
|
||||||
|
elseif index == 4 then
|
||||||
|
layer = SpriteProgressBarVarious()
|
||||||
|
elseif index == 5 then
|
||||||
|
layer = SpriteProgressBarTintAndFade()
|
||||||
|
elseif index == 6 then
|
||||||
|
layer = SpriteProgressWithSpriteFrame()
|
||||||
|
end
|
||||||
|
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
function ProgressActionsTest()
|
||||||
|
cclog("ProgressActionsTest")
|
||||||
|
local scene = CCScene:create()
|
||||||
|
|
||||||
|
scene:addChild(CreateBackMenuItem())
|
||||||
|
scene:addChild(nextAction())
|
||||||
|
|
||||||
|
CCDirector:sharedDirector():replaceScene(scene)
|
||||||
|
end
|
|
@ -0,0 +1,47 @@
|
||||||
|
require "helper"
|
||||||
|
|
||||||
|
|
||||||
|
Action_Table =
|
||||||
|
{
|
||||||
|
"ACTION_MANUAL_LAYER",
|
||||||
|
"ACTION_MOVE_LAYER",
|
||||||
|
"ACTION_SCALE_LAYER",
|
||||||
|
"ACTION_ROTATE_LAYER",
|
||||||
|
"ACTION_SKEW_LAYER",
|
||||||
|
"ACTION_SKEWROTATE_LAYER",
|
||||||
|
"ACTION_JUMP_LAYER",
|
||||||
|
"ACTION_CARDINALSPLINE_LAYER",
|
||||||
|
"ACTION_CATMULLROM_LAYER",
|
||||||
|
"ACTION_BEZIER_LAYER",
|
||||||
|
"ACTION_BLINK_LAYER",
|
||||||
|
"ACTION_FADE_LAYER",
|
||||||
|
"ACTION_TINT_LAYER",
|
||||||
|
"ACTION_ANIMATE_LAYER",
|
||||||
|
"ACTION_SEQUENCE_LAYER",
|
||||||
|
"ACTION_SEQUENCE2_LAYER",
|
||||||
|
"ACTION_SPAWN_LAYER",
|
||||||
|
"ACTION_REVERSE",
|
||||||
|
"ACTION_DELAYTIME_LAYER",
|
||||||
|
"ACTION_REPEAT_LAYER",
|
||||||
|
"ACTION_REPEATEFOREVER_LAYER",
|
||||||
|
"ACTION_ROTATETOREPEATE_LAYER",
|
||||||
|
"ACTION_ROTATEJERK_LAYER",
|
||||||
|
"ACTION_CALLFUNC_LAYER",
|
||||||
|
-- problem: no corresponding function in CCLuaEngine yet
|
||||||
|
-- "ACTION_CALLFUNCND_LAYER",
|
||||||
|
"ACTION_REVERSESEQUENCE_LAYER",
|
||||||
|
"ACTION_REVERSESEQUENCE2_LAYER",
|
||||||
|
"ACTION_ORBIT_LAYER",
|
||||||
|
"ACTION_FOLLOW_LAYER",
|
||||||
|
"ACTION_TARGETED_LAYER",
|
||||||
|
-- problem: schedule feature hasn't implement on lua yet
|
||||||
|
-- "PAUSERESUMEACTIONS_LAYER",
|
||||||
|
-- "ACTION_ISSUE1305_LAYER",
|
||||||
|
"ACTION_ISSUE1305_2_LAYER",
|
||||||
|
"ACTION_ISSUE1288_LAYER",
|
||||||
|
"ACTION_ISSUE1288_2_LAYER",
|
||||||
|
"ACTION_ISSUE1327_LAYER",
|
||||||
|
"ACTION_LAYER_COUNT",
|
||||||
|
}
|
||||||
|
|
||||||
|
Action_Table = CreateEnumTable(Action_Table)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,68 @@
|
||||||
|
|
||||||
|
local size = CCDirector:sharedDirector():getWinSize()
|
||||||
|
local layer = nil
|
||||||
|
local kTagSprite = 1
|
||||||
|
|
||||||
|
local function initWithLayer()
|
||||||
|
local sprite = CCSprite:create(s_pPathGrossini)
|
||||||
|
|
||||||
|
local bgLayer = CCLayerColor:create(ccc4(255,255,0,255))
|
||||||
|
layer:addChild(bgLayer, -1)
|
||||||
|
|
||||||
|
layer:addChild(sprite, 0, kTagSprite)
|
||||||
|
sprite:setPosition(CCPointMake(20,150))
|
||||||
|
|
||||||
|
sprite:runAction(CCJumpTo:create(4, CCPointMake(300,48), 100, 4))
|
||||||
|
|
||||||
|
bgLayer:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(
|
||||||
|
CCFadeIn:create(1),
|
||||||
|
CCFadeOut:create(1))))
|
||||||
|
|
||||||
|
local function onTouchEnded(x, y)
|
||||||
|
local s = layer:getChildByTag(kTagSprite)
|
||||||
|
s:stopAllActions()
|
||||||
|
s:runAction(CCMoveTo:create(1, CCPointMake(x, y)))
|
||||||
|
local posX, posY = s:getPosition()
|
||||||
|
local o = x - posX
|
||||||
|
local a = y - posY
|
||||||
|
local at = math.atan(o / a) / math.pi * 180.0
|
||||||
|
|
||||||
|
if a < 0 then
|
||||||
|
if o < 0 then
|
||||||
|
at = 180 + math.abs(at)
|
||||||
|
else
|
||||||
|
at = 180 - math.abs(at)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
s:runAction(CCRotateTo:create(1, at))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function onTouch(eventType, x, y)
|
||||||
|
if eventType == CCTOUCHBEGAN then
|
||||||
|
return true
|
||||||
|
elseif eventType == CCTOUCHENDED then
|
||||||
|
return onTouchEnded(x, y)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
layer:setTouchEnabled(true)
|
||||||
|
layer:registerScriptTouchHandler(onTouch)
|
||||||
|
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- Click And Move Test
|
||||||
|
--------------------------------
|
||||||
|
function ClickAndMoveTest()
|
||||||
|
cclog("ClickAndMoveTest")
|
||||||
|
local scene = CCScene:create()
|
||||||
|
layer = CCLayer:create()
|
||||||
|
|
||||||
|
initWithLayer()
|
||||||
|
|
||||||
|
scene:addChild(CreateBackMenuItem())
|
||||||
|
scene:addChild(layer)
|
||||||
|
|
||||||
|
return scene
|
||||||
|
end
|
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
EffectsList =
|
||||||
|
{
|
||||||
|
[0] = "Shaky3D",
|
||||||
|
"Waves3D",
|
||||||
|
"FlipX3D",
|
||||||
|
"FlipY3D",
|
||||||
|
"Lens3D",
|
||||||
|
"Ripple3D",
|
||||||
|
"Liquid",
|
||||||
|
"Waves",
|
||||||
|
"Twirl",
|
||||||
|
"ShakyTiles3D",
|
||||||
|
"ShatteredTiles3D",
|
||||||
|
"ShuffleTiles",
|
||||||
|
"FadeOutTRTiles",
|
||||||
|
"FadeOutBLTiles",
|
||||||
|
"FadeOutUpTiles",
|
||||||
|
"FadeOutDownTiles",
|
||||||
|
"TurnOffTiles",
|
||||||
|
"WavesTiles3D",
|
||||||
|
"JumpTiles3D",
|
||||||
|
"SplitRows",
|
||||||
|
"SplitCols",
|
||||||
|
"PageTurn3D",
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
require "EffectsTest/EffectsName"
|
||||||
|
|
||||||
|
|
||||||
|
local ActionIdx = 0
|
||||||
|
local size = CCDirector:sharedDirector():getWinSize()
|
||||||
|
local kTagTextLayer = 1
|
||||||
|
local kTagBackground = 1
|
||||||
|
local kTagLabel = 2
|
||||||
|
|
||||||
|
function initWithLayer(layer)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------
|
||||||
|
-- Entrance
|
||||||
|
--------------------------------------
|
||||||
|
function EffectsTest()
|
||||||
|
cclog("EffectsTest")
|
||||||
|
local scene = CCScene:create()
|
||||||
|
local layer = CCLayerColor:create(ccc4(32,128,32,255))
|
||||||
|
|
||||||
|
initWithLayer(layer)
|
||||||
|
|
||||||
|
scene:addChild(CreateBackMenuItem())
|
||||||
|
scene:addChild(layer)
|
||||||
|
|
||||||
|
return scene
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
require "helper"
|
||||||
|
|
||||||
|
|
||||||
|
Particle_Table =
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Particle_Table = CreateEnumTable(Particle_Table)
|
|
@ -0,0 +1,115 @@
|
||||||
|
|
||||||
|
local size = CCDirector:sharedDirector():getWinSize()
|
||||||
|
|
||||||
|
local function CreateSpriteLayer()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
|
||||||
|
local x, y
|
||||||
|
x = size.width
|
||||||
|
y = size.height
|
||||||
|
|
||||||
|
local sprite = CCSprite:create(s_pPathGrossini)
|
||||||
|
local spriteSister1 = CCSprite:create(s_pPathSister1)
|
||||||
|
local spriteSister2 = CCSprite:create(s_pPathSister2)
|
||||||
|
|
||||||
|
sprite:setScale(1.5)
|
||||||
|
spriteSister1:setScale(1.5)
|
||||||
|
spriteSister2:setScale(1.5)
|
||||||
|
|
||||||
|
sprite:setPosition(CCPointMake(x / 2, y / 2))
|
||||||
|
spriteSister1:setPosition(CCPointMake(40, y / 2))
|
||||||
|
spriteSister2:setPosition(CCPointMake(x - 40, y / 2))
|
||||||
|
|
||||||
|
layer:addChild(sprite)
|
||||||
|
layer:addChild(spriteSister1)
|
||||||
|
layer:addChild(spriteSister2)
|
||||||
|
|
||||||
|
local rot = CCRotateBy:create(16, -3600)
|
||||||
|
sprite:runAction(rot)
|
||||||
|
|
||||||
|
local jump1 = CCJumpBy:create(4, CCPointMake(-400, 0), 100, 4)
|
||||||
|
local jump2 = jump1:reverse()
|
||||||
|
|
||||||
|
local rot1 = CCRotateBy:create(4, 360 * 2)
|
||||||
|
local rot2 = rot1:reverse()
|
||||||
|
|
||||||
|
spriteSister1:runAction(CCRepeat:create(CCSequence:createWithTwoActions(jump2, jump1), 5))
|
||||||
|
spriteSister2:runAction(CCRepeat:create(CCSequence:createWithTwoActions(jump1:copy():autorelease(), jump2:copy():autorelease()), 5))
|
||||||
|
|
||||||
|
spriteSister1:runAction(CCRepeat:create(CCSequence:createWithTwoActions(rot1, rot2), 5))
|
||||||
|
spriteSister2:runAction(CCRepeat:create(CCSequence:createWithTwoActions(rot2:copy():autorelease(), rot1:copy():autorelease()), 5))
|
||||||
|
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
local function CreateTestLayer()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
|
||||||
|
local x, y
|
||||||
|
x = size.width
|
||||||
|
y = size.height
|
||||||
|
|
||||||
|
local label = CCLabelTTF:create("cocos2d", "Tahoma", 64)
|
||||||
|
label:setPosition(x / 2, y / 2)
|
||||||
|
layer:addChild(label)
|
||||||
|
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
local function CreateRotateWorldLayer()
|
||||||
|
local layer = CCLayer:create()
|
||||||
|
|
||||||
|
local x, y
|
||||||
|
x = size.width
|
||||||
|
y = size.height
|
||||||
|
|
||||||
|
local blue = CCLayerColor:create(ccc4(0,0,255,255))
|
||||||
|
local red = CCLayerColor:create(ccc4(255,0,0,255))
|
||||||
|
local green = CCLayerColor:create(ccc4(0,255,0,255))
|
||||||
|
local white = CCLayerColor:create(ccc4(255,255,255,255))
|
||||||
|
|
||||||
|
blue:setScale(0.5)
|
||||||
|
blue:setPosition(CCPointMake(- x / 4, - y / 4))
|
||||||
|
blue:addChild(CreateSpriteLayer())
|
||||||
|
|
||||||
|
red:setScale(0.5)
|
||||||
|
red:setPosition(CCPointMake(x / 4, - y / 4))
|
||||||
|
|
||||||
|
green:setScale(0.5)
|
||||||
|
green:setPosition(CCPointMake(- x / 4, y / 4))
|
||||||
|
green:addChild(CreateTestLayer())
|
||||||
|
|
||||||
|
white:setScale(0.5)
|
||||||
|
white:setPosition(CCPointMake(x / 4, y / 4))
|
||||||
|
white:ignoreAnchorPointForPosition(false)
|
||||||
|
white:setPosition(CCPointMake(x / 4 * 3, y / 4 * 3))
|
||||||
|
|
||||||
|
layer:addChild(blue, -1)
|
||||||
|
layer:addChild(white)
|
||||||
|
layer:addChild(green)
|
||||||
|
layer:addChild(red)
|
||||||
|
|
||||||
|
local rot = CCRotateBy:create(8, 720)
|
||||||
|
|
||||||
|
blue:runAction(rot)
|
||||||
|
red:runAction(rot:copy():autorelease())
|
||||||
|
green:runAction(rot:copy():autorelease())
|
||||||
|
white:runAction(rot:copy():autorelease())
|
||||||
|
|
||||||
|
return layer
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- Rotate World Test
|
||||||
|
--------------------------------
|
||||||
|
function RotateWorldTest()
|
||||||
|
cclog("RotateWorldTest")
|
||||||
|
local scene = CCScene:create()
|
||||||
|
local layer = CreateRotateWorldLayer()
|
||||||
|
|
||||||
|
scene:addChild(layer)
|
||||||
|
scene:addChild(CreateBackMenuItem())
|
||||||
|
scene:runAction(CCRotateBy:create(4, -360))
|
||||||
|
|
||||||
|
return scene
|
||||||
|
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue