Conflicts:
	cocos2dx/platform/CCFileUtils.cpp
This commit is contained in:
natural-law 2011-06-14 15:05:52 +08:00
commit 214e86a5b6
104 changed files with 2300 additions and 407 deletions

5
.gitignore vendored
View File

@ -43,5 +43,10 @@ build_*_xcode/
# Ignore files build by xcode # Ignore files build by xcode
*.mode*v* *.mode*v*
*.pbxuser *.pbxuser
*.xcbkptlist
*.xcscheme
*.xcworkspacedata
*.xcuserstate
xcschememanagement.plist
build/ build/
.DS_Store .DS_Store

View File

@ -11,8 +11,8 @@ cocos2d-0.99.5-x-0.8.4 @ May.26,2011
Feature #509 For integrting IME, we had to rotate UI to landscape by default Feature #509 For integrting IME, we had to rotate UI to landscape by default
Bug #499 CCRGBAProtocol isn't inherited and implemented in CCMenuItemSprite Bug #499 CCRGBAProtocol isn't inherited and implemented in CCMenuItemSprite
[ios] [ios]
Bug #493 the return value of CCileUtils::getWriteablePath() is not end with '/' Bug #493 the return value of CCFileUtils::getWriteablePath() is not end with '/'
Bug #508 Problem in runnint Tests in Retina resolution since 0.8.2 Bug #508 Problem in running Tests in Retina resolution since 0.8.2
[win32] [win32]
Bug #492 CCFileUtils::fullPathFromRelativeFile forget to consider the path separated by '\' Bug #492 CCFileUtils::fullPathFromRelativeFile forget to consider the path separated by '\'
Feature #489 Use GetCurrentDirectory instead of GetModuleFileName in CCFileUtils_win32.cpp Feature #489 Use GetCurrentDirectory instead of GetModuleFileName in CCFileUtils_win32.cpp

View File

@ -139,6 +139,6 @@ LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/platform/third_party/android/l
-lskia -lskia
# define the macro to compile through support/zip_support/ioapi.c # define the macro to compile through support/zip_support/ioapi.c
LOCAL_CFLAGS := -DUSE_FILE32API LOCAL_CFLAGS := -DUSE_FILE32API -Wno-unused-value
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)

View File

