Merge branch 'gles20' of github.com:cocos2d/cocos2d-x into gles20

This commit is contained in:
Ed Bartley 2012-09-18 18:42:41 -04:00
commit 925c21cdde
326 changed files with 3251 additions and 2459 deletions

View File

@ -58,7 +58,7 @@ using the camera.
- It doesn't work on batched nodes like CCSprite objects when they are parented to a CCSpriteBatchNode object.
- It is recommended to use it ONLY if you are going to create 3D effects. For 2D effecs, use the action CCFollow or position/scale/rotate.
- It is recommended to use it ONLY if you are going to create 3D effects. For 2D effects, use the action CCFollow or position/scale/rotate.
*/
class CC_DLL CCCamera : public CCObject

View File

@ -70,7 +70,7 @@ using namespace std;
unsigned int g_uNumberOfDraws = 0;
NS_CC_BEGIN
// XXX it shoul be a Director ivar. Move it there once support for multiple directors is added
// XXX it should be a Director ivar. Move it there once support for multiple directors is added
// singleton stuff
static CCDisplayLinkDirector s_SharedDirector;
@ -136,7 +136,7 @@ bool CCDirector::init(void)
m_pobOpenGLView = NULL;
m_fContentScaleFactor = 1;
m_fContentScaleFactor = 1.0f;
m_bIsContentScaleSupported = false;
// scheduler
@ -200,7 +200,7 @@ void CCDirector::setGLDefaultValues(void)
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
// Draw the SCene
// Draw the Scene
void CCDirector::drawScene(void)
{
// calculate "global" dt
@ -290,16 +290,13 @@ void CCDirector::calculateDeltaTime(void)
*m_pLastUpdate = now;
}
// m_pobOpenGLView
void CCDirector::setOpenGLView(CCEGLView *pobOpenGLView)
{
CCAssert(pobOpenGLView, "opengl view should not be null");
if (m_pobOpenGLView != pobOpenGLView)
{
// because EAGLView is not kind of CCObject
// EAGLView is not a CCObject
delete m_pobOpenGLView; // [openGLView_ release]
m_pobOpenGLView = pobOpenGLView;
@ -591,6 +588,9 @@ void CCDirector::end()
void CCDirector::purgeDirector()
{
// cleanup scheduler
getScheduler()->unscheduleAllSelectors();
// don't release the event handlers
// They are needed in case the director is run again
m_pTouchDispatcher->removeAllDelegates();
@ -814,7 +814,7 @@ bool CCDirector::enableRetinaDisplay(bool enabled)
return true;
}
// Already diabled?
// Already disabled?
if (!enabled && m_fContentScaleFactor == 1)
{
return false;
@ -942,7 +942,7 @@ CCAccelerometer* CCDirector::getAccelerometer()
* implementation of DisplayLinkDirector
**************************************************/
// should we afford 4 types of director ??
// should we implement 4 types of director ??
// I think DisplayLinkDirector is enough
// so we now only support DisplayLinkDirector
void CCDisplayLinkDirector::startAnimation(void)

View File

@ -58,7 +58,7 @@ typedef enum {
/// it calls "updateProjection" on the projection delegate.
kCCDirectorProjectionCustom,
/// Detault projection is 3D projection
/// Default projection is 3D projection
kCCDirectorProjectionDefault = kCCDirectorProjection3D,
} ccDirectorProjection;
@ -83,7 +83,7 @@ and when to execute the Scenes.
- setting the OpenGL pixel format (default on is RGB565)
- setting the OpenGL buffer depth (default one is 0-bit)
- setting the projection (default one is 3D)
- setting the orientation (default one is Protrait)
- setting the orientation (default one is Portrait)
Since the CCDirector is a singleton, the standard way to use it is by calling:
_ CCDirector::sharedDirector()->methodName();

View File

@ -54,7 +54,7 @@ static void lazy_init( void )
if( ! s_bInitialized ) {
//
// Position and 1 color passed as a uniform (to similate glColor4ub )
// Position and 1 color passed as a uniform (to simulate glColor4ub )
//
s_pShader = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_Position_uColor);
@ -67,7 +67,7 @@ static void lazy_init( void )
}
}
// When back to foreground on android, we want to it to inilialize again
// When switching from backround to foreground on android, we want the params to be initialized again
void ccDrawInit()
{
s_bInitialized = false;

View File

@ -56,7 +56,7 @@ NS_CC_BEGIN
class CCPointArray;
/** initlialize context */
/** initialize context */
void CC_DLL ccDrawInit();
/** draws a point given x and y coordinate measured in points */
@ -78,12 +78,12 @@ void CC_DLL ccDrawRect( CCPoint origin, CCPoint destination );
*/
void CC_DLL ccDrawSolidRect( CCPoint origin, CCPoint destination, ccColor4F color );
/** draws a poligon given a pointer to CCPoint coordiantes and the number of vertices measured in points.
/** draws a polygon given a pointer to CCPoint coordinates and the number of vertices measured in points.
The polygon can be closed or open
*/
void CC_DLL ccDrawPoly( const CCPoint *vertices, unsigned int numOfVertices, bool closePolygon );
/** draws a solid polygon given a pointer to CGPoint coordiantes, the number of vertices measured in points, and a color.
/** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color.
*/
void CC_DLL ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color );

View File

@ -164,7 +164,7 @@ void CCTimer::update(float dt)
if (m_nScriptHandler)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nScriptHandler, m_fElapsed, NULL);
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(this, m_fElapsed);
}
m_fElapsed = 0;
}
@ -183,7 +183,7 @@ void CCTimer::update(float dt)
if (m_nScriptHandler)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nScriptHandler, m_fElapsed, NULL);
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(this, m_fElapsed);
}
m_fElapsed = m_fElapsed - m_fDelay;
@ -202,7 +202,7 @@ void CCTimer::update(float dt)
if (m_nScriptHandler)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nScriptHandler, m_fElapsed, NULL);
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(this, m_fElapsed);
}
m_fElapsed = 0;
@ -375,7 +375,7 @@ void CCScheduler::priorityIn(tListEntry **ppList, CCObject *pTarget, int nPriori
pListElement->next = pListElement->prev = NULL;
pListElement->markedForDeletion = false;
// empey list ?
// empty list ?
if (! *ppList)
{
DL_APPEND(*ppList, pListElement);
@ -610,14 +610,14 @@ void CCScheduler::unscheduleAllSelectorsForTarget(CCObject *pTarget)
unsigned int CCScheduler::scheduleScriptFunc(unsigned int nHandler, float fInterval, bool bPaused)
{
CCSchedulerScriptHandlerEntry* pEntry = CCSchedulerScriptHandlerEntry::entryWithHandler(nHandler, fInterval, bPaused);
CCSchedulerScriptHandlerEntry* pEntry = CCSchedulerScriptHandlerEntry::create(nHandler, fInterval, bPaused);
if (!m_pScriptHandlerEntries)
{
m_pScriptHandlerEntries = CCArray::createWithCapacity(20);
m_pScriptHandlerEntries->retain();
}
m_pScriptHandlerEntries->addObject(pEntry);
return pEntry->getEntryID();
return pEntry->getEntryId();
}
void CCScheduler::unscheduleScriptEntry(unsigned int uScheduleScriptEntryID)
@ -625,7 +625,7 @@ void CCScheduler::unscheduleScriptEntry(unsigned int uScheduleScriptEntryID)
for (int i = m_pScriptHandlerEntries->count() - 1; i >= 0; i--)
{
CCSchedulerScriptHandlerEntry* pEntry = static_cast<CCSchedulerScriptHandlerEntry*>(m_pScriptHandlerEntries->objectAtIndex(i));
if (pEntry->getEntryID() == uScheduleScriptEntryID)
if (pEntry->getEntryId() == uScheduleScriptEntryID)
{
pEntry->markedForDeletion();
break;
@ -763,7 +763,7 @@ void CCScheduler::update(float dt)
dt *= m_fTimeScale;
}
// Iterate all over the Updates selectors
// Iterate over all the Updates' selectors
tListEntry *pEntry, *pTmp;
// updates with priority < 0
@ -783,7 +783,7 @@ void CCScheduler::update(float dt)
CCScriptEngineProtocol* pEngine = CCScriptEngineManager::sharedManager()->getScriptEngine();
if (pEngine != NULL && kScriptTypeJavascript == pEngine->getScriptType())
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(1, dt, (CCNode *)pEntry->target);
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(NULL, dt, (CCNode *)pEntry->target);
}
pEntry->target->update(dt);
@ -799,7 +799,7 @@ void CCScheduler::update(float dt)
}
}
// Interate all over the custom selectors
// Iterate over all the custom selectors
for (tHashSelectorEntry *elt = m_pHashForSelectors; elt != NULL; )
{
m_pCurrentTarget = elt;
@ -838,7 +838,7 @@ void CCScheduler::update(float dt)
}
}
// Interate all over the script callbacks
// Iterate over all the script callbacks
if (m_pScriptHandlerEntries)
{
for (int i = m_pScriptHandlerEntries->count() - 1; i >= 0; i--)
@ -855,7 +855,7 @@ void CCScheduler::update(float dt)
}
}
// delete all updates that are morked for deletion
// delete all updates that are marked for deletion
// updates with priority < 0
DL_FOREACH_SAFE(m_pUpdatesNegList, pEntry, pTmp)
{

View File

@ -47,7 +47,7 @@ class CCSet;
//
// CCTimer
//
/** @brief Light weight timer */
/** @brief Light-weight timer */
class CC_DLL CCTimer : public CCObject
{
public:
@ -80,6 +80,8 @@ public:
/** Allocates a timer with a script callback function and an interval in seconds. */
static CCTimer* timerWithScriptHandler(int nHandler, float fSeconds);
inline int getScriptHandler() { return m_nScriptHandler; };
public:
SEL_SCHEDULE m_pfnSelector;
float m_fInterval;
@ -106,7 +108,7 @@ struct _hashUpdateEntry;
class CCArray;
/** @brief Scheduler is responsible of triggering the scheduled callbacks.
/** @brief Scheduler is responsible for triggering the scheduled callbacks.
You should not use NSTimer. Instead use this class.
There are 2 different types of callbacks (selectors):
@ -140,9 +142,9 @@ public:
/** The scheduled method will be called every 'interval' seconds.
If paused is YES, then it won't be called until it is resumed.
If 'interval' is 0, it will be called every frame, but if so, it recommened to use 'scheduleUpdateForTarget:' instead.
If 'interval' is 0, it will be called every frame, but if so, it's recommended to use 'scheduleUpdateForTarget:' instead.
If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
repeat let the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continiously
repeat let the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continuously
delay is the amount of time the action will wait before it'll start
@since v0.99.3, repeat and delay added in v1.1

View File

@ -234,7 +234,7 @@ public:
public:
/** creates the action with a set boundary,
It will work with no boundary if @param rect is equal to CCRectZero.
@deprecated: Please use create(CCNode*, const CCRect&) intead. This interface will be deprecated sooner or later.
@deprecated: Please use create(CCNode*, const CCRect&) instead. This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero);
/** creates the action with a set boundary,

View File

@ -26,7 +26,7 @@
* THE SOFTWARE.
*
*
* Orignal code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So
* Original code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So
*
* Adapted to cocos2d-x by Vit Valentin
*
@ -96,12 +96,12 @@ CCPointArray::CCPointArray() :m_pControlPoints(NULL){}
void CCPointArray::addControlPoint(CCPoint controlPoint)
{
// should create a new object of CCPoint
// because developer always use this function like this
// should create a new object: CCPoint
// because developers are accustomed to using
// addControlPoint(ccp(x, y))
// passing controlPoint is a temple object
// and CCArray::addObject() will retain the passing object, so it
// should be an object created in heap
// which assumes controlPoint is a temporary struct
// but CCArray::addObject() will retain the passed object, so temp
// should be an object created in the heap.
CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y);
m_pControlPoints->addObject(temp);
temp->release();
@ -109,12 +109,12 @@ void CCPointArray::addControlPoint(CCPoint controlPoint)
void CCPointArray::insertControlPoint(CCPoint &controlPoint, unsigned int index)
{
// should create a new object of CCPoint
// because developer always use this function like this
// should create a new object: CCPoint
// because developers are accustomed to using
// insertControlPoint(ccp(x, y))
// passing controlPoint is a temple object
// and CCArray::insertObject() will retain the passing object, so it
// should be an object created in heap
// which assumes controlPoint is a temporary struct
// but CCArray::insertObject() will retain the passed object, so temp
// should be an object created in the heap.
CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y);
m_pControlPoints->insertObject(temp, index);
temp->release();
@ -130,12 +130,12 @@ CCPoint CCPointArray::getControlPointAtIndex(unsigned int index)
void CCPointArray::replaceControlPoint(cocos2d::CCPoint &controlPoint, unsigned int index)
{
// should create a new object of CCPoint
// because developer always use this function like this
// should create a new object: CCPoint
// because developers are accustomed to using
// replaceControlPoint(ccp(x, y))
// passing controlPoint is a temple object
// and CCArray::insertObject() will retain the passing object, so it
// should be an object created in heap
// which assumes controlPoint is a temporary struct
// but CCArray::insertObject() will retain the passed object, so temp
// should be an object created in the heap.
CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y);
m_pControlPoints->replaceObjectAtIndex(index, temp);
temp->release();

View File

@ -26,7 +26,7 @@
* THE SOFTWARE.
*
*
* Orignal code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So
* Original code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So
*
* Adapted to cocos2d-x by Vit Valentin
*

View File

@ -320,7 +320,7 @@ protected:
/**
@brief Ease Elastic In action.
@warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
@warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
@since v0.8.2
@ingroup Actions
*/
@ -345,7 +345,7 @@ public:
/**
@brief Ease Elastic Out action.
@warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
@warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
@since v0.8.2
@ingroup Actions
*/
@ -371,7 +371,7 @@ public:
/**
@brief Ease Elastic InOut action.
@warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
@warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
@since v0.8.2
@ingroup Actions
*/
@ -440,7 +440,7 @@ public:
/**
@brief EaseBounceOut action.
@warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
@warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
@since v0.8.2
@ingroup Actions
*/
@ -462,7 +462,7 @@ public:
/**
@brief CCEaseBounceInOut action.
@warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
@warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
@since v0.8.2
@ingroup Actions
*/
@ -484,7 +484,7 @@ public:
/**
@brief CCEaseBackIn action.
@warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
@warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
@since v0.8.2
@ingroup Actions
*/
@ -506,7 +506,7 @@ public:
/**
@brief CCEaseBackOut action.
@warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
@warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
@since v0.8.2
@ingroup Actions
*/
@ -528,7 +528,7 @@ public:
/**
@brief CCEaseBackInOut action.
@warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action.
@warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action.
@since v0.8.2
@ingroup Actions
*/

View File

@ -435,7 +435,7 @@ void CCCallFunc::execute() {
(m_pSelectorTarget->*m_pCallFunc)();
}
if (m_nScriptHandler) {
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionByHandler(m_nScriptHandler);
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeCallFuncActionEvent(this);
}
}
@ -447,7 +447,7 @@ void CCCallFuncN::execute() {
(m_pSelectorTarget->*m_pCallFuncN)(m_pTarget);
}
if (m_nScriptHandler) {
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionWithCCObject(m_nScriptHandler, m_pTarget, "CCNode");
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeCallFuncActionEvent(this, m_pTarget);
}
}

