mirror of https://github.com/axmolengine/axmol.git
issue #121, return bool in function init****
This commit is contained in:
parent
004df276ee
commit
5fd1bf85b6
|
@ -37,7 +37,7 @@ CCConfiguration::CCConfiguration(void)
|
|||
{
|
||||
}
|
||||
|
||||
CCConfiguration* CCConfiguration::init(void)
|
||||
bool CCConfiguration::init(void)
|
||||
{
|
||||
CCLOG("cocos2d: GL_VENDOR: %s", glGetString(GL_VENDOR));
|
||||
CCLOG("cocos2d: GL_RENDERER: %s", glGetString(GL_RENDERER));
|
||||
|
@ -73,7 +73,7 @@ CCConfiguration* CCConfiguration::init(void)
|
|||
CCLOG("cocos2d: compiled with VBO support in TextureAtlas : %s", "NO");
|
||||
#endif // CC_TEXTURE_ATLAS_USES_VBO
|
||||
|
||||
return this;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
// returns whether or not an OpenGL is supported
|
||||
bool checkForGLExtension(const std::string &searchName);
|
||||
|
||||
CCConfiguration* init(void);
|
||||
bool init(void);
|
||||
|
||||
public:
|
||||
// returns a shared instance of the CCConfiguration
|
||||
|
|
|
@ -100,7 +100,7 @@ bool CCDirector::setDierectorType(ccDirectorType obDirectorType)
|
|||
return true;
|
||||
}
|
||||
|
||||
CCDirector* CCDirector::init(void)
|
||||
bool CCDirector::init(void)
|
||||
{
|
||||
CCLOG("cocos2d: %s", cocos2dVersion());
|
||||
|
||||
|
@ -138,7 +138,7 @@ CCDirector* CCDirector::init(void)
|
|||
// create autorelease pool
|
||||
NSPoolManager::getInstance()->push();
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCDirector::~CCDirector(void)
|
||||
|
|
|
@ -132,12 +132,13 @@ CCSpeed * CCSpeed::actionWithAction(CCIntervalAction *pAction, float fRate)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CCSpeed * CCSpeed::initWithAction(CCIntervalAction *pAction, float fRate)
|
||||
bool CCSpeed::initWithAction(CCIntervalAction *pAction, float fRate)
|
||||
{
|
||||
assert(pAction != NULL);
|
||||
pAction->retain();
|
||||
m_pOther = pAction;
|
||||
m_fSpeed = fRate;
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
NSObject *CCSpeed::copyWithZone(NSZone *pZone)
|
||||
|
@ -219,8 +220,9 @@ CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode, CGRect rect)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CCFollow *CCFollow::initWithTarget(CCNode *pFollowedNode)
|
||||
bool CCFollow::initWithTarget(CCNode *pFollowedNode)
|
||||
{
|
||||
assert(pFollowedNode != NULL);
|
||||
pFollowedNode->retain();
|
||||
m_pobFollowedNode = pFollowedNode;
|
||||
m_bBoundarySet = false;
|
||||
|
@ -229,11 +231,12 @@ CCFollow *CCFollow::initWithTarget(CCNode *pFollowedNode)
|
|||
CGSize winSize = CCDirector::getSharedDirector()->getWinSize();
|
||||
m_obFullScreenSize = CGPointMake(winSize.width, winSize.height);
|
||||
m_obHalfScreenSize = ccpMult(m_obFullScreenSize, 0.5f);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCFollow *CCFollow::initWithTarget(CCNode *pFollowedNode, CGRect rect)
|
||||
bool CCFollow::initWithTarget(CCNode *pFollowedNode, CGRect rect)
|
||||
{
|
||||
assert(pFollowedNode != NULL);
|
||||
pFollowedNode->retain();
|
||||
m_pobFollowedNode = pFollowedNode;
|
||||
m_bBoundarySet = true;
|
||||
|
@ -265,7 +268,7 @@ CCFollow *CCFollow::initWithTarget(CCNode *pFollowedNode, CGRect rect)
|
|||
{
|
||||
m_bBoundaryFullyCovered = true;
|
||||
}
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
NSObject *CCFollow::copyWithZone(NSZone *pZone)
|
||||
{
|
||||
|
|
|
@ -97,12 +97,12 @@ CCActionManager::~CCActionManager(void)
|
|||
gSharedManager = NULL;
|
||||
}
|
||||
|
||||
CCActionManager* CCActionManager::init(void)
|
||||
bool CCActionManager::init(void)
|
||||
{
|
||||
CCScheduler::getSharedScheduler()->scheduleUpdateForTarget(this, 0, false);
|
||||
m_pTargets = NULL;
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
// private
|
||||
|
|
|
@ -50,10 +50,14 @@ namespace cocos2d{
|
|||
CCOrbitCamera * CCOrbitCamera::actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX)
|
||||
{
|
||||
CCOrbitCamera * pRet = new CCOrbitCamera();
|
||||
pRet->initWithDuration(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX);
|
||||
if(pRet->initWithDuration(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCX_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NSObject * CCOrbitCamera::copyWithZone(NSZone *pZone)
|
||||
{
|
||||
|
@ -75,7 +79,7 @@ namespace cocos2d{
|
|||
return pRet;
|
||||
}
|
||||
|
||||
CCOrbitCamera * CCOrbitCamera::initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX)
|
||||
bool CCOrbitCamera::initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX)
|
||||
{
|
||||
if ( CCIntervalAction::initWithDuration(t) )
|
||||
{
|
||||
|
@ -88,9 +92,9 @@ namespace cocos2d{
|
|||
|
||||
m_fRadDeltaZ = (CGFloat)CC_DEGREES_TO_RADIANS(deltaAngleZ);
|
||||
m_fRadDeltaX = (CGFloat)CC_DEGREES_TO_RADIANS(deltaAngleX);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCOrbitCamera::startWithTarget(CCNode *pTarget)
|
||||
|
|
|
@ -131,10 +131,10 @@ namespace cocos2d {
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCFlipX *CCFlipX::initWithFlipX(bool x)
|
||||
bool CCFlipX::initWithFlipX(bool x)
|
||||
{
|
||||
m_bFlipX = x;
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
void CCFlipX::startWithTarget(CCNode *pTarget)
|
||||
{
|
||||
|
@ -176,10 +176,10 @@ namespace cocos2d {
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCFlipY * CCFlipY::initWithFlipY(bool y)
|
||||
bool CCFlipY::initWithFlipY(bool y)
|
||||
{
|
||||
m_bFlipY = y;
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCFlipY::startWithTarget(CCNode *pTarget)
|
||||
|
@ -222,10 +222,10 @@ namespace cocos2d {
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCPlace * CCPlace::initWithPosition(CGPoint pos)
|
||||
bool CCPlace::initWithPosition(CGPoint pos)
|
||||
{
|
||||
m_tPosition = pos;
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
NSObject * CCPlace::copyWithZone(NSZone *pZone)
|
||||
|
@ -267,10 +267,10 @@ namespace cocos2d {
|
|||
|
||||
return pCallFunc;
|
||||
}
|
||||
CCCallFunc * CCCallFunc::initWithTarget(SelectorProtocol* pSelectorTarget)
|
||||
bool CCCallFunc::initWithTarget(SelectorProtocol* pSelectorTarget)
|
||||
{
|
||||
m_pSelectorTarget = pSelectorTarget;
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
NSObject * CCCallFunc::copyWithZone(cocos2d::NSZone *pZone)
|
||||
|
@ -327,19 +327,24 @@ namespace cocos2d {
|
|||
CCCallFuncND * CCCallFuncND::actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncND selector, void* d)
|
||||
{
|
||||
CCCallFuncND* pRet = new CCCallFuncND();
|
||||
pRet->initWithTarget(pSelectorTarget, selector, d);
|
||||
if (pRet->initWithTarget(pSelectorTarget, selector, d))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCX_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCCallFuncND * CCCallFuncND::initWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncND selector, void* d)
|
||||
bool CCCallFuncND::initWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncND selector, void* d)
|
||||
{
|
||||
if( CCCallFunc::initWithTarget(pSelectorTarget) )
|
||||
{
|
||||
m_pData = d;
|
||||
m_pCallFuncND = selector;
|
||||
return true;
|
||||
}
|
||||
return this;
|
||||
return false;
|
||||
}
|
||||
|
||||
NSObject * CCCallFuncND::copyWithZone(NSZone* zone)
|
||||
|
|
|
@ -442,11 +442,12 @@ CCRepeatForever *CCRepeatForever::actionWithAction(CCIntervalAction *pAction)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CCRepeatForever *CCRepeatForever::initWithAction(CCIntervalAction *pAction)
|
||||
bool CCRepeatForever::initWithAction(CCIntervalAction *pAction)
|
||||
{
|
||||
assert(pAction != NULL);
|
||||
pAction->retain();
|
||||
m_pOther = pAction;
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
NSObject* CCRepeatForever::copyWithZone(NSZone *pZone)
|
||||
{
|
||||
|
|
|
@ -42,15 +42,19 @@ CCAtlasNode::~CCAtlasNode()
|
|||
|
||||
CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, int tileWidth, int tileHeight, int itemsToRender)
|
||||
{
|
||||
CCAtlasNode * pAtlasNode = new CCAtlasNode();
|
||||
pAtlasNode->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender);
|
||||
pAtlasNode->autorelease();
|
||||
return pAtlasNode;
|
||||
CCAtlasNode * pRet = new CCAtlasNode();
|
||||
if (pRet->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCX_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCAtlasNode * CCAtlasNode::initWithTileFile(const char *tile, int tileWidth, int tileHeight, int itemsToRender)
|
||||
bool CCAtlasNode::initWithTileFile(const char *tile, int tileWidth, int tileHeight, int itemsToRender)
|
||||
{
|
||||
|
||||
assert(tile != NULL);
|
||||
m_nItemWidth = tileWidth;
|
||||
m_nItemHeight = tileHeight;
|
||||
|
||||
|
@ -73,7 +77,7 @@ CCAtlasNode * CCAtlasNode::initWithTileFile(const char *tile, int tileWidth, int
|
|||
this->calculateMaxItems();
|
||||
this->calculateTexCoordsSteps();
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
void setSpeed(float fSpeed) { m_fSpeed = fSpeed; }
|
||||
|
||||
// initializes the action
|
||||
CCSpeed* initWithAction(CCIntervalAction *pAction, float fRate);
|
||||
bool initWithAction(CCIntervalAction *pAction, float fRate);
|
||||
/* CCSpeed* initWithAction(CCRepeatForever *pAction, float fRate);*/
|
||||
|
||||
virtual NSObject* copyWithZone(NSZone *pZone);
|
||||
|
@ -180,10 +180,10 @@ public:
|
|||
void setBoudarySet(bool bValue) { m_bBoundarySet = bValue; }
|
||||
|
||||
// initializes the action
|
||||
CCFollow* initWithTarget(CCNode *pFollowedNode);
|
||||
bool initWithTarget(CCNode *pFollowedNode);
|
||||
|
||||
// initializes the action with a set boundary
|
||||
CCFollow* initWithTarget(CCNode *pFollowedNode, CGRect rect);
|
||||
bool initWithTarget(CCNode *pFollowedNode, CGRect rect);
|
||||
|
||||
virtual NSObject* copyWithZone(NSZone *pZone);
|
||||
virtual void step(ccTime dt);
|
||||
|
|
|
@ -49,7 +49,7 @@ class CCX_DLL CCActionManager : public NSObject, public SelectorProtocol
|
|||
public:
|
||||
CCActionManager(void);
|
||||
~CCActionManager(void);
|
||||
CCActionManager* init(void);
|
||||
bool init(void);
|
||||
|
||||
// actions
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
static CCAtlasNode * atlasWithTileFile(const char* tile,int tileWidth, int tileHeight, int itemsToRender);
|
||||
|
||||
/** initializes an CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/
|
||||
CCAtlasNode * initWithTileFile(const char* tile, int tileWidth, int tileHeight, int itemsToRender);
|
||||
bool initWithTileFile(const char* tile, int tileWidth, int tileHeight, int itemsToRender);
|
||||
|
||||
/** updates the Atlas (indexed vertex array).
|
||||
* Shall be overriden in subclasses
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace cocos2d{
|
|||
/** allocates a CCBitmapFontConfiguration with a FNT file */
|
||||
static CCBitmapFontConfiguration * configurationWithFNTFile(const char *FNTfile);
|
||||
/** initializes a BitmapFontConfiguration with a FNT file */
|
||||
CCBitmapFontConfiguration * initWithFNTfile(const char *FNTfile);
|
||||
bool initWithFNTfile(const char *FNTfile);
|
||||
private:
|
||||
void parseConfigFile(const char *controlFile);
|
||||
void parseCharacterDefinition(std::string line, ccBitmapFontDef *characterDefinition);
|
||||
|
@ -156,7 +156,7 @@ namespace cocos2d{
|
|||
/** creates a bitmap font altas with an initial string and the FNT file */
|
||||
static CCBitmapFontAtlas * bitmapFontAtlasWithString(const char *str, const char *fntFile);
|
||||
/** init a bitmap font altas with an initial string and the FNT file */
|
||||
CCBitmapFontAtlas * initWithString(const char *str, const char *fntFile);
|
||||
bool initWithString(const char *str, const char *fntFile);
|
||||
/** updates the font chars based on the string to render */
|
||||
void createFontChars();
|
||||
// super method
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace cocos2d {
|
|||
/** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */
|
||||
static CCOrbitCamera * actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
|
||||
/** initializes a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */
|
||||
CCOrbitCamera * initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
|
||||
bool initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX);
|
||||
/** positions the camera according to spherical coordinates */
|
||||
void sphericalRadius(float *r, float *zenith, float *azimuth);
|
||||
// super methods
|
||||
|
|
|
@ -198,7 +198,7 @@ and when to execute the Scenes.
|
|||
class CCX_DLL CCDirector : public NSObject
|
||||
{
|
||||
public:
|
||||
virtual CCDirector* init(void);
|
||||
virtual bool init(void);
|
||||
virtual ~CCDirector(void);
|
||||
CCDirector(void) {}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace cocos2d {
|
|||
virtual ~CCFlipX(){}
|
||||
|
||||
static CCFlipX * actionWithFlipX(bool x);
|
||||
CCFlipX * initWithFlipX(bool x);
|
||||
bool initWithFlipX(bool x);
|
||||
//super method
|
||||
virtual void startWithTarget(CCNode *pTarget);
|
||||
virtual CCFiniteTimeAction * reverse(void);
|
||||
|
@ -122,7 +122,7 @@ namespace cocos2d {
|
|||
virtual ~CCFlipY(){}
|
||||
|
||||
static CCFlipY * actionWithFlipY(bool y);
|
||||
CCFlipY * initWithFlipY(bool y);
|
||||
bool initWithFlipY(bool y);
|
||||
//super method
|
||||
virtual void startWithTarget(CCNode *pTarget);
|
||||
virtual CCFiniteTimeAction * reverse(void);
|
||||
|
@ -142,7 +142,7 @@ namespace cocos2d {
|
|||
/** creates a Place action with a position */
|
||||
static CCPlace * actionWithPosition(CGPoint pos);
|
||||
/** Initializes a Place action with a position */
|
||||
CCPlace * initWithPosition(CGPoint pos);
|
||||
bool initWithPosition(CGPoint pos);
|
||||
//super method
|
||||
virtual void startWithTarget(CCNode *pTarget);
|
||||
virtual NSObject* copyWithZone(NSZone *pZone);
|
||||
|
@ -164,7 +164,7 @@ namespace cocos2d {
|
|||
{
|
||||
}
|
||||
static CCCallFunc * actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFunc selector);
|
||||
virtual CCCallFunc * initWithTarget(SelectorProtocol* pSelectorTarget);
|
||||
virtual bool initWithTarget(SelectorProtocol* pSelectorTarget);
|
||||
virtual void execute();
|
||||
//super method
|
||||
virtual void startWithTarget(CCNode *pTarget);
|
||||
|
@ -216,7 +216,7 @@ namespace cocos2d {
|
|||
/** creates the action with the callback and the data to pass as an argument */
|
||||
static CCCallFuncND * actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncND selector, void* d);
|
||||
/** initializes the action with the callback and the data to pass as an argument */
|
||||
CCCallFuncND * initWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncND selector, void* d);
|
||||
virtual bool initWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncND selector, void* d);
|
||||
// super method
|
||||
virtual NSObject* copyWithZone(NSZone *pZone);
|
||||
virtual void execute();
|
||||
|
|
|
@ -148,7 +148,7 @@ public:
|
|||
CCRepeatForever(){}
|
||||
virtual ~CCRepeatForever();
|
||||
|
||||
CCRepeatForever* initWithAction(CCIntervalAction *pAction);
|
||||
bool initWithAction(CCIntervalAction *pAction);
|
||||
virtual NSObject* copyWithZone(NSZone *pZone);
|
||||
virtual void startWithTarget(CCNode* pTarget);
|
||||
virtual void step(ccTime dt);
|
||||
|
|
|
@ -47,9 +47,9 @@ namespace cocos2d{
|
|||
/** creates a CCLabel from a fontname and font size */
|
||||
static CCLabel * labelWithString(const char *label, const char *fontName, float fontSize);
|
||||
/** initializes the CCLabel with a font name, alignment, dimension and font size */
|
||||
CCLabel * initWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize);
|
||||
bool initWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize);
|
||||
/** initializes the CCLabel with a font name and font size */
|
||||
CCLabel * initWithString(const char *label, const char *fontName, float fontSize);
|
||||
bool initWithString(const char *label, const char *fontName, float fontSize);
|
||||
|
||||
/** changes the string to render
|
||||
* @warning Changing the string is as expensive as creating a new CCLabel. To obtain better performance use CCLabelAtlas
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace cocos2d{
|
|||
static CCLabelAtlas * labelAtlasWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
||||
|
||||
/** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
||||
CCLabelAtlas * initWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
||||
bool initWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
||||
// super methods
|
||||
virtual void updateAtlasValues();
|
||||
virtual void setString(const char *label);
|
||||
|
|
|
@ -110,9 +110,9 @@ public:
|
|||
static CCColorLayer * layerWithColor(ccColor4B color);
|
||||
|
||||
/** initializes a CCLayer with color, width and height */
|
||||
CCColorLayer * initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height);
|
||||
bool initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height);
|
||||
/** initializes a CCLayer with color. Width and height are the window size. */
|
||||
CCColorLayer * initWithColor(ccColor4B color);
|
||||
bool initWithColor(ccColor4B color);
|
||||
|
||||
/** change width */
|
||||
void changeWidth(GLfloat w);
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
/** creates a CCMultiplexLayer with one or more layers using a variable argument list. */
|
||||
static CCMultiplexLayer * layerWithLayers(CCLayer* layer, ... );
|
||||
/** initializes a MultiplexLayer with one or more layers using a variable argument list. */
|
||||
CCMultiplexLayer * initWithLayers(CCLayer* layer, va_list params);
|
||||
bool initWithLayers(CCLayer* layer, va_list params);
|
||||
/** switches to a certain layer indexed by n.
|
||||
The current (old) layer will be removed from it's parent with 'cleanup:YES'.
|
||||
*/
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace cocos2d{
|
|||
static CCMenu* menuWithItems(CCMenuItem* item, ...);
|
||||
|
||||
/** initializes a CCMenu with it's items */
|
||||
CCMenu * initWithItems(CCMenuItem* item, va_list args);
|
||||
bool initWithItems(CCMenuItem* item, va_list args);
|
||||
|
||||
/** align items vertically */
|
||||
void alignItemsVertically();
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace cocos2d{
|
|||
/** Creates a CCMenuItem with a target/selector */
|
||||
static CCMenuItem * itemWithTarget(SelectorProtocol *rec, SEL_MunuHandler selector);
|
||||
/** Initializes a CCMenuItem with a target/selector */
|
||||
CCMenuItem * initWithTarget(SelectorProtocol *rec, SEL_MunuHandler selector);
|
||||
bool initWithTarget(SelectorProtocol *rec, SEL_MunuHandler selector);
|
||||
/** Returns the outside box */
|
||||
CGRect rect();
|
||||
/** Activate the item */
|
||||
|
@ -91,7 +91,7 @@ namespace cocos2d{
|
|||
/** creates a CCMenuItemLabel with a Label, target and selector */
|
||||
static CCMenuItemLabel * itemWithLabel(CCNode*label, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
/** initializes a CCMenuItemLabel with a Label, target and selector */
|
||||
CCMenuItemLabel * initWithLabel(CCNode* label, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
bool initWithLabel(CCNode* label, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
/** sets a new string to the inner label */
|
||||
void setString(const char * label);
|
||||
// super methods
|
||||
|
@ -127,7 +127,7 @@ namespace cocos2d{
|
|||
/** creates a menu item from a string and atlas. Use it with MenuItemToggle */
|
||||
static CCMenuItemAtlasFont* itemFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
/** initializes a menu item from a string and atlas with a target/selector */
|
||||
CCMenuItemAtlasFont* initFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
bool initFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
};
|
||||
|
||||
/** A CCMenuItemFont
|
||||
|
@ -151,7 +151,7 @@ namespace cocos2d{
|
|||
/** creates a menu item from a string with a target/selector */
|
||||
static CCMenuItemFont * itemFromString(const char *value, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
/** initializes a menu item from a string with a target/selector */
|
||||
CCMenuItemFont * initFromString(const char *value, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
bool initFromString(const char *value, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
};
|
||||
|
||||
/** CCMenuItemSprite accepts CCNode<CCRGBAProtocol> objects as items.
|
||||
|
@ -184,7 +184,7 @@ namespace cocos2d{
|
|||
/** creates a menu item with a normal,selected and disabled image with target/selector */
|
||||
static CCMenuItemSprite * itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
/** initializes a menu item with a normal, selected and disabled image with target/selector */
|
||||
CCMenuItemSprite * initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
bool initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
// super methods
|
||||
virtual void draw();
|
||||
virtual void setColor(ccColor3B color){}
|
||||
|
@ -217,7 +217,7 @@ namespace cocos2d{
|
|||
/** creates a menu item with a normal,selected and disabled image with target/selector */
|
||||
static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
/** initializes a menu item with a normal, selected and disabled image with target/selector */
|
||||
CCMenuItemImage* initFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
bool initFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MunuHandler selector);
|
||||
// super methods
|
||||
virtual void setColor(ccColor3B color);
|
||||
virtual ccColor3B getColor();
|
||||
|
@ -247,7 +247,7 @@ namespace cocos2d{
|
|||
/** creates a menu item from a list of items with a target/selector */
|
||||
static CCMenuItemToggle* itemWithTarget(SelectorProtocol* target, SEL_MunuHandler selector, CCMenuItem* item, ...);
|
||||
/** initializes a menu item from a list of items with a target selector */
|
||||
CCMenuItemToggle* initWithTarget(SelectorProtocol* target, SEL_MunuHandler selector, CCMenuItem* item, va_list args);
|
||||
bool initWithTarget(SelectorProtocol* target, SEL_MunuHandler selector, CCMenuItem* item, va_list args);
|
||||
/** return the selected item */
|
||||
CCMenuItem* selectedItem();
|
||||
// super methods
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
* if back is TRUE then the effect is reversed to appear as if the incoming
|
||||
* scene is being turned from left over the outgoing scene
|
||||
*/
|
||||
virtual CCPageTurnTransition* initWithDuration(ccTime t,CCScene* scene,bool backwards);
|
||||
virtual bool initWithDuration(ccTime t,CCScene* scene,bool backwards);
|
||||
|
||||
CCIntervalAction* actionWithSize(ccGridSize vector);
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace cocos2d {
|
|||
CCRibbonSegment(){}
|
||||
virtual ~CCRibbonSegment();
|
||||
char * description();
|
||||
CCRibbonSegment * init();
|
||||
bool init();
|
||||
void reset();
|
||||
void draw(float curTime, float fadeTime, ccColor4B color);
|
||||
};
|
||||
|
|
|
@ -197,7 +197,7 @@ public:
|
|||
static CCSprite* spriteWithSpriteSheet(CCSpriteSheet *pSpriteSheet, CGRect rect, CGPoint offset);
|
||||
|
||||
public:
|
||||
CCSprite* init(void);
|
||||
bool init(void);
|
||||
virtual ~CCSprite(void);
|
||||
CCSprite() {}
|
||||
|
||||
|
@ -242,33 +242,33 @@ public:
|
|||
The rect used will be the size of the texture.
|
||||
The offset will be (0,0).
|
||||
*/
|
||||
CCSprite* initWithTexture(CCTexture2D *pTexture);
|
||||
bool initWithTexture(CCTexture2D *pTexture);
|
||||
|
||||
/** Initializes an sprite with a texture and a rect.
|
||||
The offset will be (0,0).
|
||||
*/
|
||||
CCSprite* initWithTexture(CCTexture2D *pTexture, CGRect rect);
|
||||
bool initWithTexture(CCTexture2D *pTexture, CGRect rect);
|
||||
|
||||
// Initializes an sprite with an sprite frame.
|
||||
CCSprite* initWithSpriteFrame(CCSpriteFrame *pSpriteFrame);
|
||||
bool initWithSpriteFrame(CCSpriteFrame *pSpriteFrame);
|
||||
|
||||
/** Initializes an sprite with an sprite frame name.
|
||||
An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name.
|
||||
If the CCSpriteFrame doesn't exist it will raise an exception.
|
||||
@since v0.9
|
||||
*/
|
||||
CCSprite* initWithSpriteFrameName(const char *pszSpriteFrameName);
|
||||
bool initWithSpriteFrameName(const char *pszSpriteFrameName);
|
||||
|
||||
/** Initializes an sprite with an image filename.
|
||||
The rect used will be the size of the image.
|
||||
The offset will be (0,0).
|
||||
*/
|
||||
CCSprite* initWithFile(const char *pszFilename);
|
||||
bool initWithFile(const char *pszFilename);
|
||||
|
||||
/** Initializes an sprite with an image filename, and a rect.
|
||||
The offset will be (0,0).
|
||||
*/
|
||||
CCSprite* initWithFile(const char *pszFilename, CGRect rect);
|
||||
bool initWithFile(const char *pszFilename, CGRect rect);
|
||||
|
||||
/** Initializes an sprite with a CGImageRef
|
||||
@deprecated Use spriteWithCGImage:key: instead. Will be removed in v1.0 final
|
||||
|
@ -284,7 +284,7 @@ public:
|
|||
// CCSprite* initWithCGImage(CGImageRef pImage, const char *pszKey);
|
||||
|
||||
// Initializes an sprite with an CCSpriteSheet and a rect
|
||||
CCSprite* initWithSpriteSheet(CCSpriteSheet *pSpriteSheet, CGRect rect);
|
||||
bool initWithSpriteSheet(CCSpriteSheet *pSpriteSheet, CGRect rect);
|
||||
|
||||
// sprite sheet methods
|
||||
|
||||
|
|
|
@ -95,12 +95,12 @@ public:
|
|||
/** Initializes a CCSpriteFrame with a texture, rect and offset.
|
||||
It is assumed that the frame was not trimmed.
|
||||
*/
|
||||
CCSpriteFrame* initWithTexture(CCTexture2D* pobTexture, CGRect rect, CGPoint offset);
|
||||
bool initWithTexture(CCTexture2D* pobTexture, CGRect rect, CGPoint offset);
|
||||
|
||||
/** Initializes a CCSpriteFrame with a texture, rect, offset and originalSize.
|
||||
The originalSize is the size in pixels of the frame before being trimmed.
|
||||
*/
|
||||
CCSpriteFrame* initWithTexture(CCTexture2D* pobTexture, CGRect rect, CGPoint offset, CGSize originalSize);
|
||||
bool initWithTexture(CCTexture2D* pobTexture, CGRect rect, CGPoint offset, CGSize originalSize);
|
||||
protected:
|
||||
CGRect m_obRect;
|
||||
CGPoint m_obOffset;
|
||||
|
@ -154,18 +154,18 @@ public:
|
|||
/** Initializes a CCAnimation with a name
|
||||
@since v0.99.3
|
||||
*/
|
||||
CCAnimation* initWithName(const char *pszName);
|
||||
bool initWithName(const char *pszName);
|
||||
|
||||
/** Initializes a CCAnimation with a name and frames
|
||||
@since v0.99.3
|
||||
*/
|
||||
CCAnimation* initWithName(const char *pszName, NSArray<CCSpriteFrame*> *pFrames);
|
||||
bool initWithName(const char *pszName, NSArray<CCSpriteFrame*> *pFrames);
|
||||
|
||||
// Initializes a CCAnimation with a name and delay between frames.
|
||||
CCAnimation* initWithName(const char *pszName, float fDelay);
|
||||
bool initWithName(const char *pszName, float fDelay);
|
||||
|
||||
// Initializes a CCAnimation with a name, delay and an array of CCSpriteFrames.
|
||||
CCAnimation* initWithName(const char *pszName, float fDelay, NSArray<CCSpriteFrame*> *pFrames);
|
||||
bool initWithName(const char *pszName, float fDelay, NSArray<CCSpriteFrame*> *pFrames);
|
||||
|
||||
// adds a frame to a CCAnimation
|
||||
void addFrame(CCSpriteFrame *pFrame);
|
||||
|
|
|
@ -48,7 +48,7 @@ class CCSprite;
|
|||
class CCSpriteFrameCache : public NSObject
|
||||
{
|
||||
public:
|
||||
CCSpriteFrameCache* init(void);
|
||||
bool init(void);
|
||||
~CCSpriteFrameCache(void);
|
||||
|
||||
/*Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames.
|
||||
|
|
|
@ -59,13 +59,13 @@ public:
|
|||
/** initializes a CCSpriteSheet with a texture2d and capacity of children.
|
||||
The capacity will be increased in 33% in runtime if it run out of space.
|
||||
*/
|
||||
CCSpriteSheet* initWithTexture(CCTexture2D *pobTexture, unsigned int uCapacity);
|
||||
bool initWithTexture(CCTexture2D *pobTexture, unsigned int uCapacity);
|
||||
|
||||
/** initializes a CCSpriteSheet with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
|
||||
The capacity will be increased in 33% in runtime if it run out of space.
|
||||
The file will be loaded using the TextureMgr.
|
||||
*/
|
||||
CCSpriteSheet* initWithFile(const char *pszFileImage, unsigned int uCapacity);
|
||||
bool initWithFile(const char *pszFileImage, unsigned int uCapacity);
|
||||
|
||||
void increaseAtlasCapacity(void);
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public:
|
|||
char * description(void);
|
||||
|
||||
/** Intializes with a texture2d with data */
|
||||
CCTexture2D * initWithData(const void* data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, CGSize contentSize);
|
||||
bool initWithData(const void* data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, CGSize contentSize);
|
||||
|
||||
/**
|
||||
Drawing extensions to make it easy to draw basic quads using a CCTexture2D object.
|
||||
|
@ -130,16 +130,16 @@ public:
|
|||
Note that RGBA type textures will have their alpha premultiplied - use the blending mode (GL_ONE, GL_ONE_MINUS_SRC_ALPHA).
|
||||
*/
|
||||
/** Initializes a texture from a UIImage object */
|
||||
CCTexture2D * initWithImage(UIImage * uiImage);
|
||||
bool initWithImage(UIImage * uiImage);
|
||||
|
||||
/**
|
||||
Extensions to make it easy to create a CCTexture2D object from a string of text.
|
||||
Note that the generated textures are of type A8 - use the blending mode (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).
|
||||
*/
|
||||
/** Initializes a texture from a string with dimensions, alignment, font name and font size */
|
||||
CCTexture2D * initWithString(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize);
|
||||
bool initWithString(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize);
|
||||
/** Initializes a texture from a string with font name and font size */
|
||||
CCTexture2D * initWithString(const char *text, const char *fontName, float fontSize);
|
||||
bool initWithString(const char *text, const char *fontName, float fontSize);
|
||||
|
||||
#ifdef _POWERVR_SUPPORT_
|
||||
/**
|
||||
|
@ -147,9 +147,9 @@ public:
|
|||
Note that the generated textures don't have their alpha premultiplied - use the blending mode (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).
|
||||
*/
|
||||
/** Initializes a texture from a PVRTC buffer */
|
||||
CCTexture2D * initWithPVRTCData(const void* data, int level, int bpp, bool hasAlpha, int length);
|
||||
bool initWithPVRTCData(const void* data, int level, int bpp, bool hasAlpha, int length);
|
||||
/** Initializes a texture from a PVRTC file */
|
||||
CCTexture2D * initWithPVRTCFile(const char* file);
|
||||
bool initWithPVRTCFile(const char* file);
|
||||
#endif
|
||||
|
||||
/** sets the min filter, mag filter, wrap s and wrap t texture parameters.
|
||||
|
@ -204,7 +204,7 @@ public:
|
|||
static CCTexture2DPixelFormat defaultAlphaPixelFormat();
|
||||
|
||||
private:
|
||||
CCTexture2D * initPremultipliedATextureWithImage(UIImage * image, unsigned int pixelsWide, unsigned int pixelsHigh);
|
||||
bool initPremultipliedATextureWithImage(UIImage * image, unsigned int pixelsWide, unsigned int pixelsHigh);
|
||||
|
||||
};
|
||||
}//namespace cocos2d
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
*
|
||||
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
||||
*/
|
||||
CCTextureAtlas * initWithFile(const char* file, unsigned int capacity);
|
||||
bool initWithFile(const char* file, unsigned int capacity);
|
||||
|
||||
/** creates a TextureAtlas with a previously initialized Texture2D object, and
|
||||
* with an initial capacity for n Quads.
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
*
|
||||
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
||||
*/
|
||||
CCTextureAtlas * initWithTexture(CCTexture2D *texture, unsigned int capacity);
|
||||
bool initWithTexture(CCTexture2D *texture, unsigned int capacity);
|
||||
|
||||
/** updates a Quad (texture, vertex and color) at a certain index
|
||||
* index must be between 0 and the atlas capacity - 1
|
||||
|
|
|
@ -91,7 +91,7 @@ class CCX_DLL CCTouchDispatcher : public NSObject, public EGLTouchDelegate
|
|||
{
|
||||
public:
|
||||
~CCTouchDispatcher();
|
||||
CCTouchDispatcher* init(void);
|
||||
bool init(void);
|
||||
CCTouchDispatcher() {}
|
||||
|
||||
public:
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
static CCTransitionScene * transitionWithDuration(ccTime t, CCScene *scene);
|
||||
|
||||
/** initializes a transition with duration and incoming scene */
|
||||
virtual CCTransitionScene * initWithDuration(ccTime t,CCScene* scene);
|
||||
virtual bool initWithDuration(ccTime t,CCScene* scene);
|
||||
|
||||
/** called after the transition finishes */
|
||||
void finish(void);
|
||||
|
@ -117,7 +117,7 @@ public:
|
|||
/** creates a base transition with duration and incoming scene */
|
||||
static CCOrientedTransitionScene * transitionWithDuration(ccTime t,CCScene* scene, tOrientation orientation);
|
||||
/** initializes a transition with duration and incoming scene */
|
||||
virtual CCOrientedTransitionScene * initWithDuration(ccTime t,CCScene* scene,tOrientation orientation);
|
||||
virtual bool initWithDuration(ccTime t,CCScene* scene,tOrientation orientation);
|
||||
};
|
||||
|
||||
/** CCRotoZoomTransition:
|
||||
|
@ -408,9 +408,9 @@ public:
|
|||
*/
|
||||
static CCFadeTransition* transitionWithDuration(ccTime duration,CCScene* scene, ccColor3B color = ccBLACK);
|
||||
/** initializes the transition with a duration and with an RGB color */
|
||||
virtual CCFadeTransition* initWithDuration(ccTime t, CCScene*scene ,ccColor3B color);
|
||||
virtual bool initWithDuration(ccTime t, CCScene*scene ,ccColor3B color);
|
||||
|
||||
virtual CCFadeTransition * initWithDuration(ccTime t,CCScene* scene);
|
||||
virtual bool initWithDuration(ccTime t,CCScene* scene);
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
};
|
||||
|
|
|
@ -80,15 +80,20 @@ namespace cocos2d{
|
|||
CCBitmapFontConfiguration * CCBitmapFontConfiguration::configurationWithFNTFile(const char *FNTfile)
|
||||
{
|
||||
CCBitmapFontConfiguration * pRet = new CCBitmapFontConfiguration();
|
||||
pRet->initWithFNTfile(FNTfile);
|
||||
if (pRet->initWithFNTfile(FNTfile))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCBitmapFontConfiguration * CCBitmapFontConfiguration::initWithFNTfile(const char *FNTfile)
|
||||
CCX_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
}
|
||||
bool CCBitmapFontConfiguration::initWithFNTfile(const char *FNTfile)
|
||||
{
|
||||
assert(FNTfile != NULL && strlen(FNTfile)!=0);
|
||||
m_pKerningDictionary = NULL;
|
||||
this->parseConfigFile(FNTfile);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
CCBitmapFontConfiguration::~CCBitmapFontConfiguration()
|
||||
{
|
||||
|
@ -357,8 +362,9 @@ namespace cocos2d{
|
|||
CCX_SAFE_DELETE(pRet)
|
||||
return NULL;
|
||||
}
|
||||
CCBitmapFontAtlas * CCBitmapFontAtlas::initWithString(const char *theString, const char *fntFile)
|
||||
bool CCBitmapFontAtlas::initWithString(const char *theString, const char *fntFile)
|
||||
{
|
||||
assert(theString != NULL);
|
||||
CCX_SAFE_RELEASE(m_pConfiguration);// allow re-init
|
||||
m_pConfiguration = FNTConfigLoadFile(fntFile);
|
||||
m_pConfiguration->retain();
|
||||
|
@ -372,9 +378,9 @@ namespace cocos2d{
|
|||
m_bIsOpacityModifyRGB = m_pobTextureAtlas->getTexture()->getHasPremultipliedAlpha();
|
||||
m_tAnchorPoint = ccp(0.5f, 0.5f);
|
||||
this->setString(theString);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
CCBitmapFontAtlas::~CCBitmapFontAtlas()
|
||||
{
|
||||
|
|
|
@ -50,8 +50,9 @@ namespace cocos2d{
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CCLabel * CCLabel::initWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
|
||||
bool CCLabel::initWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
|
||||
{
|
||||
assert(label != NULL);
|
||||
if (CCSprite::init())
|
||||
{
|
||||
m_tDimensions = dimensions;
|
||||
|
@ -59,21 +60,22 @@ namespace cocos2d{
|
|||
m_sFontName = fontName;
|
||||
m_fFontSize = fontSize;
|
||||
this->setString(label);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
CCLabel * CCLabel::initWithString(const char *label, const char *fontName, float fontSize)
|
||||
bool CCLabel::initWithString(const char *label, const char *fontName, float fontSize)
|
||||
{
|
||||
assert(label != NULL);
|
||||
if (CCSprite::init())
|
||||
{
|
||||
m_tDimensions = CGSizeZero;
|
||||
m_sFontName = fontName;
|
||||
m_fFontSize = fontSize;
|
||||
this->setString(label);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
void CCLabel::setString(const char *label)
|
||||
{
|
||||
|
|
|
@ -37,15 +37,16 @@ namespace cocos2d{
|
|||
CCX_SAFE_DELETE(pRet)
|
||||
return NULL;
|
||||
}
|
||||
CCLabelAtlas * CCLabelAtlas::initWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap)
|
||||
bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap)
|
||||
{
|
||||
assert(label != NULL);
|
||||
if (CCAtlasNode::initWithTileFile(charMapFile, itemWidth, itemHeight, strlen(label)))
|
||||
{
|
||||
m_cMapStartChar = startCharMap;
|
||||
this->setString(label);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
//CCLabelAtlas - Atlas generation
|
||||
|
|
|
@ -223,19 +223,27 @@ void CCColorLayer::setBlendFunc(ccBlendFunc var)
|
|||
CCColorLayer * CCColorLayer::layerWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height)
|
||||
{
|
||||
CCColorLayer * pLayer = new CCColorLayer();
|
||||
pLayer->initWithColorWidthHeight(color,width,height);
|
||||
if( pLayer && pLayer->initWithColorWidthHeight(color,width,height))
|
||||
{
|
||||
pLayer->autorelease();
|
||||
return pLayer;
|
||||
}
|
||||
CCX_SAFE_DELETE(pLayer);
|
||||
return NULL;
|
||||
}
|
||||
CCColorLayer * CCColorLayer::layerWithColor(ccColor4B color)
|
||||
{
|
||||
CCColorLayer * pLayer = new CCColorLayer();
|
||||
pLayer->initWithColor(color);
|
||||
if(pLayer && pLayer->initWithColor(color))
|
||||
{
|
||||
pLayer->autorelease();
|
||||
return pLayer;
|
||||
}
|
||||
CCX_SAFE_DELETE(pLayer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCColorLayer* CCColorLayer::initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height)
|
||||
bool CCColorLayer::initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height)
|
||||
{
|
||||
// default blend function
|
||||
m_tBlendFunc.src = CC_BLEND_SRC;
|
||||
|
@ -247,17 +255,20 @@ CCColorLayer* CCColorLayer::initWithColorWidthHeight(ccColor4B color, GLfloat wi
|
|||
m_cOpacity = color.a;
|
||||
|
||||
for (unsigned int i=0; i<sizeof(m_pSquareVertices) / sizeof(m_pSquareVertices[0]); i++ )
|
||||
{
|
||||
m_pSquareVertices[i] = 0.0f;
|
||||
}
|
||||
|
||||
this->updateColor();
|
||||
this->setContentSize(CGSizeMake(width,height));
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCColorLayer * CCColorLayer::initWithColor(ccColor4B color)
|
||||
bool CCColorLayer::initWithColor(ccColor4B color)
|
||||
{
|
||||
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
||||
return this->initWithColorWidthHeight(color, s.width, s.height);
|
||||
this->initWithColorWidthHeight(color, s.width, s.height);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// override contentSize
|
||||
|
@ -349,14 +360,18 @@ CCMultiplexLayer * CCMultiplexLayer::layerWithLayers(CCLayer * layer, ...)
|
|||
va_start(args,layer);
|
||||
|
||||
CCMultiplexLayer * pMultiplexLayer = new CCMultiplexLayer();
|
||||
pMultiplexLayer->initWithLayers(layer, args);
|
||||
if(pMultiplexLayer && pMultiplexLayer->initWithLayers(layer, args))
|
||||
{
|
||||
pMultiplexLayer->autorelease();
|
||||
|
||||
va_end(args);
|
||||
return pMultiplexLayer;
|
||||
}
|
||||
va_end(args);
|
||||
CCX_SAFE_DELETE(pMultiplexLayer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCMultiplexLayer * CCMultiplexLayer::initWithLayers(CCLayer *layer, va_list params)
|
||||
bool CCMultiplexLayer::initWithLayers(CCLayer *layer, va_list params)
|
||||
{
|
||||
m_pLayers = new NSMutableArray<CCLayer*>(5);
|
||||
m_pLayers->retain();
|
||||
|
@ -372,7 +387,7 @@ CCMultiplexLayer * CCMultiplexLayer::initWithLayers(CCLayer *layer, va_list para
|
|||
m_nEnabledLayer = 0;
|
||||
this->addChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer));
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ CCPageTurnTransition * CCPageTurnTransition::transitionWithDuration(ccTime t, CC
|
|||
}
|
||||
|
||||
/** initializes a transition with duration and incoming scene */
|
||||
CCPageTurnTransition * CCPageTurnTransition::initWithDuration(ccTime t, CCScene *scene, bool backwards)
|
||||
bool CCPageTurnTransition::initWithDuration(ccTime t, CCScene *scene, bool backwards)
|
||||
{
|
||||
// XXX: needed before [super init]
|
||||
m_bBack = backwards;
|
||||
|
@ -57,7 +57,7 @@ CCPageTurnTransition * CCPageTurnTransition::initWithDuration(ccTime t, CCScene
|
|||
{
|
||||
// do something
|
||||
}
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCPageTurnTransition::sceneOrder()
|
||||
|
|
|
@ -45,9 +45,11 @@ enum {
|
|||
_Type* _Type::transitionWithDuration(ccTime t, CCScene* scene)\
|
||||
{\
|
||||
_Type* pScene = new _Type();\
|
||||
pScene->initWithDuration(t, scene);\
|
||||
if(pScene && pScene->initWithDuration(t, scene)){\
|
||||
pScene->autorelease();\
|
||||
return pScene;\
|
||||
return pScene;}\
|
||||
CCX_SAFE_DELETE(pScene);\
|
||||
return NULL;\
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,12 +66,16 @@ CCTransitionScene::~CCTransitionScene()
|
|||
CCTransitionScene * CCTransitionScene::transitionWithDuration(ccTime t, CCScene *scene)
|
||||
{
|
||||
CCTransitionScene * pScene = new CCTransitionScene();
|
||||
pScene->initWithDuration(t,scene);
|
||||
if(pScene && pScene->initWithDuration(t,scene))
|
||||
{
|
||||
pScene->autorelease();
|
||||
return pScene;
|
||||
}
|
||||
CCX_SAFE_DELETE(pScene);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCTransitionScene * CCTransitionScene::initWithDuration(ccTime t, CCScene *scene)
|
||||
bool CCTransitionScene::initWithDuration(ccTime t, CCScene *scene)
|
||||
{
|
||||
NSAssert( scene != NULL, "Argument scene must be non-nil");
|
||||
|
||||
|
@ -90,11 +96,11 @@ CCTransitionScene * CCTransitionScene::initWithDuration(ccTime t, CCScene *scene
|
|||
CCTouchDispatcher::getSharedDispatcher()->setDispatchEvents(false);
|
||||
this->sceneOrder();
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,13 +209,13 @@ CCOrientedTransitionScene * CCOrientedTransitionScene::transitionWithDuration(cc
|
|||
return pScene;
|
||||
}
|
||||
|
||||
CCOrientedTransitionScene * CCOrientedTransitionScene::initWithDuration(ccTime t, CCScene *scene, tOrientation orientation)
|
||||
bool CCOrientedTransitionScene::initWithDuration(ccTime t, CCScene *scene, tOrientation orientation)
|
||||
{
|
||||
if ( CCTransitionScene::initWithDuration(t, scene) )
|
||||
{
|
||||
m_eOrientation = orientation;
|
||||
}
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1034,7 +1040,7 @@ CCFadeTransition * CCFadeTransition::transitionWithDuration(ccTime duration, CCS
|
|||
return pTransition;
|
||||
}
|
||||
|
||||
CCFadeTransition * CCFadeTransition::initWithDuration(ccTime duration, CCScene *scene, ccColor3B color)
|
||||
bool CCFadeTransition::initWithDuration(ccTime duration, CCScene *scene, ccColor3B color)
|
||||
{
|
||||
if (CCTransitionScene::initWithDuration(duration, scene))
|
||||
{
|
||||
|
@ -1042,13 +1048,13 @@ CCFadeTransition * CCFadeTransition::initWithDuration(ccTime duration, CCScene *
|
|||
m_tColor.g = color.g;
|
||||
m_tColor.b = color.b;
|
||||
}
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCFadeTransition * CCFadeTransition::initWithDuration(ccTime t, CCScene *scene)
|
||||
bool CCFadeTransition::initWithDuration(ccTime t, CCScene *scene)
|
||||
{
|
||||
this->initWithDuration(t, scene, ccBLACK);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCFadeTransition :: onEnter()
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace cocos2d{
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CCMenu * CCMenu::initWithItems(CCMenuItem* item, va_list args)
|
||||
bool CCMenu::initWithItems(CCMenuItem* item, va_list args)
|
||||
{
|
||||
if (CCLayer::init())
|
||||
{
|
||||
|
@ -103,10 +103,10 @@ namespace cocos2d{
|
|||
|
||||
m_pSelectedItem = NULL;
|
||||
m_eState = kMenuStateWaiting;
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -54,14 +54,14 @@ namespace cocos2d{
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCMenuItem * CCMenuItem::initWithTarget(SelectorProtocol *rec, SEL_MunuHandler selector)
|
||||
bool CCMenuItem::initWithTarget(SelectorProtocol *rec, SEL_MunuHandler selector)
|
||||
{
|
||||
m_tAnchorPoint = ccp(0.5f, 0.5f);
|
||||
m_pListener = rec;
|
||||
m_pfnSelector = selector;
|
||||
m_bIsEnabled = true;
|
||||
m_bIsSelected = false;
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
void CCMenuItem::selected()
|
||||
{
|
||||
|
@ -125,14 +125,14 @@ namespace cocos2d{
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCMenuItemLabel * CCMenuItemLabel::initWithLabel(CCNode* label, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
bool CCMenuItemLabel::initWithLabel(CCNode* label, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
{
|
||||
CCMenuItem::initWithTarget(target, selector);
|
||||
m_fOriginalScale = 1.0f;
|
||||
m_tColorBackup = ccWHITE;
|
||||
m_tDisabledColor = ccc3(126,126,126);
|
||||
this->setLabel(label);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
CCMenuItemLabel::~CCMenuItemLabel()
|
||||
{
|
||||
|
@ -231,9 +231,9 @@ namespace cocos2d{
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCMenuItemAtlasFont * CCMenuItemAtlasFont::initFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
bool CCMenuItemAtlasFont::initFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
{
|
||||
NSAssert( strlen(value) != 0, "value lenght must be greater than 0");
|
||||
NSAssert( value != NULL && strlen(value) != 0, "value lenght must be greater than 0");
|
||||
CCLabelAtlas *label = new CCLabelAtlas();
|
||||
label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
|
||||
label->autorelease();
|
||||
|
@ -241,7 +241,7 @@ namespace cocos2d{
|
|||
{
|
||||
// do something ?
|
||||
}
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
//
|
||||
//CCMenuItemFont
|
||||
|
@ -281,15 +281,15 @@ namespace cocos2d{
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCMenuItemFont * CCMenuItemFont::initFromString(const char *value, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
bool CCMenuItemFont::initFromString(const char *value, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
{
|
||||
NSAssert( strlen(value) != 0, "Value lenght must be greater than 0");
|
||||
NSAssert( value != NULL && strlen(value) != 0, "Value lenght must be greater than 0");
|
||||
CCLabel *label = CCLabel::labelWithString(value, _fontName.c_str(), (float)_fontSize);
|
||||
if (CCMenuItemLabel::initWithLabel(label, target, selector))
|
||||
{
|
||||
// do something ?
|
||||
}
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
//
|
||||
//CCMenuItemSprite
|
||||
|
@ -333,14 +333,15 @@ namespace cocos2d{
|
|||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCMenuItemSprite * CCMenuItemSprite::initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
bool CCMenuItemSprite::initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
{
|
||||
assert(normalSprite != NULL);
|
||||
CCMenuItem::initWithTarget(target, selector);
|
||||
this->m_pNormalImage = normalSprite; CCX_SAFE_RETAIN(normalSprite);
|
||||
this->m_pSelectedImage = selectedSprite; CCX_SAFE_RETAIN(selectedSprite);
|
||||
this->m_pDisabledImage = disabledSprite; CCX_SAFE_RETAIN(disabledSprite);
|
||||
this->setContentSize(m_pNormalImage->getContentSize());
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
CCMenuItemSprite::~CCMenuItemSprite()
|
||||
{
|
||||
|
@ -416,26 +417,36 @@ namespace cocos2d{
|
|||
CCMenuItemImage * CCMenuItemImage::itemFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
{
|
||||
CCMenuItemImage *pRet = new CCMenuItemImage();
|
||||
pRet->initFromNormalImage(normalImage, selectedImage, disabledImage, target, selector);
|
||||
if (pRet && pRet->initFromNormalImage(normalImage, selectedImage, disabledImage, target, selector))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCX_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
}
|
||||
CCMenuItemImage * CCMenuItemImage::itemFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage)
|
||||
{
|
||||
CCMenuItemImage *pRet = new CCMenuItemImage();
|
||||
pRet->initFromNormalImage(normalImage, selectedImage, disabledImage, NULL, NULL);
|
||||
if (pRet && pRet->initFromNormalImage(normalImage, selectedImage, disabledImage, NULL, NULL))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CCMenuItemImage * CCMenuItemImage::initFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
CCX_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
}
|
||||
bool CCMenuItemImage::initFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MunuHandler selector)
|
||||
{
|
||||
CCNode *normalSprite = CCSprite::spriteWithFile(normalImage);
|
||||
CCNode *selectedSprite = CCSprite::spriteWithFile(selectedImage);
|
||||
CCNode *disabledSprite = NULL;
|
||||
|
||||
if(disabledImage)
|
||||
{
|
||||
disabledSprite = CCSprite::spriteWithFile(disabledImage);
|
||||
return (CCMenuItemImage*)(initFromNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector));
|
||||
}
|
||||
return initFromNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector);
|
||||
}
|
||||
//
|
||||
// MenuItemToggle
|
||||
|
@ -458,7 +469,7 @@ namespace cocos2d{
|
|||
va_end(args);
|
||||
return pRet;
|
||||
}
|
||||
CCMenuItemToggle * CCMenuItemToggle::initWithTarget(SelectorProtocol* target, SEL_MunuHandler selector, CCMenuItem* item, va_list args)
|
||||
bool CCMenuItemToggle::initWithTarget(SelectorProtocol* target, SEL_MunuHandler selector, CCMenuItem* item, va_list args)
|
||||
{
|
||||
CCMenuItem::initWithTarget(target, selector);
|
||||
this->m_pSubItems = new NSMutableArray<CCMenuItem*>();
|
||||
|
@ -472,7 +483,7 @@ namespace cocos2d{
|
|||
}
|
||||
m_uSelectedIndex = UINT_MAX;
|
||||
this->setSelectedIndex(0);
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
CCMenuItemToggle::~CCMenuItemToggle()
|
||||
{
|
||||
|
|
|
@ -320,10 +320,10 @@ namespace cocos2d {
|
|||
//
|
||||
//RibbonSegment
|
||||
//
|
||||
CCRibbonSegment * CCRibbonSegment::init()
|
||||
bool CCRibbonSegment::init()
|
||||
{
|
||||
this->reset();
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
char * CCRibbonSegment::description()
|
||||
{
|
||||
|
|
|
@ -144,7 +144,7 @@ CCSprite* CCSprite::spriteWithSpriteSheet(CCSpriteSheet *pSpriteSheet, CGRect re
|
|||
return pobSprite;
|
||||
}
|
||||
|
||||
CCSprite* CCSprite::init(void)
|
||||
bool CCSprite::init(void)
|
||||
{
|
||||
m_bDirty = m_bRecursiveDirty = false;
|
||||
|
||||
|
@ -194,10 +194,10 @@ CCSprite* CCSprite::init(void)
|
|||
// Atlas: TexCoords
|
||||
setTextureRect(CGRectZero);
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCSprite* CCSprite::initWithTexture(CCTexture2D *pTexture, CGRect rect)
|
||||
bool CCSprite::initWithTexture(CCTexture2D *pTexture, CGRect rect)
|
||||
{
|
||||
assert(pTexture != NULL);
|
||||
// IMPORTANT: [self init] and not [super init];
|
||||
|
@ -205,10 +205,10 @@ CCSprite* CCSprite::initWithTexture(CCTexture2D *pTexture, CGRect rect)
|
|||
setTexture(pTexture);
|
||||
setTextureRect(rect);
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCSprite* CCSprite::initWithTexture(CCTexture2D *pTexture)
|
||||
bool CCSprite::initWithTexture(CCTexture2D *pTexture)
|
||||
{
|
||||
assert(pTexture != NULL);
|
||||
|
||||
|
@ -218,7 +218,7 @@ CCSprite* CCSprite::initWithTexture(CCTexture2D *pTexture)
|
|||
return initWithTexture(pTexture, rect);
|
||||
}
|
||||
|
||||
CCSprite* CCSprite::initWithFile(const char *pszFilename)
|
||||
bool CCSprite::initWithFile(const char *pszFilename)
|
||||
{
|
||||
assert(pszFilename != NULL);
|
||||
|
||||
|
@ -231,10 +231,10 @@ CCSprite* CCSprite::initWithFile(const char *pszFilename)
|
|||
}
|
||||
|
||||
this->release();
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
CCSprite* CCSprite::initWithFile(const char *pszFilename, CGRect rect)
|
||||
bool CCSprite::initWithFile(const char *pszFilename, CGRect rect)
|
||||
{
|
||||
assert(pszFilename != NULL);
|
||||
|
||||
|
@ -245,20 +245,20 @@ CCSprite* CCSprite::initWithFile(const char *pszFilename, CGRect rect)
|
|||
}
|
||||
|
||||
this->release();
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
CCSprite* CCSprite::initWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
|
||||
bool CCSprite::initWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
|
||||
{
|
||||
assert(pSpriteFrame != NULL);
|
||||
|
||||
CCSprite* pRet = initWithTexture(pSpriteFrame->getTexture(), pSpriteFrame->getRect());
|
||||
bool bRet = initWithTexture(pSpriteFrame->getTexture(), pSpriteFrame->getRect());
|
||||
setDisplayFrame(pSpriteFrame);
|
||||
|
||||
return pRet;
|
||||
return bRet;
|
||||
}
|
||||
|
||||
CCSprite* CCSprite::initWithSpriteFrameName(const char *pszSpriteFrameName)
|
||||
bool CCSprite::initWithSpriteFrameName(const char *pszSpriteFrameName)
|
||||
{
|
||||
assert(pszSpriteFrameName != NULL);
|
||||
|
||||
|
@ -292,12 +292,13 @@ CCSprite* CCSprite::initWithCGImage(CGImageRef pImage, const char *pszKey)
|
|||
}
|
||||
*/
|
||||
|
||||
CCSprite* CCSprite::initWithSpriteSheet(CCSpriteSheet *pSpriteSheet, CGRect rect)
|
||||
bool CCSprite::initWithSpriteSheet(CCSpriteSheet *pSpriteSheet, CGRect rect)
|
||||
{
|
||||
CCSprite* pRet = initWithTexture(pSpriteSheet->getTexture(), rect);
|
||||
assert(pSpriteSheet != NULL);
|
||||
bool bRet = initWithTexture(pSpriteSheet->getTexture(), rect);
|
||||
useSpriteSheetRender(pSpriteSheet);
|
||||
|
||||
return pRet;
|
||||
return bRet;
|
||||
}
|
||||
|
||||
CCSprite::~CCSprite(void)
|
||||
|
|
|
@ -67,22 +67,22 @@ CCAnimation* CCAnimation::animationWithName(const char *pszName, float fDelay)
|
|||
return pAnimation;
|
||||
}
|
||||
|
||||
CCAnimation* CCAnimation::initWithName(const char *pszName)
|
||||
bool CCAnimation::initWithName(const char *pszName)
|
||||
{
|
||||
return initWithName(pszName, 0, NULL);
|
||||
}
|
||||
|
||||
CCAnimation* CCAnimation::initWithName(const char *pszName, float fDelay)
|
||||
bool CCAnimation::initWithName(const char *pszName, float fDelay)
|
||||
{
|
||||
return initWithName(pszName, fDelay, NULL);
|
||||
}
|
||||
|
||||
CCAnimation* CCAnimation::initWithName(const char *pszName, NSMutableArray<CCSpriteFrame*> *pFrames)
|
||||
bool CCAnimation::initWithName(const char *pszName, NSMutableArray<CCSpriteFrame*> *pFrames)
|
||||
{
|
||||
return initWithName(pszName, 0, pFrames);
|
||||
}
|
||||
|
||||
CCAnimation* CCAnimation::initWithName(const char *pszName, float fDelay, NSMutableArray<CCSpriteFrame*> *pFrames)
|
||||
bool CCAnimation::initWithName(const char *pszName, float fDelay, NSMutableArray<CCSpriteFrame*> *pFrames)
|
||||
{
|
||||
m_fDelay = fDelay;
|
||||
m_pszName = new char[strlen(pszName) + 1];
|
||||
|
@ -90,7 +90,7 @@ CCAnimation* CCAnimation::initWithName(const char *pszName, float fDelay, NSMuta
|
|||
m_pszName[strlen(pszName)] = '\0';
|
||||
m_pobFrames = NSMutableArray<CCSpriteFrame*>::arrayWithArray(pFrames);
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCAnimation::~CCAnimation(void)
|
||||
|
@ -142,12 +142,12 @@ CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D *pobTexture, CGRect r
|
|||
return pSpriteFrame;
|
||||
}
|
||||
|
||||
CCSpriteFrame* CCSpriteFrame::initWithTexture(CCTexture2D *pobTexture, CGRect rect, CGPoint offset)
|
||||
bool CCSpriteFrame::initWithTexture(CCTexture2D *pobTexture, CGRect rect, CGPoint offset)
|
||||
{
|
||||
return initWithTexture(pobTexture, rect, offset, rect.size);
|
||||
}
|
||||
|
||||
CCSpriteFrame* CCSpriteFrame::initWithTexture(CCTexture2D *pobTexture, CGRect rect, CGPoint offset, CGSize originalSize)
|
||||
bool CCSpriteFrame::initWithTexture(CCTexture2D *pobTexture, CGRect rect, CGPoint offset, CGSize originalSize)
|
||||
{
|
||||
m_pobTexture = pobTexture;
|
||||
pobTexture->retain();
|
||||
|
@ -155,7 +155,7 @@ CCSpriteFrame* CCSpriteFrame::initWithTexture(CCTexture2D *pobTexture, CGRect re
|
|||
m_obRect = rect;
|
||||
m_obOriginalSize = originalSize;
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCSpriteFrame::~CCSpriteFrame(void)
|
||||
|
|
|
@ -52,10 +52,10 @@ void CCSpriteFrameCache::purgeSharedSpriteFrameCache(void)
|
|||
CCX_SAFE_RELEASE_NULL(pSharedSpriteFrameCache);
|
||||
}
|
||||
|
||||
CCSpriteFrameCache* CCSpriteFrameCache::init(void)
|
||||
bool CCSpriteFrameCache::init(void)
|
||||
{
|
||||
m_pSpriteFramesMap = new map<string, CCSpriteFrame*>();
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCSpriteFrameCache::~CCSpriteFrameCache(void)
|
||||
|
|
|
@ -73,7 +73,7 @@ CCSpriteSheet* CCSpriteSheet::spriteSheetWithFile(const char *pszFileImage)
|
|||
}
|
||||
|
||||
// init with CCTexture2D
|
||||
CCSpriteSheet* CCSpriteSheet::initWithTexture(CCTexture2D *pobTexture, unsigned int uCapacity)
|
||||
bool CCSpriteSheet::initWithTexture(CCTexture2D *pobTexture, unsigned int uCapacity)
|
||||
{
|
||||
m_blendFunc.src = CC_BLEND_SRC;
|
||||
m_blendFunc.dst = CC_BLEND_DST;
|
||||
|
@ -87,11 +87,11 @@ CCSpriteSheet* CCSpriteSheet::initWithTexture(CCTexture2D *pobTexture, unsigned
|
|||
m_pChildren = new NSMutableArray<CCNode*>();
|
||||
m_pobDescendants = new NSMutableArray<CCSprite*>();
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
// init with FileImage
|
||||
CCSpriteSheet* CCSpriteSheet::initWithFile(const char *pszFileImage, unsigned int uCapacity)
|
||||
bool CCSpriteSheet::initWithFile(const char *pszFileImage, unsigned int uCapacity)
|
||||
{
|
||||
CCTexture2D *pTexture2D = CCTextureCache::sharedTextureCache()->addImage(pszFileImage);
|
||||
return initWithTexture(pTexture2D, uCapacity);
|
||||
|
|
|
@ -130,7 +130,7 @@ bool CCTexture2D::getHasPremultipliedAlpha()
|
|||
return m_bHasPremultipliedAlpha;
|
||||
}
|
||||
|
||||
CCTexture2D * CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, CGSize contentSize)
|
||||
bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, CGSize contentSize)
|
||||
{
|
||||
glGenTextures(1, &m_uName);
|
||||
glBindTexture(GL_TEXTURE_2D, m_uName);
|
||||
|
@ -170,7 +170,7 @@ CCTexture2D * CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat
|
|||
|
||||
m_bHasPremultipliedAlpha = false;
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,7 +183,7 @@ char * CCTexture2D::description(void)
|
|||
|
||||
// implementation CCTexture2D (Image)
|
||||
|
||||
CCTexture2D* CCTexture2D::initWithImage(UIImage * uiImage)
|
||||
bool CCTexture2D::initWithImage(UIImage * uiImage)
|
||||
{
|
||||
unsigned int POTWide, POTHigh;
|
||||
|
||||
|
@ -191,7 +191,7 @@ CCTexture2D* CCTexture2D::initWithImage(UIImage * uiImage)
|
|||
{
|
||||
CCLOG("cocos2d: CCTexture2D. Can't create Texture. UIImage is nil");
|
||||
this->release();
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
CCConfiguration *conf = CCConfiguration::sharedConfiguration();
|
||||
|
@ -218,10 +218,9 @@ CCTexture2D* CCTexture2D::initWithImage(UIImage * uiImage)
|
|||
}
|
||||
|
||||
// always load premultiplied images
|
||||
this->initPremultipliedATextureWithImage(uiImage, POTWide, POTHigh);
|
||||
return this;
|
||||
return initPremultipliedATextureWithImage(uiImage, POTWide, POTHigh);
|
||||
}
|
||||
CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, unsigned int POTWide, unsigned int POTHigh)
|
||||
bool CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, unsigned int POTWide, unsigned int POTHigh)
|
||||
{
|
||||
unsigned int i;
|
||||
void* data = NULL;
|
||||
|
@ -364,15 +363,15 @@ CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, un
|
|||
//CGContextRelease(context);
|
||||
delete [] data;
|
||||
}
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
// implementation CCTexture2D (Text)
|
||||
CCTexture2D * CCTexture2D::initWithString(const char *text, const char *fontName, float fontSize)
|
||||
bool CCTexture2D::initWithString(const char *text, const char *fontName, float fontSize)
|
||||
{
|
||||
return initWithString(text, CGSizeMake(0,0), UITextAlignmentCenter, fontName, fontSize);
|
||||
}
|
||||
CCTexture2D * CCTexture2D::initWithString(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
|
||||
bool CCTexture2D::initWithString(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
|
||||
{
|
||||
CCXBitmapDC *pBitmapDC = new CCXBitmapDC(text, dimensions, alignment, fontName, fontSize);
|
||||
|
||||
|
@ -382,7 +381,7 @@ CCTexture2D * CCTexture2D::initWithString(const char *text, CGSize dimensions, U
|
|||
initWithData(pBitData, kCCTexture2DPixelFormat_RGBA8888, (UINT)size.width, (UINT)size.height, size);
|
||||
|
||||
delete pBitmapDC;
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -442,13 +441,13 @@ void CCTexture2D::drawInRect(CGRect rect)
|
|||
|
||||
// implementation CCTexture2D (PVRTC)
|
||||
#ifdef _POWERVR_SUPPORT_
|
||||
CCTexture2D * CCTexture2D::initWithPVRTCData(const void *data, int level, int bpp, bool hasAlpha, int length)
|
||||
bool CCTexture2D::initWithPVRTCData(const void *data, int level, int bpp, bool hasAlpha, int length)
|
||||
{
|
||||
if( !(CCConfiguration::sharedConfiguration()->isSupportsPVRTC()) )
|
||||
{
|
||||
CCLOG("cocos2d: WARNING: PVRTC images is not supported.");
|
||||
this->release();
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
glGenTextures(1, &m_uName);
|
||||
|
@ -474,7 +473,7 @@ CCTexture2D * CCTexture2D::initWithPVRTCData(const void *data, int level, int bp
|
|||
m_fMaxS = 1.0f;
|
||||
m_fMaxT = 1.0f;
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCTexture2D * CCTexture2D::initWithPVRTCFile(const char* file)
|
||||
|
@ -483,7 +482,7 @@ CCTexture2D * CCTexture2D::initWithPVRTCFile(const char* file)
|
|||
{
|
||||
CCLOG("cocos2d: WARNING: PVRTC images is not supported");
|
||||
this->release();
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
CCPVRTexture *pvr = new CCPVRTexture();
|
||||
|
@ -508,9 +507,9 @@ CCTexture2D * CCTexture2D::initWithPVRTCFile(const char* file)
|
|||
{
|
||||
CCLOG("cocos2d: Couldn't load PVR image");
|
||||
this->release();
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -93,20 +93,28 @@ void CCTextureAtlas::setQuads(ccV3F_C4B_T2F_Quad *var)
|
|||
CCTextureAtlas * CCTextureAtlas::textureAtlasWithFile(const char* file, unsigned int capacity)
|
||||
{
|
||||
CCTextureAtlas * pTextureAtlas = new CCTextureAtlas();
|
||||
pTextureAtlas->initWithFile(file, capacity);
|
||||
if(pTextureAtlas && pTextureAtlas->initWithFile(file, capacity))
|
||||
{
|
||||
pTextureAtlas->autorelease();
|
||||
return pTextureAtlas;
|
||||
}
|
||||
CCX_SAFE_DELETE(pTextureAtlas);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCTextureAtlas * CCTextureAtlas::textureAtlasWithTexture(CCTexture2D *texture, unsigned int capacity)
|
||||
{
|
||||
CCTextureAtlas * pTextureAtlas = new CCTextureAtlas();
|
||||
pTextureAtlas->initWithTexture(texture, capacity);
|
||||
if (pTextureAtlas && pTextureAtlas->initWithTexture(texture, capacity))
|
||||
{
|
||||
pTextureAtlas->autorelease();
|
||||
return pTextureAtlas;
|
||||
}
|
||||
CCX_SAFE_DELETE(pTextureAtlas);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCTextureAtlas * CCTextureAtlas::initWithFile(const char * file, unsigned int capacity)
|
||||
bool CCTextureAtlas::initWithFile(const char * file, unsigned int capacity)
|
||||
{
|
||||
// retained in property
|
||||
CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(file);
|
||||
|
@ -114,9 +122,9 @@ CCTextureAtlas * CCTextureAtlas::initWithFile(const char * file, unsigned int ca
|
|||
return initWithTexture(texture, capacity);
|
||||
}
|
||||
|
||||
CCTextureAtlas * CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned int capacity)
|
||||
bool CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned int capacity)
|
||||
{
|
||||
|
||||
assert(texture != NULL);
|
||||
m_uCapacity = capacity;
|
||||
m_uTotalQuads = 0;
|
||||
|
||||
|
@ -130,7 +138,7 @@ CCTextureAtlas * CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned
|
|||
CCLOG("cocos2d: CCTextureAtlas: not enough memory");
|
||||
CCX_SAFE_FREE(m_pQuads)
|
||||
CCX_SAFE_FREE(m_pIndices)
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
#if CC_TEXTURE_ATLAS_USES_VBO
|
||||
|
@ -140,7 +148,7 @@ CCTextureAtlas * CCTextureAtlas::initWithTexture(CCTexture2D *texture, unsigned
|
|||
|
||||
this->initIndices();
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
char * CCTextureAtlas::description()
|
||||
|
|
|
@ -68,7 +68,7 @@ CCTouchDispatcher* CCTouchDispatcher::getSharedDispatcher(void)
|
|||
}
|
||||
*/
|
||||
|
||||
CCTouchDispatcher* CCTouchDispatcher::init(void)
|
||||
bool CCTouchDispatcher::init(void)
|
||||
{
|
||||
m_bDispatchEvents = true;
|
||||
m_pTargetedHandlers = new NSMutableArray<CCTouchHandler*>(8);
|
||||
|
@ -87,7 +87,7 @@ CCTouchDispatcher* CCTouchDispatcher::init(void)
|
|||
m_sHandlerHelperData[ccTouchEnded].m_type = ccTouchEnded;
|
||||
m_sHandlerHelperData[ccTouchCancelled].m_type = ccTouchCancelled;
|
||||
|
||||
return this;
|
||||
return true;
|
||||
}
|
||||
|
||||
CCTouchDispatcher::~CCTouchDispatcher(void)
|
||||
|
|
|
@ -42,7 +42,8 @@ bool Ttest_uphoneApp::initCocos2d()
|
|||
CGSize size = CCDirector::getSharedDirector()->getWinSize();
|
||||
|
||||
// create sprite instance
|
||||
CCSprite * pSprite = (new CCSprite())->initWithTexture(pTexture);
|
||||
CCSprite * pSprite = new CCSprite();
|
||||
pSprite->initWithTexture(pTexture);
|
||||
pSprite->setPosition(CGPoint(size.width / 2, size.height / 2));
|
||||
pSprite->autorelease()->retain();
|
||||
|
||||
|
|
Loading…
Reference in New Issue