@ -36,14 +36,14 @@ static CCConfiguration g_SharedConfiguration;
static char *g_pGlExtensions; static char *g_pGlExtensions;
CCConfiguration::CCConfiguration(void) CCConfiguration::CCConfiguration(void)
: m_bSupportsBGRA8888(false) :m_nMaxTextureSize(0)
, m_bSupportsDiscardFramebuffer(false)
, m_bSupportsNPOT(false)
, m_bSupportsPVRTC(false)
, m_nMaxModelviewStackDepth(0) , m_nMaxModelviewStackDepth(0)
, m_nMaxSamplesAllowed(0) , m_bSupportsPVRTC(false)
, m_nMaxTextureSize(0) , m_bSupportsNPOT(false)
, m_bSupportsBGRA8888(false)
, m_bSupportsDiscardFramebuffer(false)
, m_uOSVersion(0) , m_uOSVersion(0)
, m_nMaxSamplesAllowed(0)
{ {
} }
@ -90,15 +90,15 @@ CCGlesVersion CCConfiguration::getGlesVersion()
{ {
// To get the Opengl ES version // To get the Opengl ES version
std::string strVersion((char *)glGetString(GL_VERSION)); std::string strVersion((char *)glGetString(GL_VERSION));
if (strVersion.find("1.0") != -1) if ((int)strVersion.find("1.0") != -1)
{ {
return GLES_VER_1_0; return GLES_VER_1_0;
} }
else if (strVersion.find("1.1") != -1) else if ((int)strVersion.find("1.1") != -1)
{ {
return GLES_VER_1_1; return GLES_VER_1_1;
} }
else if (strVersion.find("2.0") != -1) else if ((int)strVersion.find("2.0") != -1)
{ {
return GLES_VER_2_0; return GLES_VER_2_0;
} }

View File

@ -479,6 +479,7 @@ CCSize CCDirector::getDisplaySizeInPixels(void)
void CCDirector::reshapeProjection(CCSize newWindowSize) void CCDirector::reshapeProjection(CCSize newWindowSize)
{ {
CC_UNUSED_PARAM(newWindowSize);
m_obWinSizeInPoints = m_pobOpenGLView->getSize(); m_obWinSizeInPoints = m_pobOpenGLView->getSize();
m_obWinSizeInPixels = CCSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor, m_obWinSizeInPixels = CCSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor,
m_obWinSizeInPoints.height * m_fContentScaleFactor); m_obWinSizeInPoints.height * m_fContentScaleFactor);
@ -748,6 +749,7 @@ tPixelFormat CCDirector::getPiexFormat(void)
bool CCDirector::setDirectorType(ccDirectorType obDirectorType) bool CCDirector::setDirectorType(ccDirectorType obDirectorType)
{ {
CC_UNUSED_PARAM(obDirectorType);
// we only support CCDisplayLinkDirector // we only support CCDisplayLinkDirector
CCDirector::sharedDirector(); CCDirector::sharedDirector();

View File

@ -128,14 +128,14 @@ void CCTimer::update(ccTime dt)
static CCScheduler *pSharedScheduler; static CCScheduler *pSharedScheduler;
CCScheduler::CCScheduler(void) CCScheduler::CCScheduler(void)
: m_bCurrentTargetSalvaged(false) : m_fTimeScale(0.0)
, m_fTimeScale(0.0)
, m_pCurrentTarget(NULL)
, m_pHashForSelectors(NULL)
, m_pHashForUpdates(NULL)
, m_pUpdates0List(NULL)
, m_pUpdatesNegList(NULL) , m_pUpdatesNegList(NULL)
, m_pUpdates0List(NULL)
, m_pUpdatesPosList(NULL) , m_pUpdatesPosList(NULL)
, m_pHashForUpdates(NULL)
, m_pHashForSelectors(NULL)
, m_pCurrentTarget(NULL)
, m_bCurrentTargetSalvaged(false)
{ {
assert(pSharedScheduler == NULL); assert(pSharedScheduler == NULL);
} }
@ -191,12 +191,15 @@ void CCScheduler::removeHashElement(_hashSelectorEntry *pElement)
void CCScheduler::scheduleTimer(CCTimer *pTimer) void CCScheduler::scheduleTimer(CCTimer *pTimer)
{ {
CC_UNUSED_PARAM(pTimer);
assert(false); assert(false);
} }
void CCScheduler::unscheduleTimer(CCTimer *pTimer) void CCScheduler::unscheduleTimer(CCTimer *pTimer)
{ {
assert(false); //CC_UNUSED_PARAM(pTimer);
pTimer = NULL;
assert(false);
} }
void CCScheduler::unscheduleAllTimers() void CCScheduler::unscheduleAllTimers()

View File

@ -94,11 +94,13 @@ bool CCAction::isDone()
void CCAction::step(ccTime dt) void CCAction::step(ccTime dt)
{ {
CC_UNUSED_PARAM(dt);
CCLOG("[Action step]. override me"); CCLOG("[Action step]. override me");
} }
void CCAction::update(ccTime time) void CCAction::update(ccTime time)
{ {
CC_UNUSED_PARAM(time);
CCLOG("[Action update]. override me"); CCLOG("[Action update]. override me");
} }
@ -291,6 +293,7 @@ CCObject *CCFollow::copyWithZone(CCZone *pZone)
} }
void CCFollow::step(ccTime dt) void CCFollow::step(ccTime dt)
{ {
CC_UNUSED_PARAM(dt);
#define CLAMP(x,y,z) MIN(MAX(x,y),z) #define CLAMP(x,y,z) MIN(MAX(x,y),z)
if(m_bBoundarySet) if(m_bBoundarySet)

View File

@ -411,6 +411,7 @@ namespace cocos2d
void CCLens3D::update(cocos2d::ccTime time) void CCLens3D::update(cocos2d::ccTime time)
{ {
CC_UNUSED_PARAM(time);
if (m_bDirty) if (m_bDirty)
{ {
int i, j; int i, j;
@ -601,6 +602,7 @@ namespace cocos2d
void CCShaky3D::update(cocos2d::ccTime time) void CCShaky3D::update(cocos2d::ccTime time)
{ {
CC_UNUSED_PARAM(time);
int i, j; int i, j;
for (i = 0; i < (m_sGridSize.x+1); ++i) for (i = 0; i < (m_sGridSize.x+1); ++i)

View File

@ -57,10 +57,12 @@ namespace cocos2d {
} }
void CCActionInstant::step(ccTime dt) void CCActionInstant::step(ccTime dt)
{ {
CC_UNUSED_PARAM(dt);
update(1); update(1);
} }
void CCActionInstant::update(ccTime time) void CCActionInstant::update(ccTime time)
{ {
CC_UNUSED_PARAM(time);
// ignore // ignore
} }
CCFiniteTimeAction * CCActionInstant::reverse() CCFiniteTimeAction * CCActionInstant::reverse()

View File

@ -114,6 +114,7 @@ void CCActionInterval::step(ccTime dt)
void CCActionInterval::setAmplitudeRate(CGFloat amp) void CCActionInterval::setAmplitudeRate(CGFloat amp)
{ {
CC_UNUSED_PARAM(amp);
// Abstract class needs implementation // Abstract class needs implementation
assert(0); assert(0);
} }
@ -1710,6 +1711,7 @@ CCObject* CCDelayTime::copyWithZone(cocos2d::CCZone *pZone)
void CCDelayTime::update(cocos2d::ccTime time) void CCDelayTime::update(cocos2d::ccTime time)
{ {
CC_UNUSED_PARAM(time);
return; return;
} }

View File

@ -84,8 +84,8 @@ void CCActionManager::selectorProtocolRelease()
} }
CCActionManager::CCActionManager(void) CCActionManager::CCActionManager(void)
: m_pCurrentTarget(NULL), : m_pTargets(NULL),
m_pTargets(NULL), m_pCurrentTarget(NULL),
m_bCurrentTargetSalvaged(false) m_bCurrentTargetSalvaged(false)
{ {
assert(gSharedManager == NULL); assert(gSharedManager == NULL);
@ -286,7 +286,7 @@ void CCActionManager::removeAction(cocos2d::CCAction *pAction)
if (pElement) if (pElement)
{ {
unsigned int i = ccArrayGetIndexOfObject(pElement->actions, pAction); unsigned int i = ccArrayGetIndexOfObject(pElement->actions, pAction);
if (i != -1) if (UINT_MAX == i)
{ {
removeActionAtIndex(i, pElement); removeActionAtIndex(i, pElement);
} }

View File

@ -98,6 +98,7 @@ namespace cocos2d
void CCShakyTiles3D::update(cocos2d::ccTime time) void CCShakyTiles3D::update(cocos2d::ccTime time)
{ {
CC_UNUSED_PARAM(time);
int i, j; int i, j;
for (i = 0; i < m_sGridSize.x; ++i) for (i = 0; i < m_sGridSize.x; ++i)
@ -191,6 +192,7 @@ namespace cocos2d
void CCShatteredTiles3D::update(cocos2d::ccTime time) void CCShatteredTiles3D::update(cocos2d::ccTime time)
{ {
CC_UNUSED_PARAM(time);
int i, j; int i, j;
if (m_bOnce == false) if (m_bOnce == false)

View File

@ -33,13 +33,13 @@ namespace cocos2d {
// CCAtlasNode - Creation & Init // CCAtlasNode - Creation & Init
CCAtlasNode::CCAtlasNode() CCAtlasNode::CCAtlasNode()
: m_pTextureAtlas(NULL) : m_nItemsPerRow(0)
, m_bIsOpacityModifyRGB(false) , m_nItemsPerColumn(0)
, m_nItemWidth(0) , m_nItemWidth(0)
, m_nItemHeight(0) , m_nItemHeight(0)
, m_pTextureAtlas(NULL)
, m_bIsOpacityModifyRGB(false)
, m_cOpacity(0) , m_cOpacity(0)
, m_nItemsPerRow(0)
, m_nItemsPerColumn(0)
{ {
} }

View File

@ -43,35 +43,35 @@ THE SOFTWARE.
namespace cocos2d { namespace cocos2d {
CCNode::CCNode(void) CCNode::CCNode(void)
:m_bIsRunning(false) : m_nZOrder(0)
,m_fRotation(0.0f) , m_fVertexZ(0.0f)
,m_fScaleX(1.0f) , m_fRotation(0.0f)
,m_fScaleY(1.0f) , m_fScaleX(1.0f)
,m_tPosition(CCPointZero) , m_fScaleY(1.0f)
,m_tPositionInPixels(CCPointZero) , m_tPosition(CCPointZero)
,m_tAnchorPointInPixels(CCPointZero) , m_tPositionInPixels(CCPointZero)
,m_tAnchorPoint(CCPointZero)
,m_tContentSize(CCSizeZero)
,m_tContentSizeInPixels(CCSizeZero)
// "whole screen" objects. like Scenes and Layers, should set isRelativeAnchorPoint to false
,m_bIsRelativeAnchorPoint(true)
,m_bIsTransformDirty(true)
,m_bIsInverseDirty(true)
#ifdef CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
,m_bIsTransformGLDirty(true)
#endif
,m_fVertexZ(0.0f)
,m_pGrid(NULL)
,m_bIsVisible(true)
,m_nTag(kCCNodeTagInvalid)
,m_nZOrder(0)
// lazy alloc
,m_pCamera(NULL)
// children (lazy allocs) // children (lazy allocs)
,m_pChildren(NULL) , m_pChildren(NULL)
// lazy alloc
, m_pCamera(NULL)
, m_pGrid(NULL)
, m_bIsVisible(true)
, m_tAnchorPoint(CCPointZero)
, m_tAnchorPointInPixels(CCPointZero)
, m_tContentSize(CCSizeZero)
, m_tContentSizeInPixels(CCSizeZero)
, m_bIsRunning(false)
, m_pParent(NULL)
// "whole screen" objects. like Scenes and Layers, should set isRelativeAnchorPoint to false
, m_bIsRelativeAnchorPoint(true)
, m_nTag(kCCNodeTagInvalid)
// userData is always inited as nil // userData is always inited as nil
,m_pUserData(NULL) , m_pUserData(NULL)
,m_pParent(NULL) , m_bIsTransformDirty(true)
, m_bIsInverseDirty(true)
#ifdef CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
, m_bIsTransformGLDirty(true)
#endif
{ {
// nothing // nothing
} }

View File

@ -67,6 +67,8 @@ void* CCData::bytes(void)
//@todo implement //@todo implement
CCData* CCData::dataWithBytes(unsigned char *pBytes, int size) CCData* CCData::dataWithBytes(unsigned char *pBytes, int size)
{ {
CC_UNUSED_PARAM(pBytes);
CC_UNUSED_PARAM(size);
return NULL; return NULL;
} }
}//namespace cocos2d }//namespace cocos2d

View File

@ -64,7 +64,7 @@ bool splitWithForm(const char* pStr, strArray& strs)
int nPosRight = content.find('}'); int nPosRight = content.find('}');
// don't have '{' and '}' // don't have '{' and '}'
CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos); CC_BREAK_IF(nPosLeft == (int)std::string::npos || nPosRight == (int)std::string::npos);
// '}' is before '{' // '}' is before '{'
CC_BREAK_IF(nPosLeft > nPosRight); CC_BREAK_IF(nPosLeft > nPosRight);
@ -75,7 +75,7 @@ bool splitWithForm(const char* pStr, strArray& strs)
int nPos1 = pointStr.find('{'); int nPos1 = pointStr.find('{');
int nPos2 = pointStr.find('}'); int nPos2 = pointStr.find('}');
// contain '{' or '}' // contain '{' or '}'
CC_BREAK_IF(nPos1 != std::string::npos || nPos2 != std::string::npos); CC_BREAK_IF(nPos1 != (int)std::string::npos || nPos2 != (int)std::string::npos);
split(pointStr, ",", strs); split(pointStr, ",", strs);
if (strs.size() != 2 || strs[0].length() == 0 || strs[1].length() == 0) if (strs.size() != 2 || strs[0].length() == 0 || strs[1].length() == 0)
@ -107,19 +107,19 @@ namespace cocos2d
int nPosRight = content.find('}'); int nPosRight = content.find('}');
for (int i = 1; i < 3; ++i) for (int i = 1; i < 3; ++i)
{ {
if (nPosRight == std::string::npos) if (nPosRight == (int)std::string::npos)
{ {
break; break;
} }
nPosRight = content.find('}', nPosRight + 1); nPosRight = content.find('}', nPosRight + 1);
} }
CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos); CC_BREAK_IF(nPosLeft == (int)std::string::npos || nPosRight == (int)std::string::npos);
content = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1); content = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1);
int nPointEnd = content.find('}'); int nPointEnd = content.find('}');
CC_BREAK_IF(nPointEnd == std::string::npos); CC_BREAK_IF(nPointEnd == (int)std::string::npos);
nPointEnd = content.find(',', nPointEnd); nPointEnd = content.find(',', nPointEnd);
CC_BREAK_IF(nPointEnd == std::string::npos); CC_BREAK_IF(nPointEnd == (int)std::string::npos);
// get the point string and size string // get the point string and size string
std::string pointStr = content.substr(0, nPointEnd); std::string pointStr = content.substr(0, nPointEnd);

View File

@ -30,6 +30,7 @@ namespace cocos2d {
CCObject* CCCopying::copyWithZone(CCZone *pZone) CCObject* CCCopying::copyWithZone(CCZone *pZone)
{ {
CC_UNUSED_PARAM(pZone);
assert(0); assert(0);
return NULL; return NULL;
} }

View File

@ -76,6 +76,7 @@ namespace cocos2d
void CCGrabber::beforeRender(cocos2d::CCTexture2D *pTexture) void CCGrabber::beforeRender(cocos2d::CCTexture2D *pTexture)
{ {
CC_UNUSED_PARAM(pTexture);
// If the gles version is lower than GLES_VER_1_0, // If the gles version is lower than GLES_VER_1_0,
// all the functions in CCGrabber return directly. // all the functions in CCGrabber return directly.
if (m_eGlesVersion <= GLES_VER_1_0) if (m_eGlesVersion <= GLES_VER_1_0)
@ -101,6 +102,7 @@ namespace cocos2d
void CCGrabber::afterRender(cocos2d::CCTexture2D *pTexture) void CCGrabber::afterRender(cocos2d::CCTexture2D *pTexture)
{ {
CC_UNUSED_PARAM(pTexture);
// If the gles version is lower than GLES_VER_1_0, // If the gles version is lower than GLES_VER_1_0,
// all the functions in CCGrabber return directly. // all the functions in CCGrabber return directly.
if (m_eGlesVersion <= GLES_VER_1_0) if (m_eGlesVersion <= GLES_VER_1_0)

View File

@ -377,10 +377,10 @@ namespace cocos2d
float y1 = y * m_obStep.y; float y1 = y * m_obStep.y;
float y2= y1 + m_obStep.y; float y2= y1 + m_obStep.y;
GLushort a = x * (m_sGridSize.y + 1) + y; GLushort a = (GLushort)(x * (m_sGridSize.y + 1) + y);
GLushort b = (x + 1) * (m_sGridSize.y + 1) + y; GLushort b = (GLushort)((x + 1) * (m_sGridSize.y + 1) + y);
GLushort c = (x + 1) * (m_sGridSize.y + 1) + (y + 1); GLushort c = (GLushort)((x + 1) * (m_sGridSize.y + 1) + (y + 1));
GLushort d = x * (m_sGridSize.y + 1) + (y + 1); GLushort d = (GLushort)(x * (m_sGridSize.y + 1) + (y + 1));
GLushort tempidx[6] = {a, b, d, b, c, d}; GLushort tempidx[6] = {a, b, d, b, c, d};
@ -587,13 +587,13 @@ namespace cocos2d
for (x = 0; x < numQuads; x++) for (x = 0; x < numQuads; x++)
{ {
idxArray[x*6+0] = x * 4 + 0; idxArray[x*6+0] = (GLushort)(x * 4 + 0);
idxArray[x*6+1] = x * 4 + 1; idxArray[x*6+1] = (GLushort)(x * 4 + 1);
idxArray[x*6+2] = x * 4 + 2; idxArray[x*6+2] = (GLushort)(x * 4 + 2);
idxArray[x*6+3] = x * 4 + 1; idxArray[x*6+3] = (GLushort)(x * 4 + 1);
idxArray[x*6+4] = x * 4 + 2; idxArray[x*6+4] = (GLushort)(x * 4 + 2);
idxArray[x*6+5] = x * 4 + 3; idxArray[x*6+5] = (GLushort)(x * 4 + 3);
} }
memcpy(m_pOriginalVertices, m_pVertices, numQuads * 12 * sizeof(GLfloat)); memcpy(m_pOriginalVertices, m_pVertices, numQuads * 12 * sizeof(GLfloat));

View File

@ -48,7 +48,7 @@ receiving acceleration-related data from the system.
class CC_DLL CCAccelerometerDelegate class CC_DLL CCAccelerometerDelegate
{ {
public: public:
virtual void didAccelerate(CCAcceleration* pAccelerationValue) {} virtual void didAccelerate(CCAcceleration* pAccelerationValue) {CC_UNUSED_PARAM(pAccelerationValue);}
//! call the release() in child layer //! call the release() in child layer
virtual void AccelerometerDestroy(void) {} virtual void AccelerometerDestroy(void) {}

View File

@ -194,12 +194,12 @@ class CC_DLL CCFollow : public CCAction
public: public:
CCFollow() CCFollow()
: m_pobFollowedNode(NULL) : m_pobFollowedNode(NULL)
, m_bBoundarySet(false)
, m_bBoundaryFullyCovered(false) , m_bBoundaryFullyCovered(false)
, m_bBoundarySet(false)
, m_fBottomBoundary(0.0)
, m_fLeftBoundary(0.0) , m_fLeftBoundary(0.0)
, m_fRightBoundary(0.0) , m_fRightBoundary(0.0)
, m_fTopBoundary(0.0) , m_fTopBoundary(0.0)
, m_fBottomBoundary(0.0)
{} {}
virtual ~CCFollow(void); virtual ~CCFollow(void);

View File

@ -73,16 +73,16 @@ namespace cocos2d {
{ {
public: public:
CCOrbitCamera() CCOrbitCamera()
: m_fAngleX(0.0) : m_fRadius(0.0)
, m_fAngleZ(0.0) , m_fDeltaRadius(0.0)
, m_fAngleZ(0.0)
, m_fDeltaAngleZ(0.0)
, m_fAngleX(0.0)
, m_fDeltaAngleX(0.0) , m_fDeltaAngleX(0.0)
, m_fDeltaAngleZ(0.0) , m_fRadZ(0.0)
, m_fDeltaRadius(0.0) , m_fRadDeltaZ(0.0)
, m_fRadX(0.0)
, m_fRadDeltaX(0.0) , m_fRadDeltaX(0.0)
, m_fRadDeltaZ(0.0)
, m_fRadius(0.0)
, m_fRadX(0.0)
, m_fRadZ(0.0)
{} {}
~CCOrbitCamera(){} ~CCOrbitCamera(){}
/** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */

View File

@ -171,9 +171,9 @@ namespace cocos2d {
{ {
public: public:
CCCallFunc() CCCallFunc()
: m_pCallFunc(NULL) : m_pSelectorTarget(NULL)
, m_pSelectorTarget(NULL) , m_pCallFunc(NULL)
{ {
} }
virtual ~CCCallFunc() virtual ~CCCallFunc()
{ {

View File

@ -74,7 +74,7 @@ protected:
/** /**
@brief Called by CCIMEDispatcher when some text input from IME. @brief Called by CCIMEDispatcher when some text input from IME.
*/ */
virtual void insertText(const char * text, int len) {} virtual void insertText(const char * text, int len) {CC_UNUSED_PARAM(text);CC_UNUSED_PARAM(len);}
/** /**
@brief Called by CCIMEDispatcher when user clicked the backward key. @brief Called by CCIMEDispatcher when user clicked the backward key.
@ -89,10 +89,10 @@ protected:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// keyboard show/hide notification // keyboard show/hide notification
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
virtual void keyboardWillShow(CCIMEKeyboardNotificationInfo& info) {} virtual void keyboardWillShow(CCIMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);}
virtual void keyboardDidShow(CCIMEKeyboardNotificationInfo& info) {} virtual void keyboardDidShow(CCIMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);}
virtual void keyboardWillHide(CCIMEKeyboardNotificationInfo& info) {} virtual void keyboardWillHide(CCIMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);}
virtual void keyboardDidHide(CCIMEKeyboardNotificationInfo& info) {} virtual void keyboardDidHide(CCIMEKeyboardNotificationInfo& info) {CC_UNUSED_PARAM(info);}
protected: protected:
CCIMEDelegate(); CCIMEDelegate();

View File

@ -85,8 +85,8 @@ namespace cocos2d{
struct _KerningHashElement *m_pKerningDictionary; struct _KerningHashElement *m_pKerningDictionary;
public: public:
CCBMFontConfiguration() CCBMFontConfiguration()
: m_pKerningDictionary(NULL) : m_uCommonHeight(0)
, m_uCommonHeight(0) , m_pKerningDictionary(NULL)
{} {}
virtual ~CCBMFontConfiguration(); virtual ~CCBMFontConfiguration();
char * description(); char * description();
@ -148,10 +148,10 @@ namespace cocos2d{
CCBMFontConfiguration *m_pConfiguration; CCBMFontConfiguration *m_pConfiguration;
public: public:
CCLabelBMFont() CCLabelBMFont()
: m_pConfiguration(NULL) : m_cOpacity(0)
, m_bIsOpacityModifyRGB(false) , m_bIsOpacityModifyRGB(false)
, m_cOpacity(0)
, m_sString("") , m_sString("")
, m_pConfiguration(NULL)
{} {}
virtual ~CCLabelBMFont(); virtual ~CCLabelBMFont();
/** Purges the cached data. /** Purges the cached data.

View File

@ -58,7 +58,7 @@ public:
virtual void destroy(void); virtual void destroy(void);
virtual void keep(void); virtual void keep(void);
virtual void didAccelerate(CCAcceleration* pAccelerationValue) {} virtual void didAccelerate(CCAcceleration* pAccelerationValue) {CC_UNUSED_PARAM(pAccelerationValue);}
virtual void AccelerometerDestroy(void); virtual void AccelerometerDestroy(void);
virtual void AccelerometerKeep(void); virtual void AccelerometerKeep(void);

View File

@ -117,8 +117,8 @@ namespace cocos2d{
protected: protected:
tCCMenuState m_eState; tCCMenuState m_eState;
GLubyte m_cOpacity;
CCMenuItem *m_pSelectedItem; CCMenuItem *m_pSelectedItem;
GLubyte m_cOpacity;
ccColor3B m_tColor; ccColor3B m_tColor;
}; };
} }

View File

@ -51,9 +51,9 @@ namespace cocos2d{
CC_PROPERTY(bool, m_bIsEnabled, IsEnabled); CC_PROPERTY(bool, m_bIsEnabled, IsEnabled);
public: public:
CCMenuItem() CCMenuItem()
: m_pListener(NULL) : m_bIsSelected(false)
, m_bIsEnabled(false) , m_bIsEnabled(false)
, m_bIsSelected(false) , m_pListener(NULL)
, m_pfnSelector(NULL) , m_pfnSelector(NULL)
{} {}
virtual ~CCMenuItem(){} virtual ~CCMenuItem(){}
@ -248,8 +248,8 @@ namespace cocos2d{
public: public:
CCMenuItemToggle() CCMenuItemToggle()
: m_cOpacity(0) : m_cOpacity(0)
, m_uSelectedIndex(0)
, m_pSubItems(NULL) , m_pSubItems(NULL)
, m_uSelectedIndex(0)
{} {}
virtual ~CCMenuItemToggle(); virtual ~CCMenuItemToggle();
/** creates a menu item from a list of items with a target/selector */ /** creates a menu item from a list of items with a target/selector */

View File

@ -57,10 +57,10 @@ class CC_DLL CCMotionStreak : public CCNode, public CCTextureProtocol
CC_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc) CC_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc)
public: public:
CCMotionStreak() CCMotionStreak()
: m_fSegThreshold(0.0) : m_pRibbon(NULL)
, m_pTexture(NULL)
, m_fSegThreshold(0.0)
, m_fWidth(0.0) , m_fWidth(0.0)
, m_pRibbon(NULL)
, m_pTexture(NULL)
{} {}
virtual ~CCMotionStreak(){} virtual ~CCMotionStreak(){}
/** creates the a MotionStreak. The image will be loaded using the TextureMgr. */ /** creates the a MotionStreak. The image will be loaded using the TextureMgr. */

View File

@ -63,7 +63,7 @@ public:
Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO
@since v0.8 @since v0.8
*/ */
virtual void setIsOpacityModifyRGB(bool bValue) {} virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
/** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity); /** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity);
@since v0.8 @since v0.8
@ -101,7 +101,7 @@ public:
virtual CCTexture2D* getTexture(void) = 0; virtual CCTexture2D* getTexture(void) = 0;
// sets a new texture. it will be retained // sets a new texture. it will be retained
virtual void setTexture(CCTexture2D *texture) {} virtual void setTexture(CCTexture2D *texture) {CC_UNUSED_PARAM(texture);}
}; };
//! @brief Common interface for Labels //! @brief Common interface for Labels

View File

@ -108,8 +108,8 @@ public:
public: public:
CCRibbonSegment() CCRibbonSegment()
: m_bFinished(false) : m_bFinished(false)
, m_uEnd(0)
, m_uBegin(0) , m_uBegin(0)
, m_uEnd(0)
{} {}
virtual ~CCRibbonSegment(); virtual ~CCRibbonSegment();
char * description(); char * description();

View File

@ -41,6 +41,7 @@ public:
*/ */
virtual bool onTextFieldAttachWithIME(CCTextFieldTTF * sender) virtual bool onTextFieldAttachWithIME(CCTextFieldTTF * sender)
{ {
CC_UNUSED_PARAM(sender);
return false; return false;
} }
@ -49,6 +50,7 @@ public:
*/ */
virtual bool onTextFieldDetachWithIME(CCTextFieldTTF * sender) virtual bool onTextFieldDetachWithIME(CCTextFieldTTF * sender)
{ {
CC_UNUSED_PARAM(sender);
return false; return false;
} }
@ -57,6 +59,9 @@ public:
*/ */
virtual bool onTextFieldInsertText(CCTextFieldTTF * sender, const char * text, int nLen) virtual bool onTextFieldInsertText(CCTextFieldTTF * sender, const char * text, int nLen)
{ {
CC_UNUSED_PARAM(sender);
CC_UNUSED_PARAM(text);
CC_UNUSED_PARAM(nLen);
return false; return false;
} }
@ -65,6 +70,9 @@ public:
*/ */
virtual bool onTextFieldDeleteBackward(CCTextFieldTTF * sender, const char * delText, int nLen) virtual bool onTextFieldDeleteBackward(CCTextFieldTTF * sender, const char * delText, int nLen)
{ {
CC_UNUSED_PARAM(sender);
CC_UNUSED_PARAM(delText);
CC_UNUSED_PARAM(nLen);
return false; return false;
} }
@ -73,6 +81,7 @@ public:
*/ */
virtual bool onDraw(CCTextFieldTTF * sender) virtual bool onDraw(CCTextFieldTTF * sender)
{ {
CC_UNUSED_PARAM(sender);
return false; return false;
} }
}; };

View File

@ -36,8 +36,8 @@ public:
CCTouch() {} CCTouch() {}
CCTouch(int nViewId, float x, float y) : m_nViewId(nViewId), m_point(x, y), m_prevPoint(x, y) {} CCTouch(int nViewId, float x, float y) : m_nViewId(nViewId), m_point(x, y), m_prevPoint(x, y) {}
CCPoint locationInView(int nViewId) { return m_point; } CCPoint locationInView(int nViewId) {CC_UNUSED_PARAM(nViewId); return m_point; }
CCPoint previousLocationInView(int nViewId) { return m_prevPoint; } CCPoint previousLocationInView(int nViewId) {CC_UNUSED_PARAM(nViewId); return m_prevPoint; }
int view() { return m_nViewId; } int view() { return m_nViewId; }
void SetTouchInfo(int nViewId, float x, float y) void SetTouchInfo(int nViewId, float x, float y)

View File

@ -56,18 +56,18 @@ public:
//! call the retain() in child (layer or menu) //! call the retain() in child (layer or menu)
virtual void keep(void) {} virtual void keep(void) {}
virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { return false;}; virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); return false;};
// optional // optional
virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) {} virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) {} virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) {} virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
// optional // optional
virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) {} virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) {} virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) {} virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent) {} virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
}; };
/** /**
@brief @brief
@ -90,12 +90,12 @@ public:
/** Return YES to claim the touch. /** Return YES to claim the touch.
@since v0 @since v0
*/ */
virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { return false;}; virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);return false;};
// optional // optional
virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) {} virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) {} virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) {} virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent);}
}; };
/** @brief /** @brief
@ -107,10 +107,10 @@ public:
public: public:
CCStandardTouchDelegate() { m_eTouchDelegateType = ccTouchDelegateStandardBit; } CCStandardTouchDelegate() { m_eTouchDelegateType = ccTouchDelegateStandardBit; }
// optional // optional
virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) {} virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) {} virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) {} virtual void ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent) {} virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);}
}; };
}//namespace cocos2d }//namespace cocos2d

View File

@ -96,10 +96,11 @@ public:
~CCTouchDispatcher(); ~CCTouchDispatcher();
bool init(void); bool init(void);
CCTouchDispatcher() CCTouchDispatcher()
: m_pHandlersToAdd(NULL) : m_pTargetedHandlers(NULL)
, m_pStandardHandlers(NULL)
, m_pHandlersToAdd(NULL)
, m_pHandlersToRemove(NULL) , m_pHandlersToRemove(NULL)
, m_pStandardHandlers(NULL)
, m_pTargetedHandlers(NULL)
{} {}
public: public:

View File

@ -35,13 +35,13 @@ class CCEvent;
class CC_DLL SelectorProtocol class CC_DLL SelectorProtocol
{ {
public: public:
virtual void update(ccTime dt) {}; virtual void update(ccTime dt) {CC_UNUSED_PARAM(dt);};
virtual void tick(ccTime dt){}; virtual void tick(ccTime dt){CC_UNUSED_PARAM(dt);};
virtual void callfunc(){}; virtual void callfunc(){};
virtual void callfunc(CCNode* pSender){}; virtual void callfunc(CCNode* pSender){CC_UNUSED_PARAM(pSender);};
virtual void callfunc(CCNode* pSender, void* pData){}; virtual void callfunc(CCNode* pSender, void* pData){CC_UNUSED_PARAM(pSender);CC_UNUSED_PARAM(pData);};
virtual void menuHandler(CCObject* pSender){}; virtual void menuHandler(CCObject* pSender){CC_UNUSED_PARAM(pSender);};
virtual void eventHandler(CCEvent* pEvent) {}; virtual void eventHandler(CCEvent* pEvent) {CC_UNUSED_PARAM(pEvent);};
// the child call responding retain/release function // the child call responding retain/release function
virtual void selectorProtocolRetain(void) {}; virtual void selectorProtocolRetain(void) {};

View File

@ -142,7 +142,7 @@ namespace cocos2d{
while (strLeft.length() > 0) { while (strLeft.length() > 0) {
int pos = strLeft.find('\n'); int pos = strLeft.find('\n');
if (pos != std::string::npos) if (pos != (int)std::string::npos)
{ {
// the data is more than a line.get one line // the data is more than a line.get one line
line = strLeft.substr(0, pos); line = strLeft.substr(0, pos);

View File

@ -29,10 +29,10 @@ namespace cocos2d{
//CCLabelTTF //CCLabelTTF
// //
CCLabelTTF::CCLabelTTF() CCLabelTTF::CCLabelTTF()
: m_pFontName(NULL) : m_eAlignment(CCTextAlignmentCenter)
, m_pFontName(NULL)
, m_fFontSize(0.0)
, m_pString(NULL) , m_pString(NULL)
, m_fFontSize(0.0)
, m_eAlignment(CCTextAlignmentCenter)
{ {
} }

View File

@ -53,11 +53,11 @@ bool CCLayer::init()
do do
{ {
CCDirector * pDirector; CCDirector * pDirector;
CC_BREAK_IF( ! (pDirector = CCDirector::sharedDirector()) ); CC_BREAK_IF(!(pDirector = CCDirector::sharedDirector()));
this->setContentSize(pDirector->getWinSize()); this->setContentSize(pDirector->getWinSize());
// success // success
bRet = true; bRet = true;
} while (0); } while(0);
return bRet; return bRet;
} }
@ -251,6 +251,8 @@ void CCLayer::onEnterTransitionDidFinish()
bool CCLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) bool CCLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{ {
CC_UNUSED_PARAM(pTouch);
CC_UNUSED_PARAM(pEvent);
CCAssert(false, "Layer#ccTouchBegan override me"); CCAssert(false, "Layer#ccTouchBegan override me");
return true; return true;
} }

View File

@ -143,6 +143,7 @@ void CCTransitionScene::finish()
void CCTransitionScene::setNewScene(ccTime dt) void CCTransitionScene::setNewScene(ccTime dt)
{ {
CC_UNUSED_PARAM(dt);
// [self unschedule:_cmd]; // [self unschedule:_cmd];
// "_cmd" is a local variable automatically defined in a method // "_cmd" is a local variable automatically defined in a method
// that contains the selector for the method // that contains the selector for the method

View File

@ -146,6 +146,7 @@ namespace cocos2d{
bool CCMenu::ccTouchBegan(CCTouch* touch, CCEvent* event) bool CCMenu::ccTouchBegan(CCTouch* touch, CCEvent* event)
{ {
CC_UNUSED_PARAM(event);
if (m_eState != kCCMenuStateWaiting || ! m_bIsVisible) if (m_eState != kCCMenuStateWaiting || ! m_bIsVisible)
{ {
return false; return false;
@ -162,6 +163,8 @@ namespace cocos2d{
void CCMenu::ccTouchEnded(CCTouch *touch, CCEvent* event) void CCMenu::ccTouchEnded(CCTouch *touch, CCEvent* event)
{ {
CC_UNUSED_PARAM(touch);
CC_UNUSED_PARAM(event);
CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state"); CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");
if (m_pSelectedItem) if (m_pSelectedItem)
{ {
@ -173,6 +176,8 @@ namespace cocos2d{
void CCMenu::ccTouchCancelled(CCTouch *touch, CCEvent* event) void CCMenu::ccTouchCancelled(CCTouch *touch, CCEvent* event)
{ {
CC_UNUSED_PARAM(touch);
CC_UNUSED_PARAM(event);
CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state"); CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state");
if (m_pSelectedItem) if (m_pSelectedItem)
{ {
@ -183,6 +188,7 @@ namespace cocos2d{
void CCMenu::ccTouchMoved(CCTouch* touch, CCEvent* event) void CCMenu::ccTouchMoved(CCTouch* touch, CCEvent* event)
{ {
CC_UNUSED_PARAM(event);
CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state"); CCAssert(m_eState == kCCMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state");
CCMenuItem *currentItem = this->itemForTouch(touch); CCMenuItem *currentItem = this->itemForTouch(touch);
if (currentItem != m_pSelectedItem) if (currentItem != m_pSelectedItem)
@ -348,8 +354,8 @@ namespace cocos2d{
row = 0; row = 0;
rowHeight = 0; rowHeight = 0;
rowColumns = 0; rowColumns = 0;
float w; float w = 0.0;
float x; float x = 0.0;
float y = (float)(height / 2); float y = (float)(height / 2);
if (m_pChildren && m_pChildren->count() > 0) if (m_pChildren && m_pChildren->count() > 0)
@ -465,7 +471,7 @@ namespace cocos2d{
columnWidth = 0; columnWidth = 0;
columnRows = 0; columnRows = 0;
float x = (float)(-width / 2); float x = (float)(-width / 2);
float y; float y = 0.0;
if (m_pChildren && m_pChildren->count() > 0) if (m_pChildren && m_pChildren->count() > 0)
{ {

View File

@ -244,6 +244,8 @@ bool CCRenderTexture::saveBuffer(const char *name)
} }
bool CCRenderTexture::saveBuffer(const char *fileName, int format) bool CCRenderTexture::saveBuffer(const char *fileName, int format)
{ {
CC_UNUSED_PARAM(fileName);
CC_UNUSED_PARAM(format);
bool bRet = false; bool bRet = false;
//@ todo CCRenderTexture::saveBuffer //@ todo CCRenderTexture::saveBuffer
// UIImage *myImage = this->getUIImageFromBuffer(format); // UIImage *myImage = this->getUIImageFromBuffer(format);
@ -263,6 +265,7 @@ bool CCRenderTexture::saveBuffer(const char *fileName, int format)
CCData * CCRenderTexture::getUIImageAsDataFromBuffer(int format) CCData * CCRenderTexture::getUIImageAsDataFromBuffer(int format)
{ {
CC_UNUSED_PARAM(format);
CCData * pData = NULL; CCData * pData = NULL;
//@ todo CCRenderTexture::getUIImageAsDataFromBuffer //@ todo CCRenderTexture::getUIImageAsDataFromBuffer

View File

@ -656,6 +656,8 @@ void CCParticleSystem::update(ccTime dt)
} }
void CCParticleSystem::updateQuadWithParticle(tCCParticle* particle, CCPoint newPosition) void CCParticleSystem::updateQuadWithParticle(tCCParticle* particle, CCPoint newPosition)
{ {
CC_UNUSED_PARAM(particle);
CC_UNUSED_PARAM(newPosition);
// should be overriden // should be overriden
} }
void CCParticleSystem::postStep() void CCParticleSystem::postStep()

View File

@ -90,6 +90,8 @@ public:
void startElement(void *ctx, const char *name, const char **atts) void startElement(void *ctx, const char *name, const char **atts)
{ {
CC_UNUSED_PARAM(ctx);
CC_UNUSED_PARAM(atts);
std::string sName((char*)name); std::string sName((char*)name);
if( sName == "dict" ) if( sName == "dict" )
{ {
@ -169,6 +171,7 @@ public:
void endElement(void *ctx, const char *name) void endElement(void *ctx, const char *name)
{ {
CC_UNUSED_PARAM(ctx);
CCSAXState curState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top(); CCSAXState curState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top();
std::string sName((char*)name); std::string sName((char*)name);
if( sName == "dict" ) if( sName == "dict" )
@ -220,6 +223,7 @@ public:
void textHandler(void *ctx, const char *ch, int len) void textHandler(void *ctx, const char *ch, int len)
{ {
CC_UNUSED_PARAM(ctx);
if (m_tState == SAX_NONE) if (m_tState == SAX_NONE)
{ {
return; return;
@ -250,6 +254,8 @@ public:
} }
break; break;
} }
default:
break;
} }
pText->release(); pText->release();
} }
@ -311,7 +317,7 @@ unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const
pBuffer = new unsigned char[FileInfo.uncompressed_size]; pBuffer = new unsigned char[FileInfo.uncompressed_size];
int nSize = 0; int nSize = 0;
nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size); nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size);
CCAssert(nSize == 0 || nSize == FileInfo.uncompressed_size, "the file size is wrong"); CCAssert(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong");
*pSize = FileInfo.uncompressed_size; *pSize = FileInfo.uncompressed_size;
unzCloseCurrentFile(pFile); unzCloseCurrentFile(pFile);

View File

@ -86,6 +86,7 @@ CCImage::~CCImage()
bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/)
{ {
CC_UNUSED_PARAM(eImgFmt);
CCFileData data(CCFileUtils::fullPathFromRelativePath(strPath), "rb"); CCFileData data(CCFileUtils::fullPathFromRelativePath(strPath), "rb");
return initWithImageData(data.getBuffer(), data.getSize()); return initWithImageData(data.getBuffer(), data.getSize());
} }
@ -153,8 +154,8 @@ bool CCImage::_initWithJpgData(void * data, int nSize)
jpeg_start_decompress( &cinfo ); jpeg_start_decompress( &cinfo );
/* init image info */ /* init image info */
m_nWidth = cinfo.image_width; m_nWidth = (short)(cinfo.image_width);
m_nHeight = cinfo.image_height; m_nHeight = (short)(cinfo.image_height);
m_bHasAlpha = false; m_bHasAlpha = false;
m_bPreMulti = false; m_bPreMulti = false;
m_nBitsPerComponent = 8; m_nBitsPerComponent = 8;
@ -206,7 +207,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
// init png_info // init png_info
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
CC_BREAK_IF(! info_ptr || setjmp(png_jmpbuf(png_ptr))); CC_BREAK_IF(!info_ptr || setjmp(png_jmpbuf(png_ptr)));
// set the read call back function // set the read call back function
tImageSource imageSource; tImageSource imageSource;

View File

@ -100,7 +100,7 @@ public:
/** /**
@brief Save the CCImage data to specified file with specified format. @brief Save the CCImage data to specified file with specified format.
*/ */
bool saveToFile(const char * pszFilePath) { return false; } bool saveToFile(const char * pszFilePath) { CC_UNUSED_PARAM(pszFilePath);return false; }
CC_SYNTHESIZE_READONLY(short, m_nWidth, Width); CC_SYNTHESIZE_READONLY(short, m_nWidth, Width);
CC_SYNTHESIZE_READONLY(short, m_nHeight, Height); CC_SYNTHESIZE_READONLY(short, m_nHeight, Height);

View File

@ -151,7 +151,7 @@ There are config below:
// Check the supportive of platform // Check the supportive of platform
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#pragma warning (disable:4127)
#endif // CC_PLATFORM_WIN32 #endif // CC_PLATFORM_WIN32
#endif // __CC_PLATFORM_CONFIG_H__ #endif // __CC_PLATFORM_CONFIG_H__

View File

@ -120,9 +120,9 @@ public: inline void set##funName(varType var){ varName = var; }
// cocos2d debug // cocos2d debug
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
#define CCLOG(...) do {} while (0) #define CCLOG(...)
#define CCLOGINFO(...) do {} while (0) #define CCLOGINFO(...)
#define CCLOGERROR(...) do {} while (0) #define CCLOGERROR(...)
#elif COCOS2D_DEBUG == 1 #elif COCOS2D_DEBUG == 1
#define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__) #define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__)
@ -141,6 +141,9 @@ public: inline void set##funName(varType var){ varName = var; }
// assertion // assertion
#include <assert.h> #include <assert.h>
#define CC_ASSERT(cond) assert(cond) #define CC_ASSERT(cond) assert(cond)
#define CC_UNUSED_PARAM(unusedparam) unusedparam
// platform depended macros // platform depended macros

View File

@ -43,6 +43,7 @@ CCSAXParser::~CCSAXParser(void)
bool CCSAXParser::init(const char *pszEncoding) bool CCSAXParser::init(const char *pszEncoding)
{ {
CC_UNUSED_PARAM(pszEncoding);
// nothing to do // nothing to do
return true; return true;
} }

View File

@ -35,9 +35,9 @@ THE SOFTWARE.
namespace cocos2d { namespace cocos2d {
CCEGLView::CCEGLView() CCEGLView::CCEGLView()
: m_pDelegate(NULL), : m_bNotHVGA(false),
m_fScreenScaleFactor(1.0), m_pDelegate(NULL),
m_bNotHVGA(false) m_fScreenScaleFactor(1.0)
{ {
} }

View File

@ -350,7 +350,7 @@ extern "C"
void setKeyboardStateJNI(int bOpen) void setKeyboardStateJNI(int bOpen)
{ {
TMethodJNI t; TMethodJNI t;
jint open = bOpen; //jint open = bOpen;
if (getMethodID(t if (getMethodID(t
, "org/cocos2dx/lib/Cocos2dxGLSurfaceView" , "org/cocos2dx/lib/Cocos2dxGLSurfaceView"
, (bOpen) ? "openIMEKeyboard" : "closeIMEKeyboard" , (bOpen) ? "openIMEKeyboard" : "closeIMEKeyboard"

View File

@ -30,6 +30,7 @@ NS_CC_BEGIN;
int CCTime::gettimeofdayCocos2d(struct cc_timeval *tp, void *tzp) int CCTime::gettimeofdayCocos2d(struct cc_timeval *tp, void *tzp)
{ {
CC_UNUSED_PARAM(tzp);
if (tp) if (tp)
{ {
gettimeofday((struct timeval *)tp, 0); gettimeofday((struct timeval *)tp, 0);

View File

@ -35,8 +35,8 @@ public:
static CCAccelerometer* sharedAccelerometer() { return NULL; } static CCAccelerometer* sharedAccelerometer() { return NULL; }
void removeDelegate(CCAccelerometerDelegate* pDelegate) {} void removeDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);}
void addDelegate(CCAccelerometerDelegate* pDelegate) {} void addDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);}
}; };
}//namespace cocos2d }//namespace cocos2d

View File

@ -182,8 +182,8 @@ static LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
CCEGLView::CCEGLView() CCEGLView::CCEGLView()
: m_bCaptured(false) : m_bCaptured(false)
, m_bOrientationInitVertical(false)
, m_bOrientationReverted(false) , m_bOrientationReverted(false)
, m_bOrientationInitVertical(false)
, m_pDelegate(NULL) , m_pDelegate(NULL)
, m_pEGL(NULL) , m_pEGL(NULL)
, m_hWnd(NULL) , m_hWnd(NULL)

View File

@ -144,6 +144,7 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
void CCFileUtils::setResource(const char* pszZipFileName) void CCFileUtils::setResource(const char* pszZipFileName)
{ {
CC_UNUSED_PARAM(pszZipFileName);
CCAssert(0, "Have not implement!"); CCAssert(0, "Have not implement!");
} }
@ -155,6 +156,7 @@ const char* CCFileUtils::getResourcePath(void)
void CCFileUtils::setRelativePath(const char* pszRelativePath) void CCFileUtils::setRelativePath(const char* pszRelativePath)
{ {
CC_UNUSED_PARAM(pszRelativePath);
CCAssert(0, "Have not implement!"); CCAssert(0, "Have not implement!");
} }

View File

@ -236,7 +236,6 @@ public:
HGDIOBJ hOldFont = SelectObject(m_hDC, m_hFont); HGDIOBJ hOldFont = SelectObject(m_hDC, m_hFont);
HGDIOBJ hOldBmp = SelectObject(m_hDC, m_hBmp); HGDIOBJ hOldBmp = SelectObject(m_hDC, m_hBmp);
RECT rc = {0, 0, tSize.cx, tSize.cy};
SetBkMode(m_hDC, TRANSPARENT); SetBkMode(m_hDC, TRANSPARENT);
SetTextColor(m_hDC, RGB(255, 255, 255)); // white color SetTextColor(m_hDC, RGB(255, 255, 255)); // white color
@ -283,7 +282,6 @@ bool CCImage::initWithString(
do do
{ {
CC_BREAK_IF(! pText); CC_BREAK_IF(! pText);
int nLen = strlen(pText);
BitmapDC& dc = sharedBitmapDC(); BitmapDC& dc = sharedBitmapDC();

View File

@ -117,6 +117,9 @@ CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, CCRect rect)
CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, CCRect rect, CCPoint offset) CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, CCRect rect, CCPoint offset)
{ {
CC_UNUSED_PARAM(pTexture);
CC_UNUSED_PARAM(rect);
CC_UNUSED_PARAM(offset);
// not implement // not implement
assert(0); assert(0);
return NULL; return NULL;

View File

@ -422,7 +422,8 @@ namespace cocos2d
// ignore parent Z if parent is spriteSheet // ignore parent Z if parent is spriteSheet
bool bIgnoreParent = (CCSpriteBatchNode*)(pobSprite->getParent()) == this; bool bIgnoreParent = (CCSpriteBatchNode*)(pobSprite->getParent()) == this;
CCSprite *pPrevious = NULL; CCSprite *pPrevious = NULL;
if (uChildIndex > 0) if (uChildIndex > 0 &&
uChildIndex < UINT_MAX)
{ {
pPrevious = (CCSprite*)(pBrothers->objectAtIndex(uChildIndex - 1)); pPrevious = (CCSprite*)(pBrothers->objectAtIndex(uChildIndex - 1));
} }
@ -537,7 +538,7 @@ namespace cocos2d
pobSprite->useSelfRender(); pobSprite->useSelfRender();
unsigned int uIndex = m_pobDescendants->indexOfObject(pobSprite); unsigned int uIndex = m_pobDescendants->indexOfObject(pobSprite);
if (uIndex != -1) if (uIndex != UINT_MAX)
{ {
m_pobDescendants->removeObjectAtIndex(uIndex); m_pobDescendants->removeObjectAtIndex(uIndex);

View File

@ -79,6 +79,7 @@ CCSpriteFrame::~CCSpriteFrame(void)
CCObject* CCSpriteFrame::copyWithZone(CCZone *pZone) CCObject* CCSpriteFrame::copyWithZone(CCZone *pZone)
{ {
CC_UNUSED_PARAM(pZone);
CCSpriteFrame *pCopy = new CCSpriteFrame(); CCSpriteFrame *pCopy = new CCSpriteFrame();
pCopy->initWithTexture(m_pobTexture, m_obRectInPixels, m_bRotated, m_obOffsetInPixels, m_obOriginalSizeInPixels); pCopy->initWithTexture(m_pobTexture, m_obRectInPixels, m_bRotated, m_obOffsetInPixels, m_obOriginalSizeInPixels);

View File

@ -95,7 +95,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary<std::string,
framesDict->begin(); framesDict->begin();
std::string key = ""; std::string key = "";
CCDictionary<std::string, CCObject*> *frameDict = NULL; CCDictionary<std::string, CCObject*> *frameDict = NULL;
while( frameDict = (CCDictionary<std::string, CCObject*>*)framesDict->next(&key) ) while( (frameDict = (CCDictionary<std::string, CCObject*>*)framesDict->next(&key)) )
{ {
CCSpriteFrame *spriteFrame = m_pSpriteFrames->objectForKey(key); CCSpriteFrame *spriteFrame = m_pSpriteFrames->objectForKey(key);
if (spriteFrame) if (spriteFrame)
@ -237,7 +237,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist)
// stringByDeletingLastPathComponent // stringByDeletingLastPathComponent
string textureBase(pszPath); string textureBase(pszPath);
int indexOfLastSeperator = textureBase.find_last_of('/'); int indexOfLastSeperator = textureBase.find_last_of('/');
if (indexOfLastSeperator == textureBase.length() - 1) if (indexOfLastSeperator == (int)textureBase.length() - 1)
{ {
textureBase.erase(indexOfLastSeperator, 1); textureBase.erase(indexOfLastSeperator, 1);
indexOfLastSeperator = textureBase.find_last_of('/'); indexOfLastSeperator = textureBase.find_last_of('/');
@ -293,7 +293,7 @@ void CCSpriteFrameCache::removeUnusedSpriteFrames(void)
m_pSpriteFrames->begin(); m_pSpriteFrames->begin();
std::string key = ""; std::string key = "";
CCSpriteFrame *spriteFrame = NULL; CCSpriteFrame *spriteFrame = NULL;
while( spriteFrame = m_pSpriteFrames->next(&key) ) while( (spriteFrame = m_pSpriteFrames->next(&key)) )
{ {
if( spriteFrame->retainCount() == 1 ) if( spriteFrame->retainCount() == 1 )
{ {
@ -343,7 +343,7 @@ void CCSpriteFrameCache::removeSpriteFramesFromDictionary(CCDictionary<std::stri
framesDict->begin(); framesDict->begin();
std::string key = ""; std::string key = "";
CCDictionary<std::string, CCObject*> *frameDict = NULL; CCDictionary<std::string, CCObject*> *frameDict = NULL;
while( frameDict = (CCDictionary<std::string, CCObject*>*)framesDict->next(&key) ) while( (frameDict = (CCDictionary<std::string, CCObject*>*)framesDict->next(&key)) )
{ {
if (m_pSpriteFrames->objectForKey(key)) if (m_pSpriteFrames->objectForKey(key))
{ {
@ -366,7 +366,7 @@ void CCSpriteFrameCache::removeSpriteFramesFromTexture(CCTexture2D* texture)
m_pSpriteFrames->begin(); m_pSpriteFrames->begin();
std::string key = ""; std::string key = "";
CCDictionary<std::string, CCObject*> *frameDict = NULL; CCDictionary<std::string, CCObject*> *frameDict = NULL;
while( frameDict = (CCDictionary<std::string, CCObject*>*)m_pSpriteFrames->next(&key) ) while( (frameDict = (CCDictionary<std::string, CCObject*>*)m_pSpriteFrames->next(&key)) )
{ {
CCSpriteFrame *frame = m_pSpriteFrames->objectForKey(key); CCSpriteFrame *frame = m_pSpriteFrames->objectForKey(key);
if (frame && (frame->getTexture() == texture)) if (frame && (frame->getTexture() == texture))

View File

@ -118,13 +118,13 @@ static inline unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* objec
} }
} }
return -1; return UINT_MAX;
} }
/** Returns a Boolean value that indicates whether object is present in array. */ /** Returns a Boolean value that indicates whether object is present in array. */
static inline bool ccArrayContainsObject(ccArray *arr, CCObject* object) static inline bool ccArrayContainsObject(ccArray *arr, CCObject* object)
{ {
return ccArrayGetIndexOfObject(arr, object) != -1; return ccArrayGetIndexOfObject(arr, object) != UINT_MAX;
} }
/** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */ /** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */
@ -210,7 +210,7 @@ static inline void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int ind
static inline void ccArrayFastRemoveObject(ccArray *arr, CCObject* object) static inline void ccArrayFastRemoveObject(ccArray *arr, CCObject* object)
{ {
unsigned int index = ccArrayGetIndexOfObject(arr, object); unsigned int index = ccArrayGetIndexOfObject(arr, object);
if (index != -1) if (index != UINT_MAX)
ccArrayFastRemoveObjectAtIndex(arr, index); ccArrayFastRemoveObjectAtIndex(arr, index);
} }
@ -220,7 +220,7 @@ static inline void ccArrayRemoveObject(ccArray *arr, CCObject* object)
{ {
unsigned int index = ccArrayGetIndexOfObject(arr, object); unsigned int index = ccArrayGetIndexOfObject(arr, object);
if (index != -1) if (index != UINT_MAX)
{ {
ccArrayRemoveObjectAtIndex(arr, index); ccArrayRemoveObjectAtIndex(arr, index);
} }
@ -422,7 +422,7 @@ static inline void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int in
static inline void ccCArrayRemoveValue(ccCArray *arr, void* value) static inline void ccCArrayRemoveValue(ccCArray *arr, void* value)
{ {
unsigned int index = ccCArrayGetIndexOfValue(arr, value); unsigned int index = ccCArrayGetIndexOfValue(arr, value);
if (index != -1) if (index != UINT_MAX)
{ {
ccCArrayRemoveValueAtIndex(arr, index); ccCArrayRemoveValueAtIndex(arr, index);
} }

View File

@ -33,7 +33,7 @@ static int _calcCharCount(const char * pszText)
{ {
int n = 0; int n = 0;
char ch = 0; char ch = 0;
while (ch = *pszText) while ((ch = *pszText))
{ {
CC_BREAK_IF(! ch); CC_BREAK_IF(! ch);
@ -174,7 +174,7 @@ void CCTextFieldTTF::insertText(const char * text, int len)
// insert \n means input end // insert \n means input end
int nPos = sInsert.find('\n'); int nPos = sInsert.find('\n');
if (sInsert.npos != nPos) if ((int)sInsert.npos != nPos)
{ {
len = nPos; len = nPos;
sInsert.erase(nPos); sInsert.erase(nPos);
@ -194,7 +194,7 @@ void CCTextFieldTTF::insertText(const char * text, int len)
setString(sText.c_str()); setString(sText.c_str());
} }
if (sInsert.npos == nPos) { if ((int)sInsert.npos == nPos) {
return; return;
} }

View File

@ -62,12 +62,12 @@ namespace cocos2d {
static CCTexture2DPixelFormat g_defaultAlphaPixelFormat = kCCTexture2DPixelFormat_Default; static CCTexture2DPixelFormat g_defaultAlphaPixelFormat = kCCTexture2DPixelFormat_Default;
CCTexture2D::CCTexture2D() CCTexture2D::CCTexture2D()
: m_uName(0) : m_uPixelsWide(0)
, m_bHasPremultipliedAlpha(false) , m_uPixelsHigh(0)
, m_uName(0)
, m_fMaxS(0.0) , m_fMaxS(0.0)
, m_fMaxT(0.0) , m_fMaxT(0.0)
, m_uPixelsHigh(0) , m_bHasPremultipliedAlpha(false)
, m_uPixelsWide(0)
{ {
} }
@ -145,6 +145,7 @@ void CCTexture2D::releaseData(void *data)
void* CCTexture2D::keepData(void *data, unsigned int length) void* CCTexture2D::keepData(void *data, unsigned int length)
{ {
CC_UNUSED_PARAM(length);
//The texture data mustn't be saved becuase it isn't a mutable texture. //The texture data mustn't be saved becuase it isn't a mutable texture.
return data; return data;
} }
@ -291,7 +292,7 @@ bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned in
tempData = (unsigned char*)(image->getData()); tempData = (unsigned char*)(image->getData());
CCAssert(tempData != NULL, "NULL image data."); CCAssert(tempData != NULL, "NULL image data.");
if(image->getWidth() == POTWide && image->getHeight() == POTHigh) if(image->getWidth() == (short)POTWide && image->getHeight() == (short)POTHigh)
{ {
data = new unsigned char[POTHigh * POTWide * 4]; data = new unsigned char[POTHigh * POTWide * 4];
memcpy(data, tempData, POTHigh * POTWide * 4); memcpy(data, tempData, POTHigh * POTWide * 4);
@ -315,7 +316,7 @@ bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned in
case kCCTexture2DPixelFormat_RGB888: case kCCTexture2DPixelFormat_RGB888:
tempData = (unsigned char*)(image->getData()); tempData = (unsigned char*)(image->getData());
CCAssert(tempData != NULL, "NULL image data."); CCAssert(tempData != NULL, "NULL image data.");
if(image->getWidth() == POTWide && image->getHeight() == POTHigh) if(image->getWidth() == (short)POTWide && image->getHeight() == (short)POTHigh)
{ {
data = new unsigned char[POTHigh * POTWide * 3]; data = new unsigned char[POTHigh * POTWide * 3];
memcpy(data, tempData, POTHigh * POTWide * 3); memcpy(data, tempData, POTHigh * POTWide * 3);

View File

@ -40,8 +40,8 @@ THE SOFTWARE.
namespace cocos2d { namespace cocos2d {
CCTextureAtlas::CCTextureAtlas() CCTextureAtlas::CCTextureAtlas()
:m_pTexture(NULL) :m_pIndices(NULL)
,m_pIndices(NULL) ,m_pTexture(NULL)
,m_pQuads(NULL) ,m_pQuads(NULL)
{} {}
@ -189,14 +189,14 @@ void CCTextureAtlas::initIndices()
m_pIndices[i*6+4] = i*4+3; m_pIndices[i*6+4] = i*4+3;
m_pIndices[i*6+5] = i*4+3; m_pIndices[i*6+5] = i*4+3;
#else #else
m_pIndices[i*6+0] = i*4+0; m_pIndices[i*6+0] = (GLushort)(i*4+0);
m_pIndices[i*6+1] = i*4+1; m_pIndices[i*6+1] = (GLushort)(i*4+1);
m_pIndices[i*6+2] = i*4+2; m_pIndices[i*6+2] = (GLushort)(i*4+2);
// inverted index. issue #179 // inverted index. issue #179
m_pIndices[i*6+3] = i*4+3; m_pIndices[i*6+3] = (GLushort)(i*4+3);
m_pIndices[i*6+4] = i*4+2; m_pIndices[i*6+4] = (GLushort)(i*4+2);
m_pIndices[i*6+5] = i*4+1; m_pIndices[i*6+5] = (GLushort)(i*4+1);
// m_pIndices[i*6+3] = i*4+2; // m_pIndices[i*6+3] = i*4+2;
// m_pIndices[i*6+4] = i*4+3; // m_pIndices[i*6+4] = i*4+3;
// m_pIndices[i*6+5] = i*4+1; // m_pIndices[i*6+5] = i*4+1;

View File

@ -363,7 +363,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key)
do do
{ {
// If key is nil, then create a new texture each time // If key is nil, then create a new texture each time
if(texture = m_pTextures->objectForKey(forKey)) if((texture = m_pTextures->objectForKey(forKey)))
{ {
break; break;
} }
@ -456,10 +456,10 @@ VolatileTexture::VolatileTexture(CCTexture2D *t)
, m_bIsString(false) , m_bIsString(false)
, m_strFileName("") , m_strFileName("")
, m_FmtImage(CCImage::kFmtPng) , m_FmtImage(CCImage::kFmtPng)
, m_alignment(CCTextAlignmentCenter)
, m_strFontName("") , m_strFontName("")
, m_strText("") , m_strText("")
, m_fFontSize(0.0f) , m_fFontSize(0.0f)
, m_alignment(CCTextAlignmentCenter)
{ {
m_size = CCSizeMake(0, 0); m_size = CCSizeMake(0, 0);
textures.push_back(this); textures.push_back(this);

View File

@ -71,6 +71,9 @@ namespace cocos2d {
} }
void CCParallaxNode::addChild(CCNode * child, int zOrder, int tag) void CCParallaxNode::addChild(CCNode * child, int zOrder, int tag)
{ {
CC_UNUSED_PARAM(zOrder);
CC_UNUSED_PARAM(child);
CC_UNUSED_PARAM(tag);
CCAssert(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead"); CCAssert(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead");
} }
void CCParallaxNode::addChild(CCNode *child, int z, CCPoint ratio, CCPoint offset) void CCParallaxNode::addChild(CCNode *child, int z, CCPoint ratio, CCPoint offset)

View File

@ -92,14 +92,14 @@ namespace cocos2d {
return false; return false;
} }
CCTMXLayer::CCTMXLayer() CCTMXLayer::CCTMXLayer()
:m_pTiles(NULL) :m_tLayerSize(CCSizeZero)
,m_tMapTileSize(CCSizeZero)
,m_pTiles(NULL)
,m_pTileSet(NULL) ,m_pTileSet(NULL)
,m_pProperties(NULL) ,m_pProperties(NULL)
,m_sLayerName("")
,m_pReusedTile(NULL) ,m_pReusedTile(NULL)
,m_pAtlasIndexArray(NULL) ,m_pAtlasIndexArray(NULL)
,m_tLayerSize(CCSizeZero)
,m_tMapTileSize(CCSizeZero)
,m_sLayerName("")
{} {}
CCTMXLayer::~CCTMXLayer() CCTMXLayer::~CCTMXLayer()
{ {
@ -446,6 +446,9 @@ namespace cocos2d {
} }
void CCTMXLayer::addChild(CCNode * child, int zOrder, int tag) void CCTMXLayer::addChild(CCNode * child, int zOrder, int tag)
{ {
CC_UNUSED_PARAM(child);
CC_UNUSED_PARAM(zOrder);
CC_UNUSED_PARAM(tag);
CCAssert(0, "addChild: is not supported on CCTMXLayer. Instead use setTileGID:at:/tileAt:"); CCAssert(0, "addChild: is not supported on CCTMXLayer. Instead use setTileGID:at:/tileAt:");
} }
void CCTMXLayer::removeChild(CCNode* node, bool cleanup) void CCTMXLayer::removeChild(CCNode* node, bool cleanup)

View File

@ -30,8 +30,8 @@ namespace cocos2d {
//implementation CCTMXObjectGroup //implementation CCTMXObjectGroup
CCTMXObjectGroup::CCTMXObjectGroup() CCTMXObjectGroup::CCTMXObjectGroup()
:m_sGroupName("") :m_tPositionOffset(CCPointZero)
,m_tPositionOffset(CCPointZero) ,m_sGroupName("")
{ {
m_pObjects = new CCMutableArray<CCStringToStringDictionary*>(); m_pObjects = new CCMutableArray<CCStringToStringDictionary*>();
m_pProperties = new CCStringToStringDictionary(); m_pProperties = new CCStringToStringDictionary();

View File

@ -104,8 +104,8 @@ namespace cocos2d{
return true; return true;
} }
CCTMXTiledMap::CCTMXTiledMap() CCTMXTiledMap::CCTMXTiledMap()
:m_tTileSize(CCSizeZero) :m_tMapSize(CCSizeZero)
,m_tMapSize(CCSizeZero) ,m_tTileSize(CCSizeZero)
,m_pObjectGroups(NULL) ,m_pObjectGroups(NULL)
,m_pProperties(NULL) ,m_pProperties(NULL)
,m_pTileProperties(NULL) ,m_pTileProperties(NULL)

View File

@ -64,12 +64,12 @@ namespace cocos2d {
} }
// implementation CCTMXLayerInfo // implementation CCTMXLayerInfo
CCTMXLayerInfo::CCTMXLayerInfo() CCTMXLayerInfo::CCTMXLayerInfo()
:m_bOwnTiles(true) : m_sName("")
,m_uMinGID(100000) , m_pTiles(NULL)
,m_uMaxGID(0) , m_bOwnTiles(true)
,m_sName("") , m_uMinGID(100000)
,m_pTiles(NULL) , m_uMaxGID(0)
,m_tOffset(CCPointZero) , m_tOffset(CCPointZero)
{ {
m_pProperties= new CCStringToStringDictionary();; m_pProperties= new CCStringToStringDictionary();;
} }
@ -150,13 +150,13 @@ namespace cocos2d {
return parseXMLFile(m_sTMXFileName.c_str()); return parseXMLFile(m_sTMXFileName.c_str());
} }
CCTMXMapInfo::CCTMXMapInfo() CCTMXMapInfo::CCTMXMapInfo()
:m_bStoringCharacters(false) :m_tMapSize(CCSizeZero)
,m_nLayerAttribs(0) ,m_tTileSize(CCSizeZero)
,m_tMapSize(CCSizeZero) ,m_pLayers(NULL)
,m_tTileSize(CCSizeZero) ,m_pTilesets(NULL)
,m_pLayers(NULL) ,m_pObjectGroups(NULL)
,m_pTilesets(NULL) ,m_nLayerAttribs(0)
,m_pObjectGroups(NULL) ,m_bStoringCharacters(false)
,m_pProperties(NULL) ,m_pProperties(NULL)
,m_pTileProperties(NULL) ,m_pTileProperties(NULL)
{ {
@ -239,6 +239,7 @@ namespace cocos2d {
// the XML parser calls here with all the elements // the XML parser calls here with all the elements
void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts) void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
{ {
CC_UNUSED_PARAM(ctx);
CCTMXMapInfo *pTMXMapInfo = this; CCTMXMapInfo *pTMXMapInfo = this;
std::string elementName = (char*)name; std::string elementName = (char*)name;
std::map<std::string, std::string> *attributeDict = new std::map<std::string, std::string>(); std::map<std::string, std::string> *attributeDict = new std::map<std::string, std::string>();
@ -519,6 +520,7 @@ namespace cocos2d {
void CCTMXMapInfo::endElement(void *ctx, const char *name) void CCTMXMapInfo::endElement(void *ctx, const char *name)
{ {
CC_UNUSED_PARAM(ctx);
CCTMXMapInfo *pTMXMapInfo = this; CCTMXMapInfo *pTMXMapInfo = this;
std::string elementName = (char*)name; std::string elementName = (char*)name;
@ -586,6 +588,7 @@ namespace cocos2d {
void CCTMXMapInfo::textHandler(void *ctx, const char *ch, int len) void CCTMXMapInfo::textHandler(void *ctx, const char *ch, int len)
{ {
CC_UNUSED_PARAM(ctx);
CCTMXMapInfo *pTMXMapInfo = this; CCTMXMapInfo *pTMXMapInfo = this;
std::string pText((char*)ch,0,len); std::string pText((char*)ch,0,len);

View File

@ -59,8 +59,8 @@ namespace cocos2d {
return false; return false;
} }
CCTileMapAtlas::CCTileMapAtlas() CCTileMapAtlas::CCTileMapAtlas()
:m_pPosToAtlasIndex(NULL) :m_pTGAInfo(NULL)
,m_pTGAInfo(NULL) ,m_pPosToAtlasIndex(NULL)
,m_nItemsToRender(0) ,m_nItemsToRender(0)
{ {
} }

View File

@ -231,6 +231,8 @@ void CCTouchDispatcher::removeAllDelegates(void)
void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate) void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate)
{ {
CC_UNUSED_PARAM(nPriority);
CC_UNUSED_PARAM(pDelegate);
assert(0); assert(0);
} }

17
generate_xcode4_templates.sh Executable file
View File

@ -0,0 +1,17 @@
echo "generating libcocos2dx"
mkdir -p template/xcode4/lib_cocos2dx.xctemplate
python ./template/xcode4/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 airplay wophone third_party CCImage.cpp Android.mk" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist
echo "generating libcocosdenshion"
mkdir -p template/xcode4/lib_cocosdenshion.xctemplate
python ./template/xcode4/template_generator.py --directory CocosDenshion --identifier libcocosdenshion --prefix libs --exclude "android win32 airplay wophone Android.mk" > ./template/xcode4/lib_cocosdenshion.xctemplate/TemplateInfo.plist
echo "generating libbox2d"
mkdir -p template/xcode4/lib_box2d.xctemplate
python ./template/xcode4/template_generator.py --directory Box2D --identifier libbox2d --prefix libs --exclude "android win32 airplay wophone Android.mk" > ./template/xcode4/lib_box2d.xctemplate/TemplateInfo.plist
echo "generating libchipmunk"
mkdir -p template/xcode4/lib_chipmunk.xctemplate
python ./template/xcode4/template_generator.py --directory chipmunk --identifier libchipmunk --prefix libs --exclude "android win32 airplay wophone Android.mk" > ./template/xcode4/lib_chipmunk.xctemplate/TemplateInfo.plist
echo "done"

309
install-templates-xcode.sh Executable file
View File

@ -0,0 +1,309 @@
#!/bin/bash
echo 'cocos2d-x template installer'
COCOS2D_VER='cocos2d-0.99.5-x-0.8.4'
BASE_TEMPLATE_DIR="/Library/Application Support/Developer/Shared/Xcode"
BASE_TEMPLATE_USER_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode"
force=
user_dir=
usage(){
cat << EOF
usage: $0 [options]
Install / update templates for ${COCOS2D_VER}
OPTIONS:
-f force overwrite if directories exist
-h this help
-u install in user's Library directory instead of global directory
EOF
}
while getopts "fhu" OPTION; do
case "$OPTION" in
f)
force=1
;;
h)
usage
exit 0
;;
u)
user_dir=1
;;
esac
done
# Make sure only root can run our script
if [[ ! $user_dir && "$(id -u)" != "0" ]]; then
echo ""
echo "Error: This script must be run as root in order to copy templates to ${BASE_TEMPLATE_DIR}" 1>&2
echo ""
echo "Try running it with 'sudo', or with '-u' to install it only you:" 1>&2
echo " sudo $0" 1>&2
echo "or:" 1>&2
echo " $0 -u" 1>&2
exit 1
fi
# Make sure root and user_dir is not executed at the same time
if [[ $user_dir && "$(id -u)" == "0" ]]; then
echo ""
echo "Error: Do not run this script as root with the '-u' option." 1>&2
echo ""
echo "Either use the '-u' option or run it as root, but not both options at the same time." 1>&2
echo ""
echo "RECOMMENDED WAY:" 1>&2
echo " $0 -u -f" 1>&2
echo ""
exit 1
fi
copy_files(){
# SRC_DIR="${SCRIPT_DIR}/${1}"
rsync -r --exclude=.svn "$1" "$2"
}
check_dst_dir(){
if [[ -d $DST_DIR ]]; then
if [[ $force ]]; then
echo "removing old libraries: ${DST_DIR}"
rm -rf "${DST_DIR}"
else
echo "templates already installed. To force a re-install use the '-f' parameter"
exit 1
fi
fi
echo ...creating destination directory: $DST_DIR
mkdir -p "$DST_DIR"
}
# copy_base_mac_files(){
# echo ...copying cocos2dx files
# copy_files cocos2dx "$LIBS_DIR"
# echo ...copying CocosDenshion files
# copy_files CocosDenshion "$LIBS_DIR"
# }
copy_base_files(){
echo ...copying cocos2dx files
copy_files cocos2dx "$LIBS_DIR"
echo ...copying CocosDenshion files
copy_files CocosDenshion "$LIBS_DIR"
}
copy_cocos2d_files(){
echo ...copying cocos2d files
copy_files cocos2dx "$LIBS_DIR"
copy_files LICENSE.cocos2d-x "$LIBS_DIR"
}
copy_cocosdenshion_files(){
echo ...copying CocosDenshion files
copy_files CocosDenshion "$LIBS_DIR"
# copy_files LICENSE_CocosDenshion.txt "$LIBS_DIR"
}
# copy_cocosdenshionextras_files(){
# echo ...copying CocosDenshionExtras files
# copy_files CocosDenshion/CocosDenshionExtras "$LIBS_DIR"
# }
# copy_fontlabel_files(){
# echo ...copying FontLabel files
# copy_files external/FontLabel "$LIBS_DIR"
# copy_files LICENSE_FontLabel.txt "$LIBS_DIR"
# }
# copy_cocoslive_files(){
# echo ...copying cocoslive files
# copy_files cocoslive "$LIBS_DIR"
# echo ...copying TouchJSON files
# copy_files external/TouchJSON "$LIBS_DIR"
# copy_files LICENSE_TouchJSON.txt "$LIBS_DIR"
# }
print_template_banner(){
echo ''
echo ''
echo ''
echo "$1"
echo '----------------------------------------------------'
echo ''
}
# copies project-based templates
copy_xcode3_project_templates(){
if [[ $user_dir ]]; then
TEMPLATE_DIR="${BASE_TEMPLATE_USER_DIR}/Project Templates/${COCOS2D_VER}/"
else
TEMPLATE_DIR="${BASE_TEMPLATE_DIR}/Project Templates/${COCOS2D_VER}/"
fi
if [[ ! -d "$TEMPLATE_DIR" ]]; then
echo '...creating cocos2d template directory'
echo ''
mkdir -p "$TEMPLATE_DIR"
fi
print_template_banner "Installing Xcode 3 cocos2d-x iOS template"
DST_DIR="$TEMPLATE_DIR""cocos2d-x Application/"
LIBS_DIR="$DST_DIR"libs
check_dst_dir
echo ...copying template files
copy_files template/xcode3/cocos2d-x_app/ "$DST_DIR"
copy_base_files
echo done!
print_template_banner "Installing cocos2d-x iOS + box2d template"
DST_DIR="$TEMPLATE_DIR""cocos2d-x Box2d Application/"
LIBS_DIR="$DST_DIR"libs
check_dst_dir
echo ...copying template files
copy_files template/xcode3/cocos2d-x_box2d_app/ "$DST_DIR"
copy_base_files
echo ...copying Box2D files
copy_files Box2D "$LIBS_DIR"
echo done!
print_template_banner "Installing cocos2d-x iOS + chipmunk template"
DST_DIR="$TEMPLATE_DIR""cocos2d-x chipmunk Application/"
LIBS_DIR="$DST_DIR"libs
check_dst_dir
echo ...copying template files
copy_files template/xcode3/cocos2d-x_chipmunk_app/ "$DST_DIR"
copy_base_files
echo ...coping chipmunk files
copy_files chipmunk "$LIBS_DIR"
echo done!
}
copy_xcode3_file_templates(){
if [[ $user_dir ]]; then
TEMPLATE_DIR="${BASE_TEMPLATE_USER_DIR}/File Templates/${COCOS2D_VER}/"
else
TEMPLATE_DIR="${BASE_TEMPLATE_DIR}/File Templates/${COCOS2D_VER}/"
fi
echo ...copying file templates
DST_DIR="$TEMPLATE_DIR"
check_dst_dir
if [[ ! -d "$TEMPLATE_DIR" ]]; then
echo '...creating cocos2d template directory'
echo ''
mkdir -p "$TEMPLATE_DIR"
fi
# print_template_banner "Installing CCNode file templates..."
# copy_files "templates/file-templates/CCNode class" "$DST_DIR"
echo done!
}
# Xcode4 templates
copy_xcode4_project_templates(){
TEMPLATE_DIR="$HOME/Library/Developer/Xcode/Templates/cocos2d-x/"
print_template_banner "Installing Xcode 4 cocos2d-x iOS template"
DST_DIR="$TEMPLATE_DIR"
check_dst_dir
LIBS_DIR="$DST_DIR""lib_cocos2dx.xctemplate/libs/"
mkdir -p "$LIBS_DIR"
copy_cocos2d_files
# LIBS_DIR="$DST_DIR""lib_cocoslive.xctemplate/libs/"
# mkdir -p "$LIBS_DIR"
# copy_cocoslive_files
LIBS_DIR="$DST_DIR""lib_cocosdenshion.xctemplate/libs/"
mkdir -p "$LIBS_DIR"
copy_cocosdenshion_files
# LIBS_DIR="$DST_DIR""lib_cocosdenshionextras.xctemplate/libs/"
# mkdir -p "$LIBS_DIR"
# copy_cocosdenshionextras_files
# LIBS_DIR="$DST_DIR""lib_fontlabel.xctemplate/libs/"
# mkdir -p "$LIBS_DIR"
# copy_fontlabel_files
echo ...copying template files
copy_files template/xcode4/ "$DST_DIR"
echo done!
print_template_banner "Installing Xcode 4 Chipmunk iOS template"
LIBS_DIR="$DST_DIR""lib_chipmunk.xctemplate/libs/"
mkdir -p "$LIBS_DIR"
echo ...copying Chipmunk files
copy_files chipmunk "$LIBS_DIR"
copy_files LICENSE.chipmunk "$LIBS_DIR"
echo done!
print_template_banner "Installing Xcode 4 Box2d iOS template"
LIBS_DIR="$DST_DIR""lib_box2d.xctemplate/libs/"
mkdir -p "$LIBS_DIR"
echo ...copying Box2D files
copy_files Box2D "$LIBS_DIR"
copy_files LICENSE.box2d "$LIBS_DIR"
echo done!
# Move File Templates to correct position
# DST_DIR="$HOME/Library/Developer/Xcode/Templates/File Templates/cocos2d/"
# OLD_DIR="$HOME/Library/Developer/Xcode/Templates/cocos2d/"
# print_template_banner "Installing Xcode 4 CCNode file templates..."
# check_dst_dir
# mv -f "$OLD_DIR""/CCNode class.xctemplate" "$DST_DIR"
echo done!
}
# copy Xcode4 templates
copy_xcode4_project_templates
# copy Xcode3 templates
copy_xcode3_project_templates
# copy_xcode3_file_templates

View File

@ -1,186 +0,0 @@
#!/bin/bash
echo 'cocos2d-x template installer'
COCOS2D_VER='cocos2d-0.99.5-x-0.8.4'
BASE_TEMPLATE_DIR="/Library/Application Support/Developer/Shared/Xcode"
BASE_TEMPLATE_USER_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode"
force=
user_dir=
usage(){
cat << EOF
usage: $0 [options]
Install / update templates for ${COCOS2D_VER}
OPTIONS:
-f force overwrite if directories exist
-h this help
-u install in user's Library directory instead of global directory
EOF
}
while getopts "fhu" OPTION; do
case "$OPTION" in
f)
force=1
;;
h)
usage
exit 0
;;
u)
user_dir=1
;;
esac
done
# Make sure only root can run our script
if [[ ! $user_dir && "$(id -u)" != "0" ]]; then
echo ""
echo "Error: This script must be run as root in order to copy templates to ${BASE_TEMPLATE_DIR}" 1>&2
echo ""
echo "Try running it with 'sudo', or with '-u' to install it only you:" 1>&2
echo " sudo $0" 1>&2
echo "or:" 1>&2
echo " $0 -u" 1>&2
exit 1
fi
copy_files(){
rsync -r --exclude=.svn "$1" "$2"
}
check_dst_dir(){
if [[ -d $DST_DIR ]]; then
if [[ $force ]]; then
echo "removing old libraries: ${DST_DIR}"
rm -rf "${DST_DIR}"
else
echo "templates already installed. To force a re-install use the '-f' parameter"
exit 1
fi
fi
echo ...creating destination directory: $DST_DIR
mkdir -p "$DST_DIR"
}
copy_base_mac_files(){
echo ...copying cocos2dx files
copy_files cocos2dx "$LIBS_DIR"
echo ...copying CocosDenshion files
copy_files CocosDenshion "$LIBS_DIR"
}
copy_base_files(){
echo ...copying cocos2dx files
copy_files cocos2dx "$LIBS_DIR"
echo ...copying CocosDenshion files
copy_files CocosDenshion "$LIBS_DIR"
}
print_template_banner(){
echo ''
echo ''
echo ''
echo "$1"
echo '----------------------------------------------------'
echo ''
}
# copies project-based templates
copy_project_templates(){
if [[ $user_dir ]]; then
TEMPLATE_DIR="${BASE_TEMPLATE_USER_DIR}/Project Templates/${COCOS2D_VER}/"
else
TEMPLATE_DIR="${BASE_TEMPLATE_DIR}/Project Templates/${COCOS2D_VER}/"
fi
if [[ ! -d "$TEMPLATE_DIR" ]]; then
echo '...creating cocos2d template directory'
echo ''
mkdir -p "$TEMPLATE_DIR"
fi
print_template_banner "Installing cocos2d-x iOS template"
DST_DIR="$TEMPLATE_DIR""cocos2d-x Application/"
LIBS_DIR="$DST_DIR"libs
check_dst_dir
echo ...copying template files
copy_files template/xcode3/cocos2d-x_app/ "$DST_DIR"
copy_base_files
echo done!
print_template_banner "Installing cocos2d-x iOS + box2d template"
DST_DIR="$TEMPLATE_DIR""cocos2d-x Box2d Application/"
LIBS_DIR="$DST_DIR"libs
check_dst_dir
echo ...copying template files
copy_files template/xcode3/cocos2d-x_box2d_app/ "$DST_DIR"
copy_base_files
echo ...coping Box2D files
copy_files Box2D "$LIBS_DIR"
echo done!
print_template_banner "Installing cocos2d-x iOS + chipmunk template"
DST_DIR="$TEMPLATE_DIR""cocos2d-x chipmunk Application/"
LIBS_DIR="$DST_DIR"libs
check_dst_dir
echo ...copying template files
copy_files template/xcode3/cocos2d-x_chipmunk_app/ "$DST_DIR"
copy_base_files
echo ...coping chipmunk files
copy_files chipmunk "$LIBS_DIR"
echo done!
}
copy_file_templates(){
if [[ $user_dir ]]; then
TEMPLATE_DIR="${BASE_TEMPLATE_USER_DIR}/File Templates/${COCOS2D_VER}/"
else
TEMPLATE_DIR="${BASE_TEMPLATE_DIR}/File Templates/${COCOS2D_VER}/"
fi
echo ...copying file templates
DST_DIR="$TEMPLATE_DIR"
check_dst_dir
if [[ ! -d "$TEMPLATE_DIR" ]]; then
echo '...creating cocos2d template directory'
echo ''
mkdir -p "$TEMPLATE_DIR"
fi
print_template_banner "Installing CCNode file templates..."
copy_files "templates/file-templates/CCNode class" "$DST_DIR"
echo done!
}
copy_project_templates

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -0,0 +1,110 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "AppDelegate.h"
#include "cocos2d.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::initInstance()
{
bool bRet = false;
do
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView * pMainWnd = new CCEGLView();
CC_BREAK_IF(! pMainWnd
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 320, 480));
#endif // CC_PLATFORM_WIN32
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
#endif // CC_PLATFORM_IOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// android does not do anything
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView* pMainWnd = new CCEGLView(this);
CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480));
#ifndef _TRANZDA_VM_
// on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file
cocos2d::CCFileUtils::setResource("HelloWorld.zip");
#endif
#endif // CC_PLATFORM_WOPHONE
bRet = true;
} while (0);
return bRet;
}
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);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
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()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -0,0 +1,51 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCApplication.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 for initialize OpenGL instance, set source path, etc...
*/
virtual bool initInstance();
/**
@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_

View File

@ -0,0 +1,84 @@
#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
using namespace cocos2d;
using namespace CocosDenshion;
CCScene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::node();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::node();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Thonburi", 34);
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
// position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
// add the label as a child to this layer
this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) );
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
return true;
}
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}

View File

@ -0,0 +1,22 @@
#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
class HelloWorld : public cocos2d::CCLayer
{
public:
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// there's no 'id' in cpp, so we recommand to return the exactly class pointer
static cocos2d::CCScene* scene();
// a selector callback
virtual void menuCloseCallback(CCObject* pSender);
// implement the "static node()" method manually
LAYER_NODE_FUNC(HelloWorld);
};
#endif // __HELLOWORLD_SCENE_H__

View File

@ -0,0 +1,8 @@
//
// Prefix header for all source files of the '___PROJECTNAME___' target in the '___PROJECTNAME___' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif

Binary file not shown.

View File

@ -0,0 +1,14 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
@interface ___PROJECTNAMEASIDENTIFIER___AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window;
}
@end

View File

@ -0,0 +1,99 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.mm
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppController.h"
#import "cocos2d.h"
#import "EAGLView.h"
#import "AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController
#pragma mark -
#pragma mark Application lifecycle
// cocos2d application instance
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH_COMPONENT16_OES
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0 ];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication().run();
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
cocos2d::CCDirector::sharedDirector()->pause();
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
cocos2d::CCDirector::sharedDirector()->resume();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
cocos2d::CCDirector::sharedDirector()->stopAnimation();
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
cocos2d::CCDirector::sharedDirector()->startAnimation();
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -0,0 +1,16 @@
//
// main.m
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppController");
[pool release];
return retVal;
}

View File

@ -0,0 +1,110 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "AppDelegate.h"
#include "cocos2d.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::initInstance()
{
bool bRet = false;
do
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView * pMainWnd = new CCEGLView();
CC_BREAK_IF(! pMainWnd
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 320, 480));
#endif // CC_PLATFORM_WIN32
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
#endif // CC_PLATFORM_IOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// android does not do anything
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView* pMainWnd = new CCEGLView(this);
CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480));
#ifndef _TRANZDA_VM_
// on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file
cocos2d::CCFileUtils::setResource("HelloWorld.zip");
#endif
#endif // CC_PLATFORM_WOPHONE
bRet = true;
} while (0);
return bRet;
}
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);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
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()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -0,0 +1,51 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCApplication.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 for initialize OpenGL instance, set source path, etc...
*/
virtual bool initInstance();
/**
@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_

View File

@ -0,0 +1,217 @@
//
// HelloWorldScene.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
using namespace cocos2d;
using namespace CocosDenshion;
#define PTM_RATIO 32
enum
{
kTagTileMap = 1,
kTagSpriteManager = 1,
kTagAnimation1 = 1,
};
HelloWorld::HelloWorld()
{
setIsTouchEnabled( true );
setIsAccelerometerEnabled( true );
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
//UXLOG(L"Screen width %0.2f screen height %0.2f",screenSize.width,screenSize.height);
// Define the gravity vector.
b2Vec2 gravity;
gravity.Set(0.0f, -10.0f);
// Do we want to let bodies sleep?
bool doSleep = true;
// Construct a world object, which will hold and simulate the rigid bodies.
world = new b2World(gravity, doSleep);
world->SetContinuousPhysics(true);
/*
m_debugDraw = new GLESDebugDraw( PTM_RATIO );
world->SetDebugDraw(m_debugDraw);
uint flags = 0;
flags += b2DebugDraw::e_shapeBit;
flags += b2DebugDraw::e_jointBit;
flags += b2DebugDraw::e_aabbBit;
flags += b2DebugDraw::e_pairBit;
flags += b2DebugDraw::e_centerOfMassBit;
m_debugDraw->SetFlags(flags);
*/
// Define the ground body.
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0, 0); // bottom-left corner
// Call the body factory which allocates memory for the ground body
// from a pool and creates the ground box shape (also from a pool).
// The body is also added to the world.
b2Body* groundBody = world->CreateBody(&groundBodyDef);
// Define the ground box shape.
b2PolygonShape groundBox;
// bottom
groundBox.SetAsEdge(b2Vec2(0,0), b2Vec2(screenSize.width/PTM_RATIO,0));
groundBody->CreateFixture(&groundBox, 0);
// top
groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO));
groundBody->CreateFixture(&groundBox, 0);
// left
groundBox.SetAsEdge(b2Vec2(0,screenSize.height/PTM_RATIO), b2Vec2(0,0));
groundBody->CreateFixture(&groundBox, 0);
// right
groundBox.SetAsEdge(b2Vec2(screenSize.width/PTM_RATIO,screenSize.height/PTM_RATIO), b2Vec2(screenSize.width/PTM_RATIO,0));
groundBody->CreateFixture(&groundBox, 0);
//Set up sprite
CCSpriteBatchNode *mgr = CCSpriteBatchNode::spriteSheetWithFile("blocks.png", 150);
addChild(mgr, 0, kTagSpriteManager);
addNewSpriteWithCoords( CCPointMake(screenSize.width/2, screenSize.height/2) );
CCLabelTTF *label = CCLabelTTF::labelWithString("Tap screen", "Marker Felt", 32);
addChild(label, 0);
label->setColor( ccc3(0,0,255) );
label->setPosition( CCPointMake( screenSize.width/2, screenSize.height-50) );
schedule( schedule_selector(HelloWorld::tick) );
}
HelloWorld::~HelloWorld()
{
delete world;
world = NULL;
//delete m_debugDraw;
}
void HelloWorld::draw()
{
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// Needed states: GL_VERTEX_ARRAY,
// Unneeded states: GL_TEXTURE_2D, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
//world->DrawDebugData();
// restore default GL states
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
void HelloWorld::addNewSpriteWithCoords(CCPoint p)
{
//UXLOG(L"Add sprite %0.2f x %02.f",p.x,p.y);
CCSpriteBatchNode* sheet = (CCSpriteBatchNode*)getChildByTag(kTagSpriteManager);
//We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is
//just randomly picking one of the images
int idx = (CCRANDOM_0_1() > .5 ? 0:1);
int idy = (CCRANDOM_0_1() > .5 ? 0:1);
CCSprite *sprite = sheet->createSpriteWithRect( CCRectMake(32 * idx,32 * idy,32,32));
sheet->addChild(sprite);
sprite->setPosition( CCPointMake( p.x, p.y) );
// Define the dynamic body.
//Set up a 1m squared box in the physics world
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO);
bodyDef.userData = sprite;
b2Body *body = world->CreateBody(&bodyDef);
// Define another box shape for our dynamic body.
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box
// Define the dynamic body fixture.
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.3f;
body->CreateFixture(&fixtureDef);
}
void HelloWorld::tick(ccTime dt)
{
//It is recommended that a fixed time step is used with Box2D for stability
//of the simulation, however, we are using a variable time step here.
//You need to make an informed choice, the following URL is useful
//http://gafferongames.com/game-physics/fix-your-timestep/
int velocityIterations = 8;
int positionIterations = 1;
// Instruct the world to perform a single step of simulation. It is
// generally best to keep the time step and iterations fixed.
world->Step(dt, velocityIterations, positionIterations);
//Iterate over the bodies in the physics world
for (b2Body* b = world->GetBodyList(); b; b = b->GetNext())
{
if (b->GetUserData() != NULL) {
//Synchronize the AtlasSprites position and rotation with the corresponding body
CCSprite* myActor = (CCSprite*)b->GetUserData();
myActor->setPosition( CCPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO) );
myActor->setRotation( -1 * CC_RADIANS_TO_DEGREES(b->GetAngle()) );
}
}
}
void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
{
//Add a new body/atlas sprite at the touched location
CCSetIterator it;
CCTouch* touch;
for( it = touches->begin(); it != touches->end(); it++)
{
touch = (CCTouch*)(*it);
if(!touch)
break;
CCPoint location = touch->locationInView(touch->view());
location = CCDirector::sharedDirector()->convertToGL(location);
addNewSpriteWithCoords( location );
}
}
CCScene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::node();
// add layer as a child to scene
CCLayer* layer = new HelloWorld();
scene->addChild(layer);
layer->release();
return scene;
}

View File

@ -0,0 +1,33 @@
//
// HelloWorldScene.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef __HELLO_WORLD_H__
#define __HELLO_WORLD_H__
// When you import this file, you import all the cocos2d classes
#include "cocos2d.h"
#include "Box2D.h"
class HelloWorld : public cocos2d::CCLayer {
public:
~HelloWorld();
HelloWorld();
// returns a Scene that contains the HelloWorld as the only child
static cocos2d::CCScene* scene();
// adds a new sprite at a given coordinate
void addNewSpriteWithCoords(cocos2d::CCPoint p);
virtual void draw();
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event);
void tick(cocos2d::ccTime dt);
private:
b2World* world;
};
#endif // __HELLO_WORLD_H__

View File

@ -0,0 +1,8 @@
//
// Prefix header for all source files of the '___PROJECTNAME___' target in the '___PROJECTNAME___' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif

Binary file not shown.

View File

@ -0,0 +1,14 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
@interface ___PROJECTNAMEASIDENTIFIER___AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window;
}
@end

View File

@ -0,0 +1,98 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.mm
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppController.h"
#import "cocos2d.h"
#import "EAGLView.h"
#import "AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController
#pragma mark -
#pragma mark Application lifecycle
// cocos2d application instance
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH_COMPONENT16_OES
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples:0 ];
[window addSubview: __glView];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication().run();
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
cocos2d::CCDirector::sharedDirector()->pause();
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
cocos2d::CCDirector::sharedDirector()->resume();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
cocos2d::CCDirector::sharedDirector()->stopAnimation();
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
cocos2d::CCDirector::sharedDirector()->startAnimation();
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -0,0 +1,16 @@
//
// main.m
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppController");
[pool release];
return retVal;
}

View File

@ -0,0 +1,110 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "AppDelegate.h"
#include "cocos2d.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::initInstance()
{
bool bRet = false;
do
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView * pMainWnd = new CCEGLView();
CC_BREAK_IF(! pMainWnd
|| ! pMainWnd->Create(TEXT("cocos2d: Hello World"), 320, 480));
#endif // CC_PLATFORM_WIN32
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
// OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here.
#endif // CC_PLATFORM_IOS
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// android does not do anything
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WOPHONE)
// Initialize OpenGLView instance, that release by CCDirector when application terminate.
// The HelloWorld is designed as HVGA.
CCEGLView* pMainWnd = new CCEGLView(this);
CC_BREAK_IF(! pMainWnd || ! pMainWnd->Create(320,480));
#ifndef _TRANZDA_VM_
// on wophone emulator, we copy resources files to Work7/TG3/APP/ folder instead of zip file
cocos2d::CCFileUtils::setResource("HelloWorld.zip");
#endif
#endif // CC_PLATFORM_WOPHONE
bRet = true;
} while (0);
return bRet;
}
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);
// sets landscape mode
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayFPS(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
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()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -0,0 +1,51 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCApplication.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 for initialize OpenGL instance, set source path, etc...
*/
virtual bool initInstance();
/**
@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_

View File

@ -0,0 +1,189 @@
//
// HelloWorldScene.cpp
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
using namespace cocos2d;
using namespace CocosDenshion;
enum {
kTagBatchNode = 1,
};
static void
eachShape(void *ptr, void* unused)
{
cpShape *shape = (cpShape*) ptr;
CCSprite *sprite = (CCSprite*)shape->data;
if( sprite )
{
cpBody *body = shape->body;
// TIP: cocos2d and chipmunk uses the same struct to store it's position
// chipmunk uses: cpVect, and cocos2d uses CGPoint but in reality the are the same
// since v0.7.1 you can mix them if you want.
sprite->setPosition(CCPointMake(body->p.x, body->p.y));
sprite->setRotation((float) CC_RADIANS_TO_DEGREES( -body->a ));
}
}
HelloWorld::HelloWorld()
{
}
HelloWorld::~HelloWorld()
{
}
CCScene* HelloWorld::scene()
{
// 'scene' is an autorelease object.
CCScene *scene = CCScene::node();
// 'layer' is an autorelease object.
HelloWorld *layer = HelloWorld::node();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
void HelloWorld::addNewSpriteX(float x, float y)
{
int posx, posy;
CCSpriteBatchNode *batch = (CCSpriteBatchNode*) getChildByTag(kTagBatchNode);
posx = (CCRANDOM_0_1() * 200);
posy = (CCRANDOM_0_1() * 200);
posx = (posx % 4) * 85;
posy = (posy % 3) * 121;
CCSprite *sprite = CCSprite::spriteWithBatchNode(batch, CCRectMake(posx, posy, 85, 121));
batch->addChild(sprite);
sprite->setPosition(ccp(x, y));
int num = 4;
cpVect verts[] = {
cpv(-24,-54),
cpv(-24, 54),
cpv( 24, 54),
cpv( 24,-54),
};
cpBody *body = cpBodyNew(1.0f, cpMomentForPoly(1.0f, num, verts, cpv(0, 0)));
// TIP:
// since v0.7.1 you can assign CGPoint to chipmunk instead of cpVect.
// cpVect == CGPoint
body->p = cpv(x, y);
cpSpaceAddBody(space, body);
cpShape* shape = cpPolyShapeNew(body, num, verts, cpv(0, 0));
shape->e = 0.5f; shape->u = 0.5f;
shape->data = sprite;
cpSpaceAddShape(space, shape);
}
bool HelloWorld::init()
{
bool ret = false;
if (ret = CCLayer::init())
{
setIsTouchEnabled(true);
CCSize wins = CCDirector::sharedDirector()->getWinSize();
cpInitChipmunk();
cpBody *staticBody = cpBodyNew(INFINITY, INFINITY);
space = cpSpaceNew();
cpSpaceResizeStaticHash(space, 400.0f, 40);
cpSpaceResizeActiveHash(space, 100, 600);
space->gravity = cpv(0, 0);
space->elasticIterations = space->iterations;
cpShape *shape;
// bottom
shape = cpSegmentShapeNew(staticBody, cpv(0,0), cpv(wins.width,0), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
// top
shape = cpSegmentShapeNew(staticBody, cpv(0,wins.height), cpv(wins.width,wins.height), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
// left
shape = cpSegmentShapeNew(staticBody, cpv(0,0), cpv(0,wins.height), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
// right
shape = cpSegmentShapeNew(staticBody, cpv(wins.width,0), cpv(wins.width,wins.height), 0.0f);
shape->e = 1.0f; shape->u = 1.0f;
cpSpaceAddStaticShape(space, shape);
CCSpriteBatchNode *batch = CCSpriteBatchNode::batchNodeWithFile("grossini_dance_atlas.png", 100);
addChild(batch, 0, kTagBatchNode);
addNewSpriteX(200, 200);
schedule(schedule_selector(HelloWorld::step));
}
return ret;
}
void HelloWorld::onEnter()
{
CCLayer::onEnter();
}
void HelloWorld::step(ccTime delta)
{
int steps = 2;
CGFloat dt = delta/(CGFloat)steps;
for(int i=0; i<steps; i++)
{
cpSpaceStep(space, dt);
}
cpSpaceHashEach(space->activeShapes, &eachShape, NULL);
cpSpaceHashEach(space->staticShapes, &eachShape, NULL);
}
void HelloWorld::ccTouchesEnded(CCSet *touches, CCEvent *event)
{
CCSetIterator it;
CCTouch *touch;
for (it = touches->begin(); it != touches->end(); it++) {
touch = (CCTouch*)(*it);
if (! touch) {
break;
}
CCPoint location = touch->locationInView(touch->view());
location = CCDirector::sharedDirector()->convertToGL(location);
addNewSpriteX(location.x, location.y);
}
}

View File

@ -0,0 +1,36 @@
//
// HelloWorldScene.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#ifndef __HELLOW_WORLD_H__
#define __HELLOW_WORLD_H__
#include "cocos2d.h"
// include Chipmunk headers
#include "chipmunk.h"
// HelloWorld Layer
class HelloWorld : public cocos2d::CCLayer {
public:
HelloWorld();
~HelloWorld();
static cocos2d::CCScene* scene();
void step(cocos2d::ccTime dt);
void addNewSpriteX(float x, float y);
virtual void onEnter();
virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent *event);
LAYER_NODE_FUNC(HelloWorld);
private:
bool init();
cpSpace *space;
};
#endif // __HELLOW_WORLD_H__

View File

@ -0,0 +1,8 @@
//
// Prefix header for all source files of the '___PROJECTNAME___' target in the '___PROJECTNAME___' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More