View File

@ -263,7 +263,8 @@ public:
m_pSelectorTarget = pSel;
}
}
inline int getScriptHandler() { return m_nScriptHandler; };
protected:
/** Target that will be called */
CCObject* m_pSelectorTarget;

View File

@ -384,7 +384,7 @@ bool CCRepeat::initWithAction(CCFiniteTimeAction *pAction, unsigned int times)
pAction->retain();
m_bActionInstant = dynamic_cast<CCActionInstant*>(pAction) ? true : false;
//a instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action
//an instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action
if (m_bActionInstant)
{
m_uTimes -=1;
@ -463,7 +463,7 @@ void CCRepeat::update(float dt)
m_uTotal++;
}
// don't set a instantaction back or update it, it has no use because it has no duration
// don't set an instant action back or update it, it has no use because it has no duration
if (!m_bActionInstant)
{
if (m_uTotal == m_uTimes)

View File

@ -116,7 +116,7 @@ public:
@deprecated: This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...);
/** helper contructor to create an array of sequenceable actions given an array
/** helper constructor to create an array of sequenceable actions given an array
@deprecated: This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions);
@ -127,7 +127,7 @@ public:
/** helper constructor to create an array of sequenceable actions */
static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...);
/** helper contructor to create an array of sequenceable actions given an array */
/** helper constructor to create an array of sequenceable actions given an array */
static CCFiniteTimeAction* create(CCArray *arrayOfActions);
/** creates the action */
static CCSequence* createWithTwoActions(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo);
@ -257,7 +257,7 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...);
/** helper contructor to create an array of spawned actions given an array
/** helper constructor to create an array of spawned actions given an array
@deprecated: This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions);
@ -270,7 +270,7 @@ public:
/** helper constructor to create an array of spawned actions */
static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...);
/** helper contructor to create an array of spawned actions given an array */
/** helper constructor to create an array of spawned actions given an array */
static CCFiniteTimeAction* create(CCArray *arrayOfActions);
/** creates the Spawn action */

View File

@ -96,7 +96,7 @@ void CCPageTurn3D::update(float time)
p.y = ( R + ay - ( r * (1 - cosBeta) * sinTheta));
// We scale z here to avoid the animation being
// too much bigger than the screen due to perspectve transform
// too much bigger than the screen due to perspective transform
p.z = (r * ( 1 - cosBeta ) * cosTheta) / 7;// "100" didn't work for
// Stop z coord from dropping beneath underlying page in a transition

View File

@ -50,7 +50,7 @@ public:
[target runAction:modifyWidth];
Another example: CCScaleTo action could be rewriten using CCPropertyAction:
Another example: CCScaleTo action could be rewritten using CCPropertyAction:
// scaleA and scaleB are equivalents
id scaleA = [CCScaleTo actionWithDuration:2 scale:3];

View File

@ -130,7 +130,7 @@ void CCAtlasNode::calculateMaxItems()
void CCAtlasNode::updateAtlasValues()
{
CCAssert(false, "CCAtlasNode:Abstract updateAtlasValue not overriden");
CCAssert(false, "CCAtlasNode:Abstract updateAtlasValue not overridden");
}
// CCAtlasNode - draw

View File

@ -98,7 +98,7 @@ public:
bool initWithTileFile(const char* tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender);
/** updates the Atlas (indexed vertex array).
* Shall be overriden in subclasses
* Shall be overridden in subclasses
*/
virtual void updateAtlasValues();

View File

@ -171,7 +171,7 @@ void CCNode::setZOrder(int z)
}
}
/// ertexZ getter
/// vertexZ getter
float CCNode::getVertexZ()
{
return m_fVertexZ;
@ -491,7 +491,7 @@ CCNode* CCNode::getChildByTag(int aTag)
}
/* "add" logic MUST only be on this method
* If a class want's to extend the 'addChild' behaviour it only needs
* If a class want's to extend the 'addChild' behavior it only needs
* to override this method
*/
void CCNode::addChild(CCNode *child, int zOrder, int tag)
@ -681,7 +681,7 @@ void CCNode::sortAllChildren()
{
//CCAssert(0);
// override me
// Only use- this function to draw your staff.
// Only use- this function to draw your stuff.
// DON'T draw your stuff outside this method
}
@ -798,11 +798,10 @@ void CCNode::onEnter()
m_bIsRunning = true;
if ( (m_eScriptType == kScriptTypeLua && m_nScriptHandler != 0)
|| m_eScriptType == kScriptTypeJavascript )
if (m_eScriptType != kScriptTypeNone)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionWithIntegerData(m_nScriptHandler, kCCNodeOnEnter, this);
}
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnEnter);
}
}
void CCNode::onEnterTransitionDidFinish()
@ -811,7 +810,7 @@ void CCNode::onEnterTransitionDidFinish()
if (m_eScriptType == kScriptTypeJavascript)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionWithIntegerData(m_nScriptHandler, kCCNodeOnEnterTransitionDidFinish, this);
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnEnterTransitionDidFinish);
}
}
@ -821,7 +820,7 @@ void CCNode::onExitTransitionDidStart()
if (m_eScriptType == kScriptTypeJavascript)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionWithIntegerData(m_nScriptHandler, kCCNodeOnExitTransitionDidStart, this);
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnExitTransitionDidStart);
}
}
@ -831,10 +830,9 @@ void CCNode::onExit()
m_bIsRunning = false;
if ( (m_eScriptType == kScriptTypeLua && m_nScriptHandler != 0)
|| m_eScriptType == kScriptTypeJavascript )
if ( m_eScriptType != kScriptTypeNone)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionWithIntegerData(m_nScriptHandler, kCCNodeOnExit, this);
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnExit);
}
arrayMakeObjectsPerformSelector(m_pChildren, onExit, CCNode*);
@ -851,7 +849,7 @@ void CCNode::unregisterScriptHandler(void)
{
if (m_nScriptHandler)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeLuaHandler(m_nScriptHandler);
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(m_nScriptHandler);
LUALOG("[LUA] Remove CCNode event handler: %d", m_nScriptHandler);
m_nScriptHandler = 0;
}

View File

@ -25,8 +25,8 @@
THE SOFTWARE.
****************************************************************************/
#ifndef __PLATFOMR_CCNODE_H__
#define __PLATFOMR_CCNODE_H__
#ifndef __PLATFORM_CCNODE_H__
#define __PLATFORM_CCNODE_H__
#include "ccMacros.h"
#include "cocoa/CCAffineTransform.h"
@ -61,12 +61,11 @@ enum {
enum {
kCCNodeOnEnter,
kCCNodeOnExit,
kCCMenuItemActivated,
kCCNodeOnEnterTransitionDidFinish,
kCCNodeOnExitTransitionDidStart
};
/** @brief CCNode is the main element. Anything thats gets drawn or contains things that get drawn is a CCNode.
/** @brief CCNode is the main element. Anything that gets drawn or contains things that get drawn is a CCNode.
The most popular CCNodes are: CCScene, CCLayer, CCSprite, CCMenu.
The main features of a CCNode are:
@ -240,7 +239,7 @@ public:
/** A weak reference to the parent */
CC_PROPERTY(CCNode *, m_pParent, Parent)
// If ture, the Anchor Point will be (0,0) when you position the CCNode.
// If true, the Anchor Point will be (0,0) when you position the CCNode.
// Used by CCLayer and CCScene
bool m_bIgnoreAnchorPointForPosition;
bool isIgnoreAnchorPointForPosition();
@ -279,6 +278,8 @@ public:
*/
CC_PROPERTY(CCScheduler*, m_pScheduler, Scheduler);
inline int getScriptHandler() { return m_nScriptHandler; };
protected:
// transform
@ -324,7 +325,7 @@ public:
*/
static CCNode * create(void);
//scene managment
//scene management
/** callback that is called every time the CCNode enters the 'stage'.
If the CCNode enters the 'stage' with a transition, this callback is called when the transition starts.
@ -576,7 +577,7 @@ public:
*/
virtual CCAffineTransform parentToNodeTransform(void);
/** Retrusn the world affine transform matrix. The matrix is in Pixels.
/** Returns the world affine transform matrix. The matrix is in Pixels.
@since v0.7.1
*/
virtual CCAffineTransform nodeToWorldTransform(void);
@ -610,7 +611,7 @@ public:
*/
CCPoint convertTouchToNodeSpace(CCTouch * touch);
/** converts a CCTouch (world coordinates) into a local coordiante. This method is AR (Anchor Relative).
/** converts a CCTouch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
@since v0.7.1
*/
CCPoint convertTouchToNodeSpaceAR(CCTouch * touch);
@ -621,7 +622,7 @@ public:
NS_CC_END
#endif // __PLATFOMR_CCNODE_H__
#endif // __PLATFORM_CCNODE_H__

View File

@ -414,7 +414,7 @@ void CCArray::reverseObjects()
{
if (data->num > 1)
{
//floor it since in case of a oneven number the number of swaps stays the same
// floorf(), since in the case of an even number, the number of swaps stays the same
int count = (int) floorf(data->num/2.f);
unsigned int maxIndex = data->num - 1;

View File

@ -33,7 +33,7 @@ THE SOFTWARE.
*/
/** @def CCARRAY_FOREACH
A convience macro to iterate over a CCArray using. It is faster than the "fast enumeration" interface.
A convenience macro to iterate over a CCArray using. It is faster than the "fast enumeration" interface.
@since v0.99.4
*/
@ -139,7 +139,7 @@ public:
@brief Generate a CCArray pointer by file
@param pFileName The file name of *.plist file
@return The CCArray pointer generated from the file
@deprecated: Please use createWithContentsOfFile(const char*) intead. This interface will be deprecated sooner or later.
@deprecated: Please use createWithContentsOfFile(const char*) instead. This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithContentsOfFile(const char* pFileName);

View File

@ -264,7 +264,7 @@ void CCDictionary::removeAllObjects()
CCObject* CCDictionary::copyWithZone(CCZone* pZone)
{
CCAssert(pZone == NULL, "CCDirctionary should not be inherited.");
CCAssert(pZone == NULL, "CCDictionary should not be inherited.");
CCDictionary* pNewDict = new CCDictionary();
CCDictElement* pElement = NULL;

View File

@ -50,7 +50,7 @@ static inline void split(std::string src, const char* token, strArray& vect)
}
// first, judge whether the form of the string like this: {x,y}
// if the form is right,the string will be splited into the parameter strs;
// if the form is right,the string will be split into the parameter strs;
// or the parameter strs will be empty.
// if the form is right return true,else return false.
static bool splitWithForm(const char* pStr, strArray& strs)

View File

@ -44,7 +44,7 @@ CCObject::CCObject(void)
m_uID = ++uObjectCount;
m_nLuaID = 0;
// when the object is created, the refrence count of it is 1
// when the object is created, the reference count of it is 1
m_uReference = 1;
m_bManaged = false;
}
@ -61,14 +61,14 @@ CCObject::~CCObject(void)
// if the object is referenced by Lua engine, remove it
if (m_nLuaID)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeCCObjectByID(m_nLuaID);
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptObjectByCCObject(this);
}
else
{
CCScriptEngineProtocol* pEngine = CCScriptEngineManager::sharedManager()->getScriptEngine();
if (pEngine != NULL && pEngine->getScriptType() == kScriptTypeJavascript)
{
pEngine->removeJSObjectByCCObject(this);
pEngine->removeScriptObjectByCCObject(this);
}
}
}

View File

@ -53,7 +53,7 @@ public:
// Lua reference id
int m_nLuaID;
protected:
// count of refrence
// count of references
unsigned int m_uReference;
// is the object autoreleased
bool m_bManaged;

View File

@ -45,7 +45,7 @@ public:
virtual ~CCSet(void);
/**
*@brief Return a copy of the CCSet, it will copy all the elelments.
*@brief Return a copy of the CCSet, it will copy all the elements.
*/
CCSet* copy();
/**
@ -73,7 +73,7 @@ public:
*/
CCSetIterator begin();
/**
*@brief Return the iterator that points to the poisition after the last element.
*@brief Return the iterator that points to the position after the last element.
*/
CCSetIterator end();
/**

View File

@ -219,7 +219,7 @@ CCString* CCString::createWithFormat(const char* format, ...)
CCString* CCString::stringWithContentsOfFile(const char* pszFileName)
{
return CCString::create(pszFileName);
return CCString::createWithContentsOfFile(pszFileName);
}
CCString* CCString::createWithContentsOfFile(const char* pszFileName)

View File

@ -84,7 +84,7 @@ public:
virtual CCObject* copyWithZone(CCZone* pZone);
virtual bool isEqual(const CCObject* pObject);
/* static funcitons */
/* static functions */
/** create a string with c string
* @return A CCString pointer which is an autorelease object pointer,
* it means that you needn't do a release operation unless you retain it.
@ -120,7 +120,7 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE static CCString* stringWithContentsOfFile(const char* pszFileName);
/** create a string with std string, you can also pass a c string pointer because the default constuctor of std::string can access a c string pointer.
/** create a string with std string, you can also pass a c string pointer because the default constructor of std::string can access a c string pointer.
* @return A CCString pointer which is an autorelease object pointer,
* it means that you needn't do a release operation unless you retain it.
*/

View File

@ -53,7 +53,7 @@ void CCGrabber::grab(CCTexture2D *pTexture)
GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
{
CCAssert(0, "Frame Grabber: could not attach texture to frmaebuffer");
CCAssert(0, "Frame Grabber: could not attach texture to framebuffer");
}
glBindFramebuffer(GL_FRAMEBUFFER, m_oldFBO);

View File

@ -346,7 +346,7 @@ void CCGrid3D::blit(void)
// position
glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, m_pVertices);
// texCoods
// texCoords
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, m_pTexCoordinates);
glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, m_pIndices);
@ -551,7 +551,7 @@ void CCTiledGrid3D::blit(void)
// position
glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, m_pVertices);
// texCoods
// texCoords
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, m_pTexCoordinates);
glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, m_pIndices);

View File

@ -51,7 +51,7 @@ class CC_DLL CCGridBase : public CCObject
public:
virtual ~CCGridBase(void);
/** wheter or not the grid is active */
/** whether or not the grid is active */
inline bool isActive(void) { return m_bActive; }
void setActive(bool bActive);

10
cocos2dx/include/CCProtocols.h Executable file → Normal file
View File

@ -50,7 +50,7 @@ public:
virtual GLubyte getOpacity(void) = 0;
/** sets the opacity.
@warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed.
@warning If the the texture has premultiplied alpha then, the R, G and B channels will be modified.
Values goes from 0 to 255, where 255 means fully opaque.
*/
virtual void setOpacity(GLubyte opacity) = 0;
@ -59,7 +59,7 @@ public:
/** sets the premultipliedAlphaOpacity property.
If set to NO then opacity will be applied as: glColor(R,G,B,opacity);
If set to YES then oapcity will be applied as: glColor(opacity, opacity, opacity, opacity );
If set to YES then opacity will be applied as: glColor(opacity, opacity, opacity, opacity );
Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO
@since v0.8
*/
@ -72,7 +72,7 @@ public:
};
/**
@brief You can specify the blending fuction.
@brief You can specify the blending function.
@since v0.99.0
*/
class CC_DLL CCBlendProtocol
@ -91,7 +91,7 @@ public:
src=GL_ONE dst= GL_ONE_MINUS_SRC_ALPHA
else
src=GL_SRC_ALPHA dst= GL_ONE_MINUS_SRC_ALPHA
But you can change the blending funtion at any time.
But you can change the blending function at any time.
@since v0.8.0
*/
class CC_DLL CCTextureProtocol : public CCBlendProtocol
@ -119,7 +119,7 @@ public:
class CC_DLL CCDirectorDelegate
{
public:
/** Called by CCDirector when the porjection is updated, and "custom" projection is used
/** Called by CCDirector when the projection is updated, and "custom" projection is used
@since v0.99.5
*/
virtual void updateProjection(void) = 0;

18
cocos2dx/include/ccConfig.h Executable file → Normal file
View File

@ -36,14 +36,14 @@ THE SOFTWARE.
/** @def CC_ENABLE_GL_STATE_CACHE
If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches.
In order to use them, you have to use the following functions, insead of the the GL ones:
In order to use them, you have to use the following functions, instead of the the GL ones:
- ccGLUseProgram() instead of glUseProgram()
- ccGLDeleteProgram() instead of glDeleteProgram()
- ccGLBlendFunc() instead of glBlendFunc()
If this functionality is disabled, then ccGLUseProgram(), ccGLDeleteProgram(), ccGLBlendFunc() will call the GL ones, without using the cache.
It is recommened to enable whenever possible to improve speed.
It is recommended to enable whenever possible to improve speed.
If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on.
@since v2.0.0
@ -77,7 +77,7 @@ To enabled set it to 1. Disabled by default.
#endif
/** @def CC_DIRECTOR_FPS_INTERVAL
Senconds between FPS updates.
Seconds between FPS updates.
0.5 seconds, means that the FPS number will be updated every 0.5 seconds.
Having a bigger number means a more reliable FPS
@ -190,7 +190,7 @@ Only valid for cocos2d-mac. Not supported on cocos2d-ios.
/** @def CC_SPRITE_DEBUG_DRAW
If enabled, all subclasses of CCSprite will draw a bounding box
Useful for debugging purposes only. It is recommened to leave it disabled.
Useful for debugging purposes only. It is recommended to leave it disabled.
To enable set it to a value different than 0. Disabled by default:
0 -- disabled
@ -206,7 +206,7 @@ Only valid for cocos2d-mac. Not supported on cocos2d-ios.
/** @def CC_SPRITEBATCHNODE_DEBUG_DRAW
If enabled, all subclasses of CCSprite that are rendered using an CCSpriteBatchNode draw a bounding box.
Useful for debugging purposes only. It is recommened to leave it disabled.
Useful for debugging purposes only. It is recommended to leave it disabled.
To enable set it to a value different than 0. Disabled by default.
*/
@ -216,7 +216,7 @@ To enable set it to a value different than 0. Disabled by default.
/** @def CC_LABELBMFONT_DEBUG_DRAW
If enabled, all subclasses of CCLabelBMFont will draw a bounding box
Useful for debugging purposes only. It is recommened to leave it disabled.
Useful for debugging purposes only. It is recommended to leave it disabled.
To enable set it to a value different than 0. Disabled by default.
*/
@ -226,7 +226,7 @@ To enable set it to a value different than 0. Disabled by default.
/** @def CC_LABELATLAS_DEBUG_DRAW
If enabled, all subclasses of LabeltAtlas will draw a bounding box
Useful for debugging purposes only. It is recommened to leave it disabled.
Useful for debugging purposes only. It is recommended to leave it disabled.
To enable set it to a value different than 0. Disabled by default.
*/
@ -235,9 +235,9 @@ To enable set it to a value different than 0. Disabled by default.
#endif
/** @def CC_ENABLE_PROFILERS
If enabled, will activate various profilers withing cocos2d. This statistical data will be output to the console
If enabled, will activate various profilers within cocos2d. This statistical data will be output to the console
once per second showing average time (in milliseconds) required to execute the specific routine(s).
Useful for debugging purposes only. It is recommened to leave it disabled.
Useful for debugging purposes only. It is recommended to leave it disabled.
To enable set it to a value different than 0. Disabled by default.
*/

View File

@ -163,7 +163,7 @@ CCSizeMake( (__size_in_points__).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_p
void operator=(const TypeName&)
/**
Helper marcos which converts 4-byte little/big endian
Helper macros which converts 4-byte little/big endian
integral number to the machine native number representation
It should work same as apples CFSwapInt32LittleToHost(..)

6
cocos2dx/include/ccTypes.h Executable file → Normal file
View File

@ -254,7 +254,7 @@ typedef struct _ccV3F_C4B_T2F
// char __padding2__[4];
// tex coords (2F)
ccTex2F texCoords; // 8 byts
ccTex2F texCoords; // 8 bytes
} ccV3F_C4B_T2F;
//! 4 ccVertex2FTex2FColor4B Quad
@ -305,7 +305,7 @@ typedef struct _ccBlendFunc
GLenum dst;
} ccBlendFunc;
// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m
// XXX: If any of these enums are edited and/or reordered, update CCTexture2D.m
//! Vertical text alignment type
typedef enum
{
@ -314,7 +314,7 @@ typedef enum
kCCVerticalTextAlignmentBottom,
} CCVerticalTextAlignment;
// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m
// XXX: If any of these enums are edited and/or reordered, update CCTexture2D.m
//! Horizontal text alignment type
typedef enum
{

View File

@ -35,7 +35,7 @@ extern "C" {
#endif
/**
* A struture that represents an axis-aligned
* A structure that represents an axis-aligned
* bounding box.
*/
typedef struct kmAABB {

View File

@ -32,13 +32,13 @@
#endif
#endif // __arm__
// Matrixes are assumed to be stored in column major format according to OpenGL
// Matrices are assumed to be stored in column major format according to OpenGL
// specification.
// Multiplies two 4x4 matrices (a,b) outputing a 4x4 matrix (output)
// Multiplies two 4x4 matrices (a,b) outputting a 4x4 matrix (output)
void NEON_Matrix4Mul(const float* a, const float* b, float* output );
// Multiplies a 4x4 matrix (m) with a vector 4 (v), outputing a vector 4
// Multiplies a 4x4 matrix (m) with a vector 4 (v), outputting a vector 4
void NEON_Matrix4Vector4Mul(const float* m, const float* v, float* output);

View File

@ -62,7 +62,7 @@ CC_DLL kmPlane* const kmPlaneFromPoints(kmPlane* pOut, const struct kmVec3* p1,
CC_DLL kmVec3* const kmPlaneIntersectLine(struct kmVec3* pOut, const kmPlane* pP, const struct kmVec3* pV1, const struct kmVec3* pV2);
CC_DLL kmPlane* const kmPlaneNormalize(kmPlane* pOut, const kmPlane* pP);
CC_DLL kmPlane* const kmPlaneScale(kmPlane* pOut, const kmPlane* pP, kmScalar s);
CC_DLL const POINT_CLASSIFICATION kmPlaneClassifyPoint(const kmPlane* pIn, const kmVec3* pP); /** Classifys a point against a plane */
CC_DLL const POINT_CLASSIFICATION kmPlaneClassifyPoint(const kmPlane* pIn, const kmVec3* pP); /** Classifies a point against a plane */
#ifdef __cplusplus
}

View File

@ -100,7 +100,7 @@ void kmGLPushMatrix(void)
void kmGLPopMatrix(void)
{
assert(initialized && "Cannot Pop empty matrix stack");
//No need to lazy initialize, you shouldnt be popping first anyway!
//No need to lazy initialize, you shouldn't be popping first anyway!
km_mat4_stack_pop(current_stack, NULL);
}

View File

@ -55,7 +55,7 @@ const kmScalar kmMat3Determinant(const kmMat3* pIn)
m = | 1 4 7 | 1 4 |
| 2 5 8 | 2 5 |
now sum up the products of the diagonals going to the right (i.e. 0,4,8)
and substract the products of the other diagonals (i.e. 2,4,6)
and subtract the products of the other diagonals (i.e. 2,4,6)
*/
output = pIn->mat[0] * pIn->mat[4] * pIn->mat[8] + pIn->mat[1] * pIn->mat[5] * pIn->mat[6] + pIn->mat[2] * pIn->mat[3] * pIn->mat[7];

View File

@ -41,7 +41,7 @@ public:
// The back key clicked
virtual void keyBackClicked() {}
// The menu key clicked. only avialble on wophone & android
// The menu key clicked. only available on wophone & android
virtual void keyMenuClicked() {};
};

View File

@ -931,7 +931,7 @@ void CCLabelBMFont::createFontChars()
// Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on
fontChar->setColor(m_tColor);
// only apply opaccity if it is different than 255 )
// only apply opacity if it is different than 255 )
// to prevent modifying the color too (issue #610)
if( m_cOpacity != 255 )
{

View File

@ -93,7 +93,7 @@ typedef struct _BMFontPadding {
*/
class CC_DLL CCBMFontConfiguration : public CCObject
{
// XXX: Creating a public interface so that the bitmapFontArray[] is accesible
// XXX: Creating a public interface so that the bitmapFontArray[] is accessible
public://@public
// BMFont definitions
struct _FontDefHashElement* m_pFontDefDictionary;
@ -142,7 +142,7 @@ Features:
- scaled
- translated
- tinted
- chage the opacity
- change the opacity
- It can be used as part of a menu item.
- anchorPoint can be used to align the "label"
- Supports AngelCode text format
@ -202,11 +202,11 @@ public:
@since v0.99.3
*/
static void purgeCachedData();
/** creates a bitmap font altas with an initial string and the FNT file
/** creates a bitmap font atlas with an initial string and the FNT file
@deprecated: This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero);
/** creates a bitmap font altas with an initial string and the FNT file */
/** creates a bitmap font atlas with an initial string and the FNT file */
static CCLabelBMFont * create(const char *str, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset);
static CCLabelBMFont * create(const char *str, const char *fntFile, float width, CCTextAlignment alignment) {
@ -231,7 +231,7 @@ public:
static CCLabelBMFont * create();
bool init();
/** init a bitmap font altas with an initial string and the FNT file */
/** init a bitmap font atlas with an initial string and the FNT file */
bool initWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero);
/** updates the font chars based on the string to render */

View File

@ -227,7 +227,7 @@ void CCLabelTTF::setDimensions(const CCSize &dim)
{
m_tDimensions = dim;
// Force udpate
// Force update
if (m_string.size() > 0)
{
this->updateTexture();

View File

@ -123,7 +123,7 @@ void CCLayer::registerWithTouchDispatcher()
void CCLayer::registerScriptTouchHandler(int nHandler, bool bIsMultiTouches, int nPriority, bool bSwallowsTouches)
{
unregisterScriptTouchHandler();
m_pScriptHandlerEntry = CCTouchScriptHandlerEntry::entryWithHandler(nHandler, bIsMultiTouches, nPriority, bSwallowsTouches);
m_pScriptHandlerEntry = CCTouchScriptHandlerEntry::create(nHandler, bIsMultiTouches, nPriority, bSwallowsTouches);
m_pScriptHandlerEntry->retain();
}
@ -138,22 +138,12 @@ void CCLayer::unregisterScriptTouchHandler(void)
int CCLayer::excuteScriptTouchHandler(int nEventType, CCTouch *pTouch)
{
return CCScriptEngineManager::sharedManager()->getScriptEngine()->executeTouchEvent(m_pScriptHandlerEntry->getHandler(), nEventType, pTouch);
return CCScriptEngineManager::sharedManager()->getScriptEngine()->executeLayerTouchEvent(this, nEventType, pTouch);
}
int CCLayer::excuteScriptTouchHandler(int nEventType, CCSet *pTouches)
{
int ret = 0;
if (kScriptTypeJavascript == m_eScriptType)
{
ret = CCScriptEngineManager::sharedManager()->getScriptEngine()->executeTouchesEvent(1, nEventType, pTouches, this);
}
else if (kScriptTypeLua == m_eScriptType)
{
ret = CCScriptEngineManager::sharedManager()->getScriptEngine()->executeTouchesEvent(m_pScriptHandlerEntry->getHandler(), nEventType, pTouches, this);
}
return ret;
return CCScriptEngineManager::sharedManager()->getScriptEngine()->executeLayerTouchesEvent(this, nEventType, pTouches);
}
/// isTouchEnabled getter
@ -257,7 +247,7 @@ void CCLayer::onEnter()
pDirector->getAccelerometer()->setDelegate(this);
}
// add this layer to concern the kaypad msg
// add this layer to concern the keypad msg
if (m_bIsKeypadEnabled)
{
pDirector->getKeypadDispatcher()->addDelegate(this);
@ -279,7 +269,7 @@ void CCLayer::onExit()
pDirector->getAccelerometer()->setDelegate(NULL);
}
// remove this layer from the delegates who concern the kaypad msg
// remove this layer from the delegates who concern the keypad msg
if (m_bIsKeypadEnabled)
{
pDirector->getKeypadDispatcher()->removeDelegate(this);
@ -301,7 +291,7 @@ void CCLayer::onEnterTransitionDidFinish()
bool CCLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
if (kScriptTypeJavascript == m_eScriptType || (kScriptTypeLua == m_eScriptType && m_pScriptHandlerEntry))
if (kScriptTypeNone != m_eScriptType)
{
return excuteScriptTouchHandler(CCTOUCHBEGAN, pTouch) == 0 ? false : true;
}
@ -314,7 +304,7 @@ bool CCLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
void CCLayer::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent)
{
if (kScriptTypeJavascript == m_eScriptType || (kScriptTypeLua == m_eScriptType && m_pScriptHandlerEntry))
if (kScriptTypeNone != m_eScriptType)
{
excuteScriptTouchHandler(CCTOUCHMOVED, pTouch);
return;
@ -326,7 +316,7 @@ void CCLayer::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent)
void CCLayer::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
if (kScriptTypeJavascript == m_eScriptType || (kScriptTypeLua == m_eScriptType && m_pScriptHandlerEntry))
if (kScriptTypeNone != m_eScriptType)
{
excuteScriptTouchHandler(CCTOUCHENDED, pTouch);
return;
@ -338,7 +328,7 @@ void CCLayer::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
void CCLayer::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent)
{
if (kScriptTypeJavascript == m_eScriptType || (kScriptTypeLua == m_eScriptType && m_pScriptHandlerEntry))
if (kScriptTypeNone != m_eScriptType)
{
excuteScriptTouchHandler(CCTOUCHCANCELLED, pTouch);
return;
@ -350,7 +340,7 @@ void CCLayer::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent)
void CCLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
if (kScriptTypeJavascript == m_eScriptType || (kScriptTypeLua == m_eScriptType && m_pScriptHandlerEntry))
if (kScriptTypeNone != m_eScriptType)
{
excuteScriptTouchHandler(CCTOUCHBEGAN, pTouches);
return;
@ -362,7 +352,7 @@ void CCLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
void CCLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
if (kScriptTypeJavascript == m_eScriptType || (kScriptTypeLua == m_eScriptType && m_pScriptHandlerEntry))
if (kScriptTypeNone != m_eScriptType)
{
excuteScriptTouchHandler(CCTOUCHMOVED, pTouches);
return;
@ -374,7 +364,7 @@ void CCLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
void CCLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
if (kScriptTypeJavascript == m_eScriptType || (kScriptTypeLua == m_eScriptType && m_pScriptHandlerEntry))
if (kScriptTypeNone != m_eScriptType)
{
excuteScriptTouchHandler(CCTOUCHENDED, pTouches);
return;
@ -386,7 +376,7 @@ void CCLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
void CCLayer::ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent)
{
if (kScriptTypeJavascript == m_eScriptType || (kScriptTypeLua == m_eScriptType && m_pScriptHandlerEntry))
if (kScriptTypeNone != m_eScriptType)
{
excuteScriptTouchHandler(CCTOUCHCANCELLED, pTouches);
return;

View File

@ -119,6 +119,7 @@ public:
bool isKeypadEnabled();
void setKeypadEnabled(bool value);
inline CCTouchScriptHandlerEntry* getScriptHandlerEntry() { return m_pScriptHandlerEntry; };
protected:
bool m_bIsTouchEnabled;
bool m_bIsAccelerometerEnabled;
@ -292,7 +293,7 @@ public:
/**
* lua script can not init with undetermined number of variables
* so add these functinons to be used with lua.
* so add these functions to be used with lua.
@deprecated: This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCLayerMultiplex * layerWithLayer(CCLayer* layer);
@ -302,7 +303,7 @@ public:
/**
* lua script can not init with undetermined number of variables
* so add these functinons to be used with lua.
* so add these functions to be used with lua.
*/
static CCLayerMultiplex * createWithLayer(CCLayer* layer);

View File

@ -130,7 +130,7 @@ public:
/** called after the transition finishes */
void finish(void);
/** used by some transitions to hide the outter scene */
/** used by some transitions to hide the outer scene */
void hideOutShowIn(void);
protected:
@ -266,7 +266,7 @@ public:
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
/** returns the action that will be performed by the incoming and outgoing scene */
virtual CCActionInterval* action(void);
virtual void onEnter();
@ -290,7 +290,7 @@ public:
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
/** returns the action that will be performed by the incoming and outgoing scene */
virtual CCActionInterval* action(void);
TRANSITION_CREATE_FUNC(CCTransitionSlideInR);
@ -310,7 +310,7 @@ public:
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
/** returns the action that will be performed by the incoming and outgoing scene */
virtual CCActionInterval* action(void);
TRANSITION_CREATE_FUNC(CCTransitionSlideInB);
@ -330,7 +330,7 @@ public:
/** initializes the scenes */
virtual void initScenes(void);
/** returns the action that will be performed by the incomming and outgoing scene */
/** returns the action that will be performed by the incoming and outgoing scene */
virtual CCActionInterval* action(void);
TRANSITION_CREATE_FUNC(CCTransitionSlideInT);

View File

@ -59,7 +59,7 @@ protected:
/** CCTransitionRadialCCW transition.
A counter colock-wise radial transition to the next scene
A counter clock-wise radial transition to the next scene
*/
class CC_DLL CCTransitionProgressRadialCCW : public CCTransitionProgress
{
@ -73,7 +73,7 @@ protected:
/** CCTransitionRadialCW transition.
A counter colock-wise radial transition to the next scene
A counter clock-wise radial transition to the next scene
*/
class CC_DLL CCTransitionProgressRadialCW : public CCTransitionProgress
{
@ -86,7 +86,7 @@ protected:
};
/** CCTransitionProgressHorizontal transition.
A colock-wise radial transition to the next scene
A clock-wise radial transition to the next scene
*/
class CC_DLL CCTransitionProgressHorizontal : public CCTransitionProgress
{

View File

@ -51,7 +51,7 @@ enum {
*
* Features and Limitation:
* - You can add MenuItem objects in runtime using addChild:
* - But the only accecpted children are MenuItem objects
* - But the only accepted children are MenuItem objects
*/
class CC_DLL CCMenu : public CCLayer, public CCRGBAProtocol
{

View File

@ -80,7 +80,7 @@ bool CCMenuItem::initWithTarget(CCObject *rec, SEL_MenuHandler selector)
CCMenuItem::~CCMenuItem()
{
unregisterScriptHandler();
unregisterScriptTapHandler();
}
void CCMenuItem::selected()
@ -93,20 +93,20 @@ void CCMenuItem::unselected()
m_bIsSelected = false;
}
void CCMenuItem::registerScriptHandler(int nHandler)
void CCMenuItem::registerScriptTapHandler(int nHandler)
{
unregisterScriptHandler();
m_nScriptHandler = nHandler;
LUALOG("[LUA] Add CCMenuItem script handler: %d", m_nScriptHandler);
unregisterScriptTapHandler();
m_nScriptTapHandler = nHandler;
LUALOG("[LUA] Add CCMenuItem script handler: %d", m_nScriptTapHandler);
}
void CCMenuItem::unregisterScriptHandler(void)
void CCMenuItem::unregisterScriptTapHandler(void)
{
if (m_nScriptHandler)
if (m_nScriptTapHandler)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeLuaHandler(m_nScriptHandler);
LUALOG("[LUA] Remove CCMenuItem script handler: %d", m_nScriptHandler);
m_nScriptHandler = 0;
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(m_nScriptTapHandler);
LUALOG("[LUA] Remove CCMenuItem script handler: %d", m_nScriptTapHandler);
m_nScriptTapHandler = 0;
}
}
@ -119,13 +119,9 @@ void CCMenuItem::activate()
(m_pListener->*m_pfnSelector)(this);
}
if (kScriptTypeJavascript == m_eScriptType)
if (kScriptTypeNone != m_eScriptType)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionWithIntegerData(m_nScriptHandler, kCCMenuItemActivated, this);
}
else if( kScriptTypeLua == m_eScriptType && m_nScriptHandler != 0)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeFunctionWithIntegerData(m_nScriptHandler, getTag(), this);
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeMenuItemEvent(this);
}
}
}

View File

@ -65,7 +65,7 @@ public:
, m_bIsEnabled(false)
, m_pListener(NULL)
, m_pfnSelector(NULL)
, m_nScriptHandler(0)
, m_nScriptTapHandler(0)
{}
virtual ~CCMenuItem();
/** Creates a CCMenuItem with a target/selector
@ -88,9 +88,10 @@ public:
virtual void unselected();
/** Register menu handler script function */
virtual void registerScriptHandler(int nHandler);
virtual void unregisterScriptHandler(void);
virtual void registerScriptTapHandler(int nHandler);
virtual void unregisterScriptTapHandler(void);
int getScriptTapHandler() { return m_nScriptTapHandler; };
virtual bool isEnabled();
//@note: It's 'setIsEnable' in cocos2d-iphone.
virtual void setEnabled(bool value);
@ -98,10 +99,11 @@ public:
/** set the target/selector of the menu item*/
void setTarget(CCObject *rec, SEL_MenuHandler selector);
protected:
CCObject* m_pListener;
SEL_MenuHandler m_pfnSelector;
int m_nScriptHandler;
int m_nScriptTapHandler;
};
/** @brief An abstract class for "label" CCMenuItemLabel items
@ -127,14 +129,14 @@ public:
@deprecated: This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector);
/** creates a CCMenuItemLabel with a Label. Target and selector will be nill
/** creates a CCMenuItemLabel with a Label. Target and selector will be nil
@deprecated: This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCMenuItemLabel* itemWithLabel(CCNode *label);
/** creates a CCMenuItemLabel with a Label, target and selector */
static CCMenuItemLabel * create(CCNode*label, CCObject* target, SEL_MenuHandler selector);
/** creates a CCMenuItemLabel with a Label. Target and selector will be nill */
/** creates a CCMenuItemLabel with a Label. Target and selector will be nil */
static CCMenuItemLabel* create(CCNode *label);
/** initializes a CCMenuItemLabel with a Label, target and selector */
@ -371,7 +373,7 @@ public:
/** @brief A CCMenuItemToggle
A simple container class that "toggles" it's inner items
The inner itmes can be any MenuItem
The inner items can be any MenuItem
*/
class CC_DLL CCMenuItemToggle : public CCMenuItem, public CCRGBAProtocol
{

View File

@ -299,7 +299,7 @@ void CCMotionStreak::update(float delta)
m_pPointVertexes[m_uNuPoints] = m_tPositionR;
m_pPointState[m_uNuPoints] = 1.0f;
// Color asignation
// Color assignment
const unsigned int offset = m_uNuPoints*8;
*((ccColor3B*)(m_pColorPointer + offset)) = m_tColor;
*((ccColor3B*)(m_pColorPointer + offset+4)) = m_tColor;

View File

@ -87,7 +87,7 @@ public:
virtual void setOpacityModifyRGB(bool bValue);
virtual bool isOpacityModifyRGB(void);
/** When fast mode is enbled, new points are added faster but with lower precision */
/** When fast mode is enabled, new points are added faster but with lower precision */
inline bool isFastMode() { return m_bFastMode; }
inline void setFastMode(bool bFastMode) { m_bFastMode = bFastMode; }

View File

@ -118,7 +118,7 @@ void CCProgressTimer::setSprite(CCSprite *pSprite)
m_pSprite = pSprite;
setContentSize(m_pSprite->getContentSize());
// Everytime we set a new sprite, we free the current vertex data
// Every time we set a new sprite, we free the current vertex data
if (m_pVertexData)
{
CC_SAFE_FREE(m_pVertexData);

View File

@ -45,7 +45,7 @@ typedef enum {
} CCProgressTimerType;
/**
@brief CCProgresstimer is a subclass of CCNode.
@brief CCProgressTimer is a subclass of CCNode.
It renders the inner sprite according to the percentage.
The progress can be Radial, Horizontal or vertical.
@since v0.99.1

View File

@ -431,7 +431,7 @@ CCImage* CCRenderTexture::newCCImage()
const CCSize& s = m_pTexture->getContentSizeInPixels();
// to get the image size to save
// if the saving image domain exeeds the buffer texture domain,
// if the saving image domain exceeds the buffer texture domain,
// it should be cut
int nSavedBufferWidth = (int)s.width;
int nSavedBufferHeight = (int)s.height;
@ -458,7 +458,7 @@ CCImage* CCRenderTexture::newCCImage()
this->end();
// to get the actual texture data
// #640 the image read from rendertexture is upseted
// #640 the image read from rendertexture is dirty
for (int i = 0; i < nSavedBufferHeight; ++i)
{
memcpy(&pBuffer[i * nSavedBufferWidth * 4],

View File

@ -44,7 +44,7 @@ typedef enum eImageFormat
/**
@brief CCRenderTexture is a generic rendering target. To render things into it,
simply construct a render target, call begin on it, call visit on any cocos
scenes or objects to render them, and call end. For convienience, render texture
scenes or objects to render them, and call end. For convenience, render texture
adds a sprite as it's display child with the results, so you can simply add
the render texture to your scene and treat it like any other CocosNode.
There are also functions for saving the render texture to disk in PNG or JPG format.

View File

@ -135,7 +135,7 @@ void CCParticleBatchNode::visit()
// with the exception that it doesn't call visit on it's children
//
// The alternative is to have a void CCSprite#visit, but
// although this is less mantainable, is faster
// although this is less maintainable, is faster
//
if (!m_bIsVisible)
{
@ -185,7 +185,7 @@ void CCParticleBatchNode::addChild(CCNode * child, int zOrder, int tag)
setBlendFunc(pChild->getBlendFunc());
}
CCAssert( m_tBlendFunc.src == pChild->getBlendFunc().src && m_tBlendFunc.dst == pChild->getBlendFunc().dst, "Can't add a PaticleSystem that uses a differnt blending function");
CCAssert( m_tBlendFunc.src == pChild->getBlendFunc().src && m_tBlendFunc.dst == pChild->getBlendFunc().dst, "Can't add a PaticleSystem that uses a different blending function");
//no lazy sorting, so don't call super addChild, call helper instead
unsigned int pos = addChildHelper(pChild,zOrder,tag);
@ -388,7 +388,7 @@ void CCParticleBatchNode::removeChild(CCNode* child, bool cleanup)
// after memmove of data, empty the quads at the end of array
m_pTextureAtlas->fillWithEmptyQuadsFromIndex(m_pTextureAtlas->getTotalQuads(), pChild->getTotalParticles());
// paticle could be reused for self rendering
// particle could be reused for self rendering
pChild->setBatchNode(NULL);
updateAllAtlasIndexes();
@ -469,7 +469,7 @@ void CCParticleBatchNode::insertChild(CCParticleSystem* pSystem, unsigned int in
m_pTextureAtlas->moveQuadsFromIndex(index, index+pSystem->getTotalParticles());
}
// increase totalParticles here for new particles, update method of particlesystem will fill the quads
// increase totalParticles here for new particles, update method of particle-system will fill the quads
m_pTextureAtlas->increaseTotalQuadsWith(pSystem->getTotalParticles());
updateAllAtlasIndexes();

View File

@ -263,7 +263,7 @@ bool CCParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
modeA.radialAccel = -80;
modeA.radialAccelVar = 0;
// Gravity Mode: tagential
// Gravity Mode: tangential
modeA.tangentialAccel = 80;
modeA.tangentialAccelVar = 0;
@ -337,7 +337,7 @@ bool CCParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
modeA.radialAccel = -60;
modeA.radialAccelVar = 0;
// Gravity Mode: tagential
// Gravity Mode: tangential
modeA.tangentialAccel = 15;
modeA.tangentialAccelVar = 0;
@ -410,7 +410,7 @@ bool CCParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
modeA.radialAccel = 0;
modeA.radialAccelVar = 0;
// Gravity Mode: tagential
// Gravity Mode: tangential
modeA.tangentialAccel = 0;
modeA.tangentialAccelVar = 0;
@ -484,7 +484,7 @@ bool CCParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
modeA.radialAccel = -380;
modeA.radialAccelVar = 0;
// Gravity Mode: tagential
// Gravity Mode: tangential
modeA.tangentialAccel = 45;
modeA.tangentialAccelVar = 0;
@ -557,7 +557,7 @@ bool CCParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
modeA.radialAccel = 0;
modeA.radialAccelVar = 0;
// Gravity Mode: tagential
// Gravity Mode: tangential
modeA.tangentialAccel = 0;
modeA.tangentialAccelVar = 0;
@ -700,7 +700,7 @@ bool CCParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
modeA.radialAccel = 0;
modeA.radialAccelVar = 1;
// Gravity mode: tagential
// Gravity mode: tangential
modeA.tangentialAccel = 0;
modeA.tangentialAccelVar = 1;
@ -768,7 +768,7 @@ bool CCParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
modeA.radialAccel = 0;
modeA.radialAccelVar = 1;
// Gravity Mode: tagential
// Gravity Mode: tangential
modeA.tangentialAccel = 0;
modeA.tangentialAccelVar = 1;

View File

@ -37,7 +37,7 @@ THE SOFTWARE.
// http://particledesigner.71squared.com/
//
// IMPORTANT: Particle Designer is supported by cocos2d, but
// 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
// 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d,
// cocos2d uses a another approach, but the results are almost identical.
//
@ -73,7 +73,7 @@ NS_CC_BEGIN
// http://particledesigner.71squared.com/
//
// IMPORTANT: Particle Designer is supported by cocos2d, but
// 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
// 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d,
// cocos2d uses a another approach, but the results are almost identical.
//
@ -392,12 +392,12 @@ bool CCParticleSystem::initWithTotalParticles(unsigned int numberOfParticles)
m_bIsAutoRemoveOnFinish = false;
// Optimization: compile udpateParticle method
// Optimization: compile updateParticle method
//updateParticleSel = @selector(updateQuadWithParticle:newPosition:);
//updateParticleImp = (CC_UPDATE_PARTICLE_IMP) [self methodForSelector:updateParticleSel];
//for batchNode
m_bTransformSystemDirty = false;
// udpate after action in run!
// update after action in run!
this->scheduleUpdateWithPriority(1);
return true;
@ -734,12 +734,12 @@ void CCParticleSystem::updateQuadWithParticle(tCCParticle* particle, const CCPoi
{
CC_UNUSED_PARAM(particle);
CC_UNUSED_PARAM(newPosition);
// should be overriden
// should be overridden
}
void CCParticleSystem::postStep()
{
// should be overriden
// should be overridden
}
// ParticleSystem - CCTexture protocol

View File

@ -131,7 +131,7 @@ class CCTexture2D;
/** @brief Particle System base class.
Attributes of a Particle System:
- emmision rate of the particles
- emission rate of the particles
- Gravity Mode (Mode A):
- gravity
- direction
@ -155,7 +155,7 @@ Attributes of a Particle System:
- texture
cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/).
'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d,
'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guaranteed in cocos2d,
cocos2d uses a another approach, but the results are almost identical.
cocos2d supports all the variables used by Particle Designer plus a bit more:
@ -208,7 +208,7 @@ protected:
float endRadius;
/** The ending radius variance of the particles. Only available in 'Radius' mode. */
float endRadiusVar;
/** Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode. */
/** Number of degrees to rotate a particle around the source pos per second. Only available in 'Radius' mode. */
float rotatePerSecond;
/** Variance in degrees for rotatePerSecond. Only available in 'Radius' mode. */
float rotatePerSecondVar;
@ -245,7 +245,7 @@ protected:
bool m_bIsActive;
/** Quantity of particles that are being simulated at the moment */
CC_PROPERTY_READONLY(unsigned int, m_uParticleCount, ParticleCount)
/** How many seconds the emitter wil run. -1 means 'forever' */
/** How many seconds the emitter will run. -1 means 'forever' */
CC_PROPERTY(float, m_fDuration, Duration)
/** sourcePosition of the emitter */
CC_PROPERTY_PASS_BY_REF(CCPoint, m_tSourcePosition, SourcePosition)
@ -368,7 +368,7 @@ public:
CCParticleSystem();
virtual ~CCParticleSystem();
/** creates an initializes a CCParticleSystem from a plist file.
This plist files can be creted manually or with Particle Designer:
This plist files can be created manually or with Particle Designer:
http://particledesigner.71squared.com/
@deprecated: This interface will be deprecated sooner or later.
@since v0.99.3
@ -376,7 +376,7 @@ public:
CC_DEPRECATED_ATTRIBUTE static CCParticleSystem * particleWithFile(const char *plistFile);
/** creates an initializes a CCParticleSystem from a plist file.
This plist files can be creted manually or with Particle Designer:
This plist files can be created manually or with Particle Designer:
http://particledesigner.71squared.com/
@since v2.0
*/
@ -388,7 +388,7 @@ public:
/** initializes a CCParticleSystem*/
bool init();
/** initializes a CCParticleSystem from a plist file.
This plist files can be creted manually or with Particle Designer:
This plist files can be created manually or with Particle Designer:
http://particledesigner.71squared.com/
@since v0.99.3
*/
@ -412,9 +412,9 @@ public:
//! whether or not the system is full
bool isFull();
//! should be overriden by subclasses
//! should be overridden by subclasses
virtual void updateQuadWithParticle(tCCParticle* particle, const CCPoint& newPosition);
//! should be overriden by subclasses
//! should be overridden by subclasses
virtual void postStep();
virtual void update(float dt);

View File

@ -381,7 +381,7 @@ void CCParticleSystemQuad::draw()
void CCParticleSystemQuad::setTotalParticles(unsigned int tp)
{
// If we are setting the total numer of particles to a number higher
// If we are setting the total number of particles to a number higher
// than what is allocated, we need to allocate new arrays
if( tp > m_uAllocatedParticles )
{

View File

@ -67,20 +67,20 @@ public:
virtual ~CCParticleSystemQuad();
/** creates an initializes a CCParticleSystemQuad from a plist file.
This plist files can be creted manually or with Particle Designer:
This plist files can be created manually or with Particle Designer:
@deprecated: This interface will be deprecated sooner or later.
*/
CC_DEPRECATED_ATTRIBUTE static CCParticleSystemQuad * particleWithFile(const char *plistFile);
/** creates an initializes a CCParticleSystemQuad from a plist file.
This plist files can be creted manually or with Particle Designer:
This plist files can be created manually or with Particle Designer:
*/
static CCParticleSystemQuad * create(const char *plistFile);
/** initialices the indices for the vertices*/
/** initializes the indices for the vertices*/
void setupIndices();
/** initilizes the texture with a rectangle measured Points */
/** initializes the texture with a rectangle measured Points */
void initTexCoordsWithRect(const CCRect& rect);
/** Sets a new CCSpriteFrame as particle.

View File

@ -46,7 +46,7 @@ public:
/**
@brief Callback by CCDirector for limit FPS.
@interval The time, which expressed in second in second, between current frame and next.
@interval The time, expressed in seconds, between current frame and next.
*/
virtual void setAnimationInterval(double interval) = 0;

View File

@ -47,14 +47,13 @@ void CC_DLL CCLog(const char * pszFormat, ...);
*/
void CC_DLL CCLuaLog(const char * pszFormat);
/**
@brief Pop out a message box
*/
void CC_DLL CCMessageBox(const char * pszMsg, const char * pszTitle);
/**
@brief Enum the language type supportted now
@brief Enum the language type supported now
*/
typedef enum LanguageType
{

View File

@ -91,7 +91,7 @@ void CCEGLViewProtocol::setDesignResolutionSize(float width, float height, Resol
//setViewPortInPoints(0, 0,m_obScreenSize.width, m_obScreenSize.height);
// reset director's member vaviables to fit visible rect
// reset director's member variables to fit visible rect
CCDirector::sharedDirector()->createStatsLabel();
CCDirector::sharedDirector()->m_obWinSizeInPoints = CCDirector::sharedDirector()->m_obWinSizeInPixels = getSize();
CCDirector::sharedDirector()->setGLDefaultValues();

View File

@ -36,7 +36,7 @@ public:
CCEGLViewProtocol();
virtual ~CCEGLViewProtocol();
/** Force destorying EGL view, subclass must implement this method. */
/** Force destroying EGL view, subclass must implement this method. */
virtual void end() = 0;
/** Get whether opengl render system is ready, subclass must implement this method. */
@ -77,14 +77,14 @@ public:
virtual CCPoint getVisibleOrigin() const;
/**
* Set the design resolutin size.
* You can't use it with enableRetina together.
* Set the design resolution size.
* Behavior undefined when enableRetina == true.
* @param width Design resolution width.
* @param height Design resolution height.
* @param resolutionPolicy The resolution policy you need, there are:
* [1] kCCResolutionExactFit Fill screen, if the design resolution ratio of width and height is different from the screen resolution ratio, your game view will be stretched.
* [2] kCCResolutionNoBorder Full screen without black border, if the design resolution ratio of width and height is different from the screen resolution ratio, two areas of your game view will be cut.
* [3] kCCResolutionShowAll Full screen with black border, if the design resolution ratio of width and height is different from the screen resolution ratio, two black border will be shown on the screen;
* @param resolutionPolicy The resolution policy desired, you may choose:
* [1] kCCResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
* [2] kCCResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
* [3] kCCResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
*/
virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy);
@ -93,7 +93,7 @@ public:
/**
* Set content scale factor.
* @return If return true, it means the plaform supports retina display.
* @return If the return value is true, the platform supports retina display mode.
*/
virtual bool setContentScaleFactor(float contentScaleFactor);
@ -113,30 +113,29 @@ public:
*/
virtual bool enableRetina();
/** handle touch events by default, if you want to custom your handles, please override these functions */
/** Touch events are handled by default; if you want to customize your handlers, please override these functions: */
virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]);
virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]);
virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]);
virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]);
/**
* Get opengl view port rectangle.
* Get the opengl view port rectangle.
*/
const CCRect& getViewPortRect() const;
/**
* Get the scale factor of horizontal direction.
*
* Get scale factor of the horizontal direction.
*/
float getScaleX() const;
/**
* Get the scale factor of vertical direction.
* Get scale factor of the vertical direction.
*/
float getScaleY() const;
/**
* Get whether the retina mode is enabled.
* Get retina mode status (on if true).
*/
bool isRetinaEnabled() const;
private:
@ -145,9 +144,9 @@ private:
protected:
EGLTouchDelegate* m_pDelegate;
// real size of screen
// real screen size
CCSize m_obScreenSize;
// resolution size, it is the size the app resources designed for
// resolution size, it is the size appropriate for the app resources.
CCSize m_obDesignResolutionSize;
// the view port size
CCRect m_obViewPortRect;

View File

@ -45,20 +45,20 @@ public:
void purgeCachedEntries();
/**
@brief Get resource file data
@param[in] pszFileName The resource file name which contain the path
@param[in] pszMode The read mode of the file
@param[out] pSize If get the file data succeed the it will be the data size,or it will be 0
@return if success,the pointer of data will be returned,or NULL is returned
@warning If you get the file data succeed,you must delete[] it after used.
@param[in] pszFileName The resource file name which contains the path.
@param[in] pszMode The read mode of the file.
@param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0.
@return Upon success, a pointer to the data is returned, otherwise NULL.
@warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned.
*/
unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize);
/**
@brief Get resource file data from zip file
@param[in] pszFileName The resource file name which contain the relative path of zip file
@param[out] pSize If get the file data succeed the it will be the data size,or it will be 0
@return if success,the pointer of data will be returned,or NULL is returned
@warning If you get the file data succeed,you must delete[] it after used.
@brief Get resource file data from a zip file.
@param[in] pszFileName The resource file name which contains the relative path of the zip file.
@param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0.
@return Upon success, a pointer to the data is returned, otherwise NULL.
@warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned.
*/
unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize);
@ -67,8 +67,8 @@ public:
@param pszRelativePath The relative path of the file.
@return The absolute path of the file.
@warning We only add the ResourcePath before the relative path of the file.
If you have not set the ResourcePath,the function add "/NEWPLUS/TDA_DATA/UserData/" as default.
You can set ResourcePath by function void setResourcePath(const char *pszResourcePath);
If you have not set the ResourcePath, the function appends "/NEWPLUS/TDA_DATA/UserData/" by default.
You can set ResourcePath with void setResourcePath(const char *pszResourcePath);
*/
const char* fullPathFromRelativePath(const char *pszRelativePath);
@ -77,8 +77,8 @@ public:
/// @endcond
/**
@brief Set the resource directory,we will find resource relative to this directory
@param pszDirectoryName Relative path to root
@brief Set the resource directory; we will find resources relative to this directory.
@param pszDirectoryName Relative path to root.
*/
void setResourceDirectory(const char *pszDirectoryName);
@ -100,6 +100,10 @@ public:
bool isPopupNotify();
protected:
CCFileUtils(void)
{
}
std::string m_obDirectory;
};

View File

@ -199,7 +199,7 @@ public:
}
else if (preState == SAX_ARRAY)
{
CCAssert(! m_tArrayStack.empty(), "The state is worng!");
CCAssert(! m_tArrayStack.empty(), "The state is wrong!");
CCArray* pPreArray = m_tArrayStack.top();
pPreArray->addObject(m_pArray);
}
@ -305,7 +305,7 @@ public:
{
if (curState == SAX_DICT)
{
CCAssert(!m_sCurKey.empty(), "not found key : <integet/real>");
CCAssert(!m_sCurKey.empty(), "key not found : <integer/real>");
}
m_sCurValue.append(pText->getCString());

View File

@ -64,29 +64,29 @@ public:
/**
@brief Load the image from the specified path.
@param strPath the absolute file path
@param imageType the type of image, now only support tow types.
@return true if load correctly
@param strPath the absolute file path.
@param imageType the type of image, currently only supporting two types.
@return true if loaded correctly.
*/
bool initWithImageFile(const char * strPath, EImageFormat imageType = kFmtPng);
/*
@brief The same meaning as initWithImageFile, but it is thread safe. It is casued by
@brief The same result as with initWithImageFile, but thread safe. It is caused by
loadImage() in CCTextureCache.cpp.
@param fullpath full path of the file
@param imageType the type of image, now only support tow types.
@return true if load correctly
@param fullpath full path of the file.
@param imageType the type of image, currently only supporting two types.
@return true if loaded correctly.
*/
bool initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType = kFmtPng);
/**
@brief Load image from stream buffer.
@warning kFmtRawData only support RGBA8888
@param pBuffer stream buffer that hold the image data
@param nLength the length of data(managed in byte)
@param nWidth, nHeight, nBitsPerComponent are used for kFmtRawData
@return true if load correctly
@warning kFmtRawData only supports RGBA8888.
@param pBuffer stream buffer which holds the image data.
@param nLength data length expressed in (number of) bytes.
@param nWidth, nHeight, nBitsPerComponent are used for kFmtRawData.
@return true if loaded correctly.
*/
bool initWithImageData(void * pData,
int nDataLen,
@ -97,11 +97,11 @@ public:
/**
@brief Create image with specified string.
@param pText the text which the image show, nil cause init fail
@param nWidth the image width, if 0, the width match the text's width
@param nHeight the image height, if 0, the height match the text's height
@param pText the text the image will show (cannot be nil).
@param nWidth the image width, if 0, the width will match the text's width.
@param nHeight the image height, if 0, the height will match the text's height.
@param eAlignMask the test Alignment
@param pFontName the name of the font which use to draw the text. If nil, use the default system font.
@param pFontName the name of the font used to draw the text. If nil, use the default system font.
@param nSize the font size, if 0, use the system default size.
*/
bool initWithString(
@ -119,9 +119,9 @@ public:
bool isPremultipliedAlpha() { return m_bPreMulti; }
/**
@brief Save the CCImage data to specified file with specified format.
@param pszFilePath the file's absolute path, including file subfix
@param bIsToRGB if the image is saved as RGB format
@brief Save CCImage data to the specified file, with specified format.
@param pszFilePath the file's absolute path, including file suffix.
@param bIsToRGB whether the image is saved as RGB format.
*/
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);

View File

@ -40,7 +40,7 @@ NS_CC_BEGIN
// premultiply alpha, or the effect will wrong when want to use other pixel format in CCTexture2D,
// such as RGB888, RGB5A1
#define CC_RGB_PREMULTIPLY_APLHA(vr, vg, vb, va) \
#define CC_RGB_PREMULTIPLY_ALPHA(vr, vg, vb, va) \
(unsigned)(((unsigned)((unsigned char)(vr) * ((unsigned char)(va) + 1)) >> 8) | \
((unsigned)((unsigned char)(vg) * ((unsigned char)(va) + 1) >> 8) << 8) | \
((unsigned)((unsigned char)(vb) * ((unsigned char)(va) + 1) >> 8) << 16) | \
@ -71,7 +71,7 @@ static void pngReadCallback(png_structp png_ptr, png_bytep data, png_size_t leng
}
//////////////////////////////////////////////////////////////////////////
// Impliment CCImage
// Implement CCImage
//////////////////////////////////////////////////////////////////////////
CCImage::CCImage()
@ -325,7 +325,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
{
png_set_palette_to_rgb(png_ptr);
}
// low-bit-depth grayscale iamges are to be expanded to 8 bits
// low-bit-depth grayscale images are to be expanded to 8 bits
if (color_type == PNG_COLOR_TYPE_GRAY && m_nBitsPerComponent < 8)
{
png_set_expand_gray_1_2_4_to_8(png_ptr);
@ -376,7 +376,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen)
{
for(unsigned int j = 0; j < rowbytes; j += 4)
{
*tmp++ = CC_RGB_PREMULTIPLY_APLHA( row_pointers[i][j], row_pointers[i][j + 1],
*tmp++ = CC_RGB_PREMULTIPLY_ALPHA( row_pointers[i][j], row_pointers[i][j + 1],
row_pointers[i][j + 2], row_pointers[i][j + 3] );
}
}
@ -553,7 +553,7 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen)
after invoking TIFFReadRGBAImageOriented
for(int j = 0; j < m_nWidth * m_nHeight * 4; j += 4)
{
*tmp++ = CC_RGB_PREMULTIPLY_APLHA( src[j], src[j + 1],
*tmp++ = CC_RGB_PREMULTIPLY_ALPHA( src[j], src[j + 1],
src[j + 2], src[j + 3] );
}
*/
@ -585,7 +585,7 @@ bool CCImage::_initWithRawData(void * pData, int nDatalen, int nWidth, int nHeig
m_nWidth = (short)nWidth;
m_bHasAlpha = true;
// only RGBA8888 surported
// only RGBA8888 supported
int nBytesPerComponent = 4;
int nSize = nHeight * nWidth * nBytesPerComponent;
m_pData = new unsigned char[nSize];

View File

@ -26,10 +26,7 @@ THE SOFTWARE.
#define __CC_PLATFORM_CONFIG_H__
/**
Config of cocos2d-x project.
There are config below:
build for which target platform
Config of cocos2d-x project, per target platform.
*/
//////////////////////////////////////////////////////////////////////////
@ -47,7 +44,7 @@ build for which target platform
#define CC_PLATFORM_BLACKBERRY 7
#define CC_PLATFORM_MAC 8
// Determine tartet platform by compile environment macro.
// Determine target platform by compile environment macro.
#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
// iphone
@ -106,10 +103,9 @@ build for which target platform
// check user set platform
#if ! CC_TARGET_PLATFORM
#error "Can not recognize the target platform, compling under a unsupported platform?"
#error "Cannot recognize the target platform; are you targeting an unsupported platform?"
#endif
// Check the supportive of platform
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#pragma warning (disable:4127)
#endif // CC_PLATFORM_WIN32

View File

@ -49,7 +49,7 @@ bool CCSAXParser::init(const char *pszEncoding)
bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength)
{
/*
* this initialize the library and check potential ABI mismatches
* this initializes the library and checks potential ABI mismatches
* between the version it was compiled for and the actual shared
* library used.
*/

View File

@ -24,8 +24,8 @@ THE SOFTWARE.
#include "CCThread.h"
// iOS already has a CCThread.mm
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
// iOS and Mac already has a CCThread.mm
#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS && CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
NS_CC_BEGIN

View File

@ -15,8 +15,8 @@ public:
virtual ~CCApplication();
/**
@brief Callback by CCDirector for limit FPS.
@interval The time, which expressed in second in second, between current frame and next.
@brief Callback by CCDirector to limit FPS.
@interval The time, expressed in seconds, between current frame and next.
*/
void setAnimationInterval(double interval);
@ -33,8 +33,8 @@ public:
} Orientation;
/**
@brief Callback by CCDirector for change device orientation.
@orientation The defination of orientation which CCDirector want change to.
@brief Callback by CCDirector to change device orientation.
@orientation The desired orientation.
@return The actual orientation of the application.
*/
Orientation setOrientation(Orientation orientation);
@ -45,7 +45,7 @@ public:
int run();
/**
@brief Get current applicaiton instance.
@brief Get current application instance.
@return Current application instance pointer.
*/
static CCApplication* sharedApplication();

View File

@ -41,7 +41,7 @@ THE SOFTWARE.
// normal process
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
// gl2.h don't define GLchar on Android
// gl2.h doesn't define GLchar on Android
typedef char GLchar;
//declare here while define in CCEGLView_android.cpp

View File

@ -69,7 +69,7 @@ public:
* this method call Cococs2dx.createBitmap()(java code) to create the bitmap, the java code
* will call Java_org_cocos2dx_lib_Cocos2dxBitmap_nativeInitBitmapDC() to init the width, height
* and data.
* use this appoach to decrease the jni call number
* use this approach to decrease the jni call number
*/
jstring jstrText = methodInfo.env->NewStringUTF(text);
jstring jstrFont = methodInfo.env->NewStringUTF(pFontName);

View File

@ -44,14 +44,14 @@ public:
int run();
/**
@brief Get current applicaiton instance.
@brief Get the current application instance.
@return Current application instance pointer.
*/
static CCApplication* sharedApplication();
/**
@brief Callback by CCDirector for limit FPS.
@interval The time, which expressed in second in second, between current frame and next.
@interval The time, expressed in seconds, between current frame and next.
*/
virtual void setAnimationInterval(double interval);

View File

@ -110,7 +110,7 @@ ccLanguageType CCApplication::getCurrentLanguage()
TargetPlatform CCApplication::getTargetPlatform()
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) // idiom for iOS <= 3.2, otherwise: [UIDevice userInterfaceIdiom] is faster.
{
return kTargetIpad;
}

View File

@ -66,7 +66,7 @@ static id s_sharedDirectorCaller;
-(void) startMainLoop
{
// CCDirector::setAnimationInterval() is called, we should invalide it first
// CCDirector::setAnimationInterval() is called, we should invalidate it first
[displayLink invalidate];
displayLink = nil;
@ -77,7 +77,7 @@ static id s_sharedDirectorCaller;
-(void) setAnimationInterval:(double)intervalNew
{
// CCDirector::setAnimationInterval() is called, we should invalide it first
// CCDirector::setAnimationInterval() is called, we should invalidate it first
[displayLink invalidate];
displayLink = nil;

View File

@ -48,8 +48,7 @@ bool CCEGLView::isOpenGLReady()
bool CCEGLView::setContentScaleFactor(float contentScaleFactor)
{
// can not enable retina because have used resolution policy
assert(m_eResolutionPolicy == kResolutionUnKnown);
assert(m_eResolutionPolicy == kResolutionUnKnown); // cannot enable retina mode
if ([[EAGLView sharedEGLView] respondsToSelector:@selector(setContentScaleFactor:)])
{

View File

@ -264,7 +264,7 @@ CCArray* ccFileUtils_arrayWithContentsOfFileThreadSafe(const char* pFileName)
unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize)
{
unsigned char * pBuffer = NULL;
CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invaild parameters.");
CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invalid parameters.");
*pSize = 0;
do
{

View File

@ -437,7 +437,7 @@ bool CCImage::_initWithRawData(void *pData, int nDatalen, int nWidth, int nHeigh
m_nWidth = (short)nWidth;
m_bHasAlpha = true;
// only RGBA8888 surported
// only RGBA8888 supported
int nBytesPerComponent = 4;
int nSize = nHeight * nWidth * nBytesPerComponent;
m_pData = new unsigned char[nSize];

View File

@ -577,7 +577,7 @@ static EAGLView *view = 0;
/* If text can be selected, it can be marked. Marked text represents provisionally
* inserted text that has yet to be confirmed by the user. It requires unique visual
* treatment in its display. If there is any marked text, the selection, whether a
* caret or an extended range, always resides witihin.
* caret or an extended range, always resides within.
*
* Setting marked text either replaces the existing marked text or, if none is present,
* inserts it from the current selection. */

View File

@ -113,7 +113,7 @@
- (ZAttributedString *)attributedSubstringFromRange:(NSRange)aRange {
if (NSMaxRange(aRange) > [_buffer length]) {
@throw [NSException exceptionWithName:NSRangeException reason:@"range was outisde of the attributed string" userInfo:nil];
@throw [NSException exceptionWithName:NSRangeException reason:@"range was outside of the attributed string" userInfo:nil];
}
ZMutableAttributedString *newStr = [self mutableCopy];
if (aRange.location > 0) {

View File

@ -24,7 +24,7 @@
@end
// override UIAccelerometer behaviour
// override UIAccelerometer behavior
@interface UIAccelerometer (Simulation)
+ (UIAccelerometer *)sharedAccelerometer;
@end

View File

@ -167,7 +167,7 @@ static AccelerometerSimulation *sharedAccelerometer = NULL;
accObject = [UIAccelerationSimulation alloc];
isExiting = false;
// couldn't get the CFSocket version to work with UDP and runloop, so used Berkely sockets and a thread instead
// couldn't get the CFSocket version to work with UDP and runloop, so used Berkeley sockets and a thread instead
udpSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
struct sockaddr_in sin;

View File

@ -142,6 +142,11 @@ void mousePosEventHandle(int iPosX,int iPosY) {
}
}
int closeEventHandle() {
CCDirector::sharedDirector()->end();
return GL_TRUE;
}
void CCEGLView::setFrameSize(float width, float height)
{
bool eResult = false;
@ -217,6 +222,8 @@ void CCEGLView::setFrameSize(float width, float height)
//register the glfw mouse pos event
glfwSetMousePosCallback(mousePosEventHandle);
glfwSetWindowCloseCallback(closeEventHandle);
//Inits extensions
eResult = initExtensions();

View File

@ -27,7 +27,7 @@ THE SOFTWARE.
#include "platform/CCAccelerometerDelegate.h"
namespace cocos2d {
NS_CC_BEGIN
class CC_DLL CCAccelerometer
{
@ -38,6 +38,6 @@ public:
void setDelegate(CCAccelerometerDelegate* pDelegate) { CC_UNUSED_PARAM(pDelegate); }
};
}//namespace cocos2d
NS_CC_END
#endif

View File

@ -22,14 +22,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#ifndef __CC_APPLICATION_MAC_H__
#define __CC_APPLICATION_MAC_H__
#include "platform/CCCommon.h"
#include "platform/CCApplicationProtocol.h"
#include <string>
NS_CC_BEGIN;
NS_CC_BEGIN
class CC_DLL CCApplication : public CCApplicationProtocol
{
@ -69,10 +69,23 @@ public:
*/
virtual TargetPlatform getTargetPlatform();
/* set the Resource root path */
void setResourceRootPath(const std::string& rootResDir);
/* get the Resource root path */
const std::string& getResourceRootPath(void);
void setStartupScriptFilename(const std::string& startupScriptFile);
const std::string& getStartupScriptFilename(void);
protected:
static CCApplication * sm_pSharedApplication;
std::string m_resourceRootPath;
std::string m_startupScriptFilename;
};
NS_CC_END;
NS_CC_END
#endif // end of __CC_APPLICATION_MAC_H__
#endif // end of __CC_APPLICATION_MAC_H__;

View File

@ -23,26 +23,26 @@
****************************************************************************/
#import "CCApplication.h"
#import <Cocoa/Cocoa.h>
#include <algorithm>
#import "CCGeometry.h"
#include "CCGeometry.h"
#include "CCDirector.h"
#import "CCDirectorCaller.h"
NS_CC_BEGIN;
NS_CC_BEGIN
CCApplication* CCApplication::sm_pSharedApplication = 0;
CCApplication::CCApplication()
{
CC_ASSERT(! sm_pSharedApplication);
CCAssert(! sm_pSharedApplication, "sm_pSharedApplication already exist");
sm_pSharedApplication = this;
}
CCApplication::~CCApplication()
{
CC_ASSERT(this == sm_pSharedApplication);
CCAssert(this == sm_pSharedApplication, "sm_pSharedApplication != this");
sm_pSharedApplication = 0;
}
@ -71,7 +71,7 @@ TargetPlatform CCApplication::getTargetPlatform()
CCApplication* CCApplication::sharedApplication()
{
CC_ASSERT(sm_pSharedApplication);
CCAssert(sm_pSharedApplication, "sm_pSharedApplication not set");
return sm_pSharedApplication;
}
@ -99,4 +99,30 @@ ccLanguageType CCApplication::getCurrentLanguage()
return ret;
}
NS_CC_END;
void CCApplication::setResourceRootPath(const std::string& rootResDir)
{
m_resourceRootPath = rootResDir;
std::replace(m_resourceRootPath.begin(), m_resourceRootPath.end(), '\\', '/');
if (m_resourceRootPath[m_resourceRootPath.length() - 1] != '/')
{
m_resourceRootPath += '/';
}
}
const std::string& CCApplication::getResourceRootPath(void)
{
return m_resourceRootPath;
}
void CCApplication::setStartupScriptFilename(const std::string& startupScriptFile)
{
m_startupScriptFilename = startupScriptFile;
std::replace(m_startupScriptFilename.begin(), m_startupScriptFilename.end(), '\\', '/');
}
const std::string& CCApplication::getStartupScriptFilename(void)
{
return m_startupScriptFilename;
}
NS_CC_END

View File

@ -30,7 +30,7 @@
#import "EAGLView.h"
NS_CC_BEGIN;
NS_CC_BEGIN
void CCLog(const char * pszFormat, ...)
{
@ -45,6 +45,11 @@ void CCLog(const char * pszFormat, ...)
printf("\n");
}
void CCLuaLog(const char * pszFormat)
{
CCLog(pszFormat);
}
// ios no MessageBox, use CCLog instead
void CCMessageBox(const char * pszMsg, const char * pszTitle)
{
@ -64,4 +69,4 @@ void CCMessageBox(const char * pszMsg, const char * pszTitle)
contextInfo:nil];
}
NS_CC_END;
NS_CC_END

View File

@ -31,8 +31,9 @@
}
@property (readwrite) int interval;
-(void) startMainLoop;
-(void) end;
-(void) doCaller: (id) sender;
-(void) setAnimationInterval:(double)interval;
+(id) sharedDirectorCaller;
+(void) destroy;
@end

View File

@ -45,30 +45,24 @@ static id s_sharedDirectorCaller;
{
if (s_sharedDirectorCaller == nil)
{
s_sharedDirectorCaller = [CCDirectorCaller new];
s_sharedDirectorCaller = [[CCDirectorCaller alloc] init];
}
return s_sharedDirectorCaller;
}
+(void) destroy
{
[s_sharedDirectorCaller release];
}
-(void) alloc
{
interval = 1;
interval = 1;
}
-(void) dealloc
{
s_sharedDirectorCaller = nil;
NSLog(@"cocos2d: deallocing CCDirectorCaller %@", self);
if (displayLink) {
CVDisplayLinkRelease(displayLink);
}
if (renderTimer) {
[renderTimer release];
}
[super dealloc];
}
@ -77,7 +71,7 @@ static id s_sharedDirectorCaller;
#if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
//if( ! runningThread_ )
//runningThread_ = [NSThread currentThread];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
cocos2d::CCDirector::sharedDirector()->drawScene();
@ -99,84 +93,94 @@ static id s_sharedDirectorCaller;
// This is the renderer output callback function
static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext)
{
// CVReturn result = [(CCDirectorCaller*)displayLinkContext getFrameForTime:outputTime];
// return result;
// CVReturn result = [(CCDirectorCaller*)displayLinkContext getFrameForTime:outputTime];
// return result;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
cocos2d::CCDirector::sharedDirector()->mainLoop();
[pool release];
return kCVReturnSuccess;
}
- (void)timerFired:(id)sender
{
// It is good practice in a Cocoa application to allow the system to send the -drawRect:
// message when it needs to draw, and not to invoke it directly from the timer.
// message when it needs to draw, and not to invoke it directly from the timer.
// All we do here is tell the display it needs a refresh
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// get the opengl view
EAGLView *openGLView = [EAGLView sharedEGLView];
[openGLView lockOpenGLContext];
// run the main cocos2d loop
cocos2d::CCDirector::sharedDirector()->mainLoop();
// flush buffer (this line is very important!)
[[openGLView openGLContext] flushBuffer];
[[openGLView openGLContext] flushBuffer];
[openGLView unlockOpenGLContext];
// send any queued events
[[CCEventDispatcher sharedDispatcher] dispatchQueuedEvents];
[pool release];
}
-(void) startMainLoop
{
// CCDirector::setAnimationInterval() is called, we should invalide it first
// [displayLink invalidate];
// displayLink = nil;
//
// displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doCaller:)];
// [displayLink setFrameInterval: self.interval];
// [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
// CCDirector::setAnimationInterval() is called, we should invalide it first
// [displayLink invalidate];
// displayLink = nil;
//
// displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doCaller:)];
// [displayLink setFrameInterval: self.interval];
// [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
#if ! CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
NSThread* thread = [[NSThread alloc] initWithTarget:self selector:@selector(mainLoop) object:nil];
[thread start];
[thread start];
#endif
// NSTimer
[renderTimer invalidate];
renderTimer = nil;
renderTimer = [NSTimer timerWithTimeInterval:self.interval/60.0f //a 1ms time interval
target:self
selector:@selector(timerFired:)
userInfo:nil
repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:renderTimer
forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:renderTimer
forMode:NSEventTrackingRunLoopMode]; //Ensure timer fires during resize
/*
// CVDisplayLink
//cocos2d::CCDirector::sharedDirector()->gettimeofday();
// Create a display link capable of being used with all active displays
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
// Set the renderer output callback function
CVDisplayLinkSetOutputCallback(displayLink, &MyDisplayLinkCallback, self);
// Set the display link for the current renderer
EAGLView *openGLView_ = (EAGLView*)[EAGLView sharedEGLView];
CGLContextObj cglContext = (CGLContextObj)[[openGLView_ openGLContext] CGLContextObj];
CGLPixelFormatObj cglPixelFormat = (CGLPixelFormatObj)[[openGLView_ pixelFormat] CGLPixelFormatObj];
CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, cglContext, cglPixelFormat);
// Activate the display link
CVDisplayLinkStart(displayLink);
*/
target:self
selector:@selector(timerFired:)
userInfo:nil
repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:renderTimer
forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:renderTimer
forMode:NSEventTrackingRunLoopMode]; //Ensure timer fires during resize
/*
// CVDisplayLink
//cocos2d::CCDirector::sharedDirector()->gettimeofday();
// Create a display link capable of being used with all active displays
CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
// Set the renderer output callback function
CVDisplayLinkSetOutputCallback(displayLink, &MyDisplayLinkCallback, self);
// Set the display link for the current renderer
EAGLView *openGLView_ = (EAGLView*)[EAGLView sharedEGLView];
CGLContextObj cglContext = (CGLContextObj)[[openGLView_ openGLContext] CGLContextObj];
CGLPixelFormatObj cglPixelFormat = (CGLPixelFormatObj)[[openGLView_ pixelFormat] CGLPixelFormatObj];
CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, cglContext, cglPixelFormat);
// Activate the display link
CVDisplayLinkStart(displayLink);
*/
}
-(void) end
{
[renderTimer invalidate];
renderTimer = nil;
[self release];
}
-(void) setAnimationInterval:(double)intervalNew
@ -195,7 +199,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
[[NSRunLoop currentRunLoop] addTimer:renderTimer
forMode:NSEventTrackingRunLoopMode];
}
-(void) doCaller: (id) sender
{
cocos2d::CCDirector::sharedDirector()->mainLoop();

View File

@ -1,26 +1,26 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CC_EGLVIEW_MAC_H__
#define __CC_EGLVIEW_MAC_H__
@ -28,7 +28,8 @@ THE SOFTWARE.
#include "platform/CCCommon.h"
#include "platform/CCEGLViewProtocol.h"
namespace cocos2d {
NS_CC_BEGIN
class CCSet;
class CCTouch;
class CCSize;
@ -36,22 +37,24 @@ class CCSize;
class CC_DLL CCEGLView : public CCEGLViewProtocol
{
public:
CCEGLView();
virtual ~CCEGLView();
bool isOpenGLReady();
static CCEGLView* sharedOpenGLView(void);
virtual ~CCEGLView(void);
virtual bool isOpenGLReady(void);
virtual bool setContentScaleFactor(float contentScaleFactor);
void end();
void swapBuffers();
void setIMEKeyboardState(bool bOpen);
void setMultiTouchMask(bool mask);
static CCEGLView* sharedOpenGLView();
virtual void end();
virtual void swapBuffers(void);
virtual void setIMEKeyboardState(bool bOpen);
virtual void setMultiTouchMask(bool mask);
private:
static CCEGLView* s_sharedView;
CCEGLView(void);
};
} // end of namespace cocos2d
NS_CC_END // end of namespace cocos2d
#endif // end of __CC_EGLVIEW_MAC_H__

View File

@ -1,26 +1,26 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCEGLView.h"
#include "EAGLView.h"
#include "CCDirectorCaller.h"
@ -28,19 +28,32 @@ THE SOFTWARE.
#include "CCTouch.h"
#include "CCTouchDispatcher.h"
namespace cocos2d {
NS_CC_BEGIN
CCEGLView::CCEGLView()
CCEGLView* CCEGLView::s_sharedView = NULL;
CCEGLView* CCEGLView::sharedOpenGLView(void)
{
if (!s_sharedView)
{
s_sharedView = new CCEGLView();
}
return s_sharedView;
}
CCEGLView::CCEGLView(void)
{
m_obScreenSize.width = m_obDesignResolutionSize.width = [[EAGLView sharedEGLView] getWidth];
m_obScreenSize.height = m_obDesignResolutionSize.height = [[EAGLView sharedEGLView] getHeight];
}
CCEGLView::~CCEGLView()
CCEGLView::~CCEGLView(void)
{
CCLOG("cocos2d: deallocing CCEGLView %0x", this);
s_sharedView = NULL;
}
bool CCEGLView::isOpenGLReady()
bool CCEGLView::isOpenGLReady(void)
{
return [EAGLView sharedEGLView] != NULL;
}
@ -50,14 +63,14 @@ bool CCEGLView::setContentScaleFactor(float contentScaleFactor)
return false;
}
void CCEGLView::end()
void CCEGLView::end(void)
{
[CCDirectorCaller destroy];
[[CCDirectorCaller sharedDirectorCaller] end];
// destroy EAGLView
[[EAGLView sharedEGLView] removeFromSuperview];
_exit(0);
delete this;
}
void CCEGLView::swapBuffers()
@ -83,10 +96,4 @@ void CCEGLView::setMultiTouchMask(bool mask)
//glView.multipleTouchEnabled = mask ? YES : NO;
}
CCEGLView* CCEGLView::sharedOpenGLView()
{
static CCEGLView instance;
return &instance;
}
} // end of namespace cocos2d;
NS_CC_END // end of namespace cocos2d;

View File

@ -1,27 +1,27 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2011 Zynga Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import <Foundation/Foundation.h>
#include <string>
@ -44,7 +44,7 @@ USING_NS_CC;
static void static_addValueToCCDict(id key, id value, CCDictionary* pDict);
static void static_addItemToCCArray(id item, CCArray* pArray);
static NSFileManager *__localFileManager= [[NSFileManager alloc] init];
static NSFileManager *__localFileManager= [NSFileManager defaultManager];
static void static_addItemToCCArray(id item, CCArray *pArray)
{
@ -56,7 +56,7 @@ static void static_addItemToCCArray(id item, CCArray *pArray)
pValue->release();
return;
}
// add number value into array(such as int, float, bool and so on)
if ([item isKindOfClass:[NSNumber class]]) {
NSString* pStr = [item stringValue];
@ -97,7 +97,7 @@ static void static_addValueToCCDict(id key, id value, CCDictionary* pDict)
// the key must be a string
CCAssert([key isKindOfClass:[NSString class]], "The key should be a string!");
std::string pKey = [key UTF8String];
// the value is a new dictionary
if ([value isKindOfClass:[NSDictionary class]]) {
CCDictionary* pSubDict = new CCDictionary();
@ -109,16 +109,16 @@ static void static_addValueToCCDict(id key, id value, CCDictionary* pDict)
pSubDict->release();
return;
}
// the value is a string
if ([value isKindOfClass:[NSString class]]) {
CCString* pValue = new CCString([value UTF8String]);
pDict->setObject(pValue, pKey.c_str());
pValue->release();
return;
}
// the value is a number
if ([value isKindOfClass:[NSNumber class]]) {
NSString* pStr = [value stringValue];
@ -128,7 +128,7 @@ static void static_addValueToCCDict(id key, id value, CCDictionary* pDict)
pValue->release();
return;
}
// the value is a array
if ([value isKindOfClass:[NSArray class]]) {
CCArray *pArray = new CCArray();
@ -164,13 +164,13 @@ void CCFileUtils::purgeFileUtils()
{
s_pFileUtils->purgeCachedEntries();
}
CC_SAFE_DELETE(s_pFileUtils);
}
void CCFileUtils::purgeCachedEntries()
{
}
void CCFileUtils::setResourceDirectory(const char *pszDirectoryName)
@ -191,7 +191,6 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
// only if it is not an absolute path
if( ! [relPath isAbsolutePath] ) {
// pathForResource also searches in .lproj directories. issue #1230
NSString *lastPathComponent = [relPath lastPathComponent];
@ -199,16 +198,24 @@ const char* CCFileUtils::fullPathFromRelativePath(const char *pszRelativePath)
NSMutableString *imageDirectoryByAppendDirectory = [NSMutableString stringWithUTF8String:m_obDirectory.c_str()];
[imageDirectoryByAppendDirectory appendString:imageDirectory];
// search path from directory set by setResourceDirectory
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
ofType:nil
inDirectory:imageDirectoryByAppendDirectory];
if (fullpath == nil)
const std::string& resourceRootPath = CCApplication::sharedApplication()->getResourceRootPath();
if (resourceRootPath.length() == 0)
{
// search from root directory
// search path from directory set by setResourceDirectory
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
ofType:nil
inDirectory:imageDirectory];
inDirectory:imageDirectoryByAppendDirectory];
if (fullpath == nil)
{
// search from root directory
fullpath = [[NSBundle mainBundle] pathForResource:lastPathComponent
ofType:nil
inDirectory:imageDirectory];
}
}
else
{
fullpath = [NSString stringWithFormat:@"%s%s%@", resourceRootPath.c_str(), m_obDirectory.c_str(), relPath];
}
}
@ -257,7 +264,7 @@ CCArray* ccFileUtils_arrayWithContentsOfFileThreadSafe(const char* pFileName)
for (id value in pArray) {
static_addItemToCCArray(value, pRet);
}
return pRet;
}
@ -266,12 +273,12 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
unsigned char * pBuffer = NULL;
CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invaild parameters.");
*pSize = 0;
do
do
{
// read the file from hardware
FILE *fp = fopen(pszFileName, pszMode);
CC_BREAK_IF(!fp);
fseek(fp,0,SEEK_END);
*pSize = ftell(fp);
fseek(fp,0,SEEK_SET);
@ -279,13 +286,13 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz
*pSize = fread(pBuffer,sizeof(unsigned char), *pSize,fp);
fclose(fp);
} while (0);
if (! pBuffer && isPopupNotify())
if (! pBuffer && isPopupNotify())
{
std::string title = "Notification";
std::string msg = "Get data from file(";
msg.append(pszFileName).append(") failed!");
CCMessageBox(msg.c_str(), title.c_str());
}
return pBuffer;
@ -316,44 +323,44 @@ std::string CCFileUtils::getWriteablePath()
unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize)
{
unsigned char * pBuffer = NULL;
unzFile pFile = NULL;
*pSize = 0;
unsigned char * pBuffer = NULL;
unzFile pFile = NULL;
*pSize = 0;
do
{
CC_BREAK_IF(!pszZipFilePath || !pszFileName);
CC_BREAK_IF(strlen(pszZipFilePath) == 0);
do
{
CC_BREAK_IF(!pszZipFilePath || !pszFileName);
CC_BREAK_IF(strlen(pszZipFilePath) == 0);
pFile = unzOpen(pszZipFilePath);
CC_BREAK_IF(!pFile);
int nRet = unzLocateFile(pFile, pszFileName, 1);
CC_BREAK_IF(UNZ_OK != nRet);
char szFilePathA[260];
unz_file_info FileInfo;
nRet = unzGetCurrentFileInfo(pFile, &FileInfo, szFilePathA, sizeof(szFilePathA), NULL, 0, NULL, 0);
CC_BREAK_IF(UNZ_OK != nRet);
nRet = unzOpenCurrentFile(pFile);
CC_BREAK_IF(UNZ_OK != nRet);
pBuffer = new unsigned char[FileInfo.uncompressed_size];
int nSize = 0;
nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size);
CCAssert(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong");
*pSize = FileInfo.uncompressed_size;
unzCloseCurrentFile(pFile);
} while (0);
pFile = unzOpen(pszZipFilePath);
CC_BREAK_IF(!pFile);
if (pFile)
{
unzClose(pFile);
}
int nRet = unzLocateFile(pFile, pszFileName, 1);
CC_BREAK_IF(UNZ_OK != nRet);
char szFilePathA[260];
unz_file_info FileInfo;
nRet = unzGetCurrentFileInfo(pFile, &FileInfo, szFilePathA, sizeof(szFilePathA), NULL, 0, NULL, 0);
CC_BREAK_IF(UNZ_OK != nRet);
nRet = unzOpenCurrentFile(pFile);
CC_BREAK_IF(UNZ_OK != nRet);
pBuffer = new unsigned char[FileInfo.uncompressed_size];
int nSize = 0;
nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size);
CCAssert(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong");
*pSize = FileInfo.uncompressed_size;
unzCloseCurrentFile(pFile);
} while (0);
if (pFile)
{
unzClose(pFile);
}
return pBuffer;
return pBuffer;
}
NS_CC_END

View File

@ -340,8 +340,8 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
{
bool bRet = false;
CCAssert( pText, @"Invalid pText");
CCAssert( pInfo, @"Invalid pInfo");
CCAssert(pText, "Invalid pText");
CCAssert(pInfo, "Invalid pInfo");
do {
NSString * string = [NSString stringWithUTF8String:pText];
@ -480,7 +480,7 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
return bRet;
}
NS_CC_BEGIN;
NS_CC_BEGIN
static bool m_bEnabledScale = true;
@ -876,5 +876,5 @@ bool CCImage::saveToFile(const char *pszFilePath, bool bIsToRGB)
NS_CC_END;
NS_CC_END

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