issue #7, change the use of NSMutableArray

This commit is contained in:
Walzer 2010-07-20 05:49:13 +00:00
parent c8477d4d16
commit 5d60c2ca0a
20 changed files with 130 additions and 129 deletions

View File

@ -59,7 +59,7 @@ CCAtlasNode * CCAtlasNode::initWithTileFile(std::string &tile, int tileWidth, in
m_cOpacity = 255; m_cOpacity = 255;
m_tColor = m_tColorUnmodified = ccWHITE; m_tColor = m_tColorUnmodified = ccWHITE;
m_bOpacityModifyRGB = true; m_bIsOpacityModifyRGB = true;
m_tBlendFunc.src = CC_BLEND_SRC; m_tBlendFunc.src = CC_BLEND_SRC;
m_tBlendFunc.dst = CC_BLEND_DST; m_tBlendFunc.dst = CC_BLEND_DST;
@ -135,9 +135,9 @@ void CCAtlasNode::draw()
// CCAtlasNode - RGBA protocol // CCAtlasNode - RGBA protocol
ccColor3B CCAtlasNode:: color() ccColor3B CCAtlasNode:: getColor()
{ {
if(m_bOpacityModifyRGB) if(m_bIsOpacityModifyRGB)
{ {
return m_tColorUnmodified; return m_tColorUnmodified;
} }
@ -148,7 +148,7 @@ void CCAtlasNode::setColor(ccColor3B color3)
{ {
m_tColor = m_tColorUnmodified = color3; m_tColor = m_tColorUnmodified = color3;
if( m_bOpacityModifyRGB ) if( m_bIsOpacityModifyRGB )
{ {
m_tColor.r = color3.r * m_cOpacity/255; m_tColor.r = color3.r * m_cOpacity/255;
m_tColor.g = color3.g * m_cOpacity/255; m_tColor.g = color3.g * m_cOpacity/255;
@ -156,7 +156,7 @@ void CCAtlasNode::setColor(ccColor3B color3)
} }
} }
GLubyte CCAtlasNode::opacity() GLubyte CCAtlasNode::getOpacity()
{ {
return m_cOpacity; return m_cOpacity;
} }
@ -166,29 +166,39 @@ void CCAtlasNode::setOpacity(GLubyte opacity)
m_cOpacity = opacity; m_cOpacity = opacity;
// special opacity for premultiplied textures // special opacity for premultiplied textures
if( m_bOpacityModifyRGB ) if( m_bIsOpacityModifyRGB )
this->setColor(m_bOpacityModifyRGB ? m_tColorUnmodified : m_tColor); this->setColor(m_bIsOpacityModifyRGB ? m_tColorUnmodified : m_tColor);
} }
void CCAtlasNode::setOpacityModifyRGB(bool bValue) void CCAtlasNode::setIsOpacityModifyRGB(bool bValue)
{ {
ccColor3B oldColor = this->m_tColor; ccColor3B oldColor = this->m_tColor;
m_bOpacityModifyRGB = bValue; m_bIsOpacityModifyRGB = bValue;
this->m_tColor = oldColor; this->m_tColor = oldColor;
} }
bool CCAtlasNode::doesOpacityModifyRGB() bool CCAtlasNode::getIsOpacityModifyRGB()
{ {
return m_bOpacityModifyRGB; return m_bIsOpacityModifyRGB;
} }
void CCAtlasNode::updateOpacityModifyRGB() void CCAtlasNode::updateOpacityModifyRGB()
{ {
m_bOpacityModifyRGB = m_pTextureAtlas->getTexture()->getHasPremultipliedAlpha(); m_bIsOpacityModifyRGB = m_pTextureAtlas->getTexture()->getHasPremultipliedAlpha();
} }
// CCAtlasNode - CocosNodeTexture protocol // CCAtlasNode - CocosNodeTexture protocol
ccBlendFunc CCAtlasNode::getBlendFunc()
{
return m_tBlendFunc;
}
void CCAtlasNode::setBlendFunc(ccBlendFunc blendFunc)
{
m_tBlendFunc = blendFunc;
}
void CCAtlasNode::updateBlendFunc() void CCAtlasNode::updateBlendFunc()
{ {
if( ! m_pTextureAtlas->getTexture()->getHasPremultipliedAlpha() ) { if( ! m_pTextureAtlas->getTexture()->getHasPremultipliedAlpha() ) {
@ -204,7 +214,7 @@ void CCAtlasNode::setTexture(CCTexture2D *texture)
this->updateOpacityModifyRGB(); this->updateOpacityModifyRGB();
} }
CCTexture2D * CCAtlasNode::texture() CCTexture2D * CCAtlasNode::getTexture()
{ {
return m_pTextureAtlas->getTexture(); return m_pTextureAtlas->getTexture();
} }

View File

@ -75,15 +75,15 @@ CCNode::~CCNode()
} }
void CCNode::arrayMakeObjectsPerformSelector(NSMutableArray * pArray, callbackFunc func) void CCNode::arrayMakeObjectsPerformSelector(NSMutableArray<CCNode*> * pArray, callbackFunc func)
{ {
if(pArray && pArray->count() > 0) if(pArray && pArray->count() > 0)
{ {
CCNode* pNode; CCNode* pNode;
NSMutableArrayIterator it; NSMutableArray<CCNode*>::NSMutableArrayIterator it;
for( it = pArray->begin(); it != pArray->end(); it++) for( it = pArray->begin(); it != pArray->end(); it++)
{ {
pNode = static_cast<CCNode*>(*it); pNode = (*it);
if(pNode && func) if(pNode && func)
{ {
@ -203,7 +203,7 @@ void CCNode::setPosition(CGPoint newPosition)
} }
/// children getter /// children getter
NSMutableArray * CCNode::getChildren() NSMutableArray<CCNode*> * CCNode::getChildren()
{ {
return m_pChildren; return m_pChildren;
} }
@ -411,7 +411,7 @@ std::string CCNode::description()
// lazy allocs // lazy allocs
void CCNode::childrenAlloc(void) void CCNode::childrenAlloc(void)
{ {
m_pChildren = new NSMutableArray(4); m_pChildren = new NSMutableArray<CCNode*>(4);
} }
CCNode* CCNode::getChildByTag(int aTag) CCNode* CCNode::getChildByTag(int aTag)
@ -423,10 +423,10 @@ CCNode* CCNode::getChildByTag(int aTag)
if(m_pChildren && m_pChildren->count() > 0) if(m_pChildren && m_pChildren->count() > 0)
{ {
CCNode* pNode; CCNode* pNode;
NSMutableArrayIterator it; NSMutableArray<CCNode*>::NSMutableArrayIterator it;
for( it = m_pChildren->begin(); it != m_pChildren->end(); it++) for( it = m_pChildren->begin(); it != m_pChildren->end(); it++)
{ {
pNode = static_cast<CCNode*>(*it); pNode = (*it);
if(pNode && pNode->m_nTag == aTag) if(pNode && pNode->m_nTag == aTag)
return pNode; return pNode;
} }
@ -506,7 +506,7 @@ void CCNode::removeAllChildrenWithCleanup(bool cleanup)
if ( m_pChildren && m_pChildren->count() > 0 ) if ( m_pChildren && m_pChildren->count() > 0 )
{ {
CCNode * pNode; CCNode * pNode;
NSMutableArrayIterator it; NSMutableArray<CCNode*>::NSMutableArrayIterator it;
for ( it = m_pChildren->begin(); it!= m_pChildren->end(); it++ ) for ( it = m_pChildren->begin(); it!= m_pChildren->end(); it++ )
{ {
pNode = static_cast<CCNode *>(*it); pNode = static_cast<CCNode *>(*it);
@ -561,10 +561,10 @@ void CCNode::insertChild(CCNode* child, int z)
if(m_pChildren && m_pChildren->count() > 0) if(m_pChildren && m_pChildren->count() > 0)
{ {
CCNode* pNode; CCNode* pNode;
NSMutableArrayIterator it; NSMutableArray<CCNode*>::NSMutableArrayIterator it;
for( it = m_pChildren->begin(); it != m_pChildren->end(); it++) for( it = m_pChildren->begin(); it != m_pChildren->end(); it++)
{ {
pNode = static_cast<CCNode*>(*it); pNode = (*it);
if ( pNode && pNode->m_nZOrder > z ) if ( pNode && pNode->m_nZOrder > z )
{ {
@ -618,10 +618,10 @@ void CCNode::visit()
if(m_pChildren && m_pChildren->count() > 0) if(m_pChildren && m_pChildren->count() > 0)
{ {
CCNode* pNode; CCNode* pNode;
NSMutableArrayIterator it; NSMutableArray<CCNode*>::NSMutableArrayIterator it;
for( it = m_pChildren->begin(); it != m_pChildren->end(); it++) for( it = m_pChildren->begin(); it != m_pChildren->end(); it++)
{ {
pNode = static_cast<CCNode*>(*it); pNode = (*it);
if ( pNode && pNode->m_nZOrder < 0 ) if ( pNode && pNode->m_nZOrder < 0 )
{ {
@ -924,13 +924,14 @@ CGPoint CCNode::convertToWorldSpaceAR(CGPoint nodePoint)
nodePoint = ccpAdd(nodePoint, m_tAnchorPointInPixels); nodePoint = ccpAdd(nodePoint, m_tAnchorPointInPixels);
return this->convertToWorldSpace(nodePoint); return this->convertToWorldSpace(nodePoint);
} }
/** @todo no declare in .h file /** @todo CCDirector*/
CGPoint CCNode::convertToWindowSpace(CGPoint nodePoint) CGPoint CCNode::convertToWindowSpace(CGPoint nodePoint)
{ {
CGPoint worldPoint = [self convertToWorldSpace:nodePoint]; CGPoint worldPoint = this->convertToWorldSpace(nodePoint);
return [[CCDirector sharedDirector] convertToUI:worldPoint]; //return [[CCDirector sharedDirector] convertToUI:worldPoint];
}*/ return ccp(0,0);
}
// convenience methods which take a UITouch instead of CGPoint // convenience methods which take a UITouch instead of CGPoint
/** @todo /** @todo

View File

@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "NSZone.h" #include "NSZone.h"
#include "cocoa/NSObject.h" #include "../cocoa/NSObject.h"
NSZone::NSZone(NSObject *pObject) NSZone::NSZone(NSObject *pObject)
{ {

View File

@ -25,7 +25,7 @@ THE SOFTWARE.
#ifndef __NS_ZONE_H__ #ifndef __NS_ZONE_H__
#define __NS_ZONE_H__ #define __NS_ZONE_H__
#include "platform/platform.h" #include "../platform/platform.h"
class NSObject; class NSObject;

View File

@ -44,6 +44,7 @@ public:
void afterDraw(CCNode *pobTarget); void afterDraw(CCNode *pobTarget);
void blit(void); void blit(void);
void reuse(void); void reuse(void);
bool isActive(void);
public: public:
static CCGridBase* gridWithSize(ccGridSize obGridSize, CCTexture2D *pobTexture, bool bFlipped); static CCGridBase* gridWithSize(ccGridSize obGridSize, CCTexture2D *pobTexture, bool bFlipped);

View File

@ -59,13 +59,14 @@ protected:
ccColor3B m_tColorUnmodified; ccColor3B m_tColorUnmodified;
// protocol variables
bool m_bOpacityModifyRGB;
ccBlendFunc m_tBlendFunc;
GLubyte m_cOpacity;
ccColor3B m_tColor;
CCTextureAtlas * m_pTextureAtlas; CCTextureAtlas * m_pTextureAtlas;
// protocol variables
CCX_PROPERTY(bool, m_bIsOpacityModifyRGB, IsOpacityModifyRGB)
CCX_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc);
CCX_PROPERTY(GLubyte, m_cOpacity, Opacity);
CCX_PROPERTY(ccColor3B, m_tColor, Color);
public: public:
CCAtlasNode(); CCAtlasNode();
~CCAtlasNode(); ~CCAtlasNode();
@ -83,55 +84,10 @@ public:
virtual void draw(); virtual void draw();
public:
// CC RGBA protocol
/** sets Color
@since v0.8
*/
virtual void setColor(ccColor3B color);
/** returns the color
@since v0.8
*/
virtual ccColor3B color(void);
// returns the opacity
virtual GLubyte opacity(void);
/** sets the opacity.
@warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed.
Values goes from 0 to 255, where 255 means fully opaque.
*/
virtual void setOpacity(GLubyte opacity);
// optional
/** 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 );
Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO
@since v0.8
*/
virtual void setOpacityModifyRGB(bool bValue);
/** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity);
@since v0.8
*/
virtual bool doesOpacityModifyRGB(void);
// CC Blend protocol
// set the source blending function for the texture
virtual void setBlendFunc(ccBlendFunc blendFunc);
// returns the blending function used for the texture
virtual ccBlendFunc blendFunc(void);
// CC Texture protocol // CC Texture protocol
// returns the used texture // returns the used texture
virtual CCTexture2D* texture(void); virtual CCTexture2D* getTexture(void);
// sets a new texture. it will be retained // sets a new texture. it will be retained
virtual void setTexture(CCTexture2D *texture); virtual void setTexture(CCTexture2D *texture);

View File

@ -27,9 +27,9 @@ THE SOFTWARE.
#include "Cocos2dDefine.h" #include "Cocos2dDefine.h"
#include "CCNode.h" #include "CCNode.h"
/// @todo CCTexture2D.h #include "CCTexture2D.h"
//#include "CCProtocols.h" #include "CCProtocols.h"
#include "../touch_dispatcher/CCTouchDelegateProtocol.h"
// //
// CCLayer // CCLayer
// //
@ -40,7 +40,7 @@ All features from CCNode are valid, plus the following new features:
- It can receive Accelerometer input - It can receive Accelerometer input
*/ */
/// @todo public UIAccelerometerDelegate, public CCStandardTouchDelegate, public CCTargetedTouchDelegate /// @todo public UIAccelerometerDelegate, public CCStandardTouchDelegate, public CCTargetedTouchDelegate
class CCLayer : public CCNode//, public UIAccelerometerDelegate, public CCStandardTouchDelegate, public CCTargetedTouchDelegate class CCLayer : public CCNode, public CCStandardTouchDelegate, public CCTargetedTouchDelegate//, public UIAccelerometerDelegate
{ {
public: public:
CCLayer(); CCLayer();
@ -83,8 +83,7 @@ All features from CCLayer are valid, plus the following new features:
- opacity - opacity
- RGB colors - RGB colors
*/ */
/// @todo public CCRGBAProtocol, public CCBlendProtocol class CCColorLayer : public CCLayer , public CCRGBAProtocol, public CCBlendProtocol
class CCColorLayer : public CCLayer //, public CCRGBAProtocol, public CCBlendProtocol
{ {
protected: protected:
GLfloat m_fSquareVertices[4 * 2]; GLfloat m_fSquareVertices[4 * 2];
@ -137,7 +136,7 @@ class CCMultiplexLayer : public CCLayer
{ {
protected: protected:
unsigned int m_nEnabledLayer; unsigned int m_nEnabledLayer;
NSMutableArray * m_pLayers; NSMutableArray<CCLayer *> * m_pLayers;
public: public:
CCMultiplexLayer(); CCMultiplexLayer();

View File

@ -96,7 +96,7 @@ Camera:
- Each node has a camera. By default it points to the center of the CCNode. - Each node has a camera. By default it points to the center of the CCNode.
*/ */
class CCNode : public NSObject, public SelectorProtocol class CCNode : virtual public NSObject, public SelectorProtocol
{ {
// variable property // variable property
@ -129,7 +129,7 @@ class CCNode : public NSObject, public SelectorProtocol
/** Position (x,y) of the node in OpenGL coordinates. (0,0) is the left-bottom corner. */ /** Position (x,y) of the node in OpenGL coordinates. (0,0) is the left-bottom corner. */
CCX_PROPERTY(CGPoint, m_tPosition, Position) CCX_PROPERTY(CGPoint, m_tPosition, Position)
CCX_PROPERTY_READONLY(NSMutableArray *, m_pChildren, Children) CCX_PROPERTY_READONLY(NSMutableArray<CCNode *> *, m_pChildren, Children)
/** A CCCamera object that lets you move the node using a gluLookAt /** A CCCamera object that lets you move the node using a gluLookAt
*/ */
@ -211,7 +211,9 @@ private:
typedef void (CCNode::*callbackFunc)(void); typedef void (CCNode::*callbackFunc)(void);
void arrayMakeObjectsPerformSelector(NSMutableArray * pArray, callbackFunc func); void arrayMakeObjectsPerformSelector(NSMutableArray<CCNode*> * pArray, callbackFunc func);
CGPoint convertToWindowSpace(CGPoint nodePoint);
public: public:

View File

@ -40,7 +40,7 @@ THE SOFTWARE.
class CCPVRTexture : public NSObject class CCPVRTexture : public NSObject
{ {
protected: protected:
NSMutableArray * m_pImageData; NSMutableArray<NSData> * m_pImageData;
public: public:

View File

@ -43,6 +43,7 @@ class CCScene : public CCNode
public: public:
CCScene(); CCScene();
virtual ~CCScene(); virtual ~CCScene();
bool init();
}; };
#endif // __CCSCENE_H__ #endif // __CCSCENE_H__

View File

@ -28,7 +28,9 @@ THE SOFTWARE.
#include "../cocoa/NSObject.h" #include "../cocoa/NSObject.h"
/// @todo #import <Foundation/Foundation.h> /// @todo #import <Foundation/Foundation.h>
/// @todo #import <CoreGraphics/CGImage.h> /// @todo #import <CoreGraphics/CGImage.h>
//#include "../platform/uphone/NSLock.h"
#include <string> #include <string>
#include <hash_map>
class CCTexture2D; class CCTexture2D;
@ -42,10 +44,10 @@ typedef void (*fpAsyncCallback)(CCTexture2D*, void*);
class CCTextureCache : public NSObject class CCTextureCache : public NSObject
{ {
protected: protected:
/** @todo NSMutableDictionary, NSLock /// @todo hash_map<*,*>
NSMutableDictionary *textures; stdext::hash_map<int ,int > textures;
NSLock *dictLock; //NSLock *m_pDictLock;
NSLock *contextLock;*/ //NSLock *m_pContextLock;
public: public:

View File

@ -88,13 +88,14 @@ THE SOFTWARE.
#define CCX_SAFE_RETAIN(p) if(p) { p->retain(); } #define CCX_SAFE_RETAIN(p) if(p) { p->retain(); }
#ifdef _DEBUG #ifdef _DEBUG
#include "assert.h" #include <assert.h>
#include <stdio.h>
#define NSAssert(_CONDITION, _TXT)\ #define NSAssert(_CONDITION, _TXT)\
if(! (_CONDITION) ) \ if(! (_CONDITION) ) \
{ \ { \
printf( (_TXT) ); \ printf( (_TXT) ); \
assert( (_CONDITION) ); \ assert( (_CONDITION) ); \
} }
#else #else
#define NSAssert(_CONDITION, _TXT) #define NSAssert(_CONDITION, _TXT)
#endif #endif

View File

@ -23,14 +23,33 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "CCScene.h" #include "CCScene.h"
#include "../support/CGPointExtension.h"
//#include "../CCDirector.h"
CCScene::CCScene() CCScene::CCScene()
{ {
/// @todo this->m_bIsRelativeAnchorPoint = false;
m_tAnchorPoint = ccp(0.5f, 0.5f);
} }
CCScene::~CCScene() CCScene::~CCScene()
{ {
/// @todo /// @todo
} }
bool CCScene::init()
{
/// @todo CCDirector
bool bRet = false;
// do
// {
// CCDirector * pDirector;
// CCX_BREAK_IF( ! (pDirector = CCDirector::getSharedDirector()) );
// this->setContentSize(pDirector->getWinSize());
// // success
// bRet = true;
// } while (0);
//
return bRet;
}

View File

@ -23,7 +23,7 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "TransformUtils.h" #include "TransformUtils.h"
#include "cocoa/CGAffineTransform.h" #include "../cocoa/CGAffineTransform.h"
void CGAffineToGL(const CGAffineTransform *t, GLfloat *m) void CGAffineToGL(const CGAffineTransform *t, GLfloat *m)
{ {

View File

@ -25,6 +25,9 @@ THE SOFTWARE.
#include "CCPVRTexture.h" #include "CCPVRTexture.h"
#include "ccMacros.h" #include "ccMacros.h"
using namespace std;
#define PVR_TEXTURE_FLAG_TYPE_MASK 0xff #define PVR_TEXTURE_FLAG_TYPE_MASK 0xff
static char* gPVRTexIdentifier[] = {"PVR!"}; static char* gPVRTexIdentifier[] = {"PVR!"};
@ -230,7 +233,7 @@ bool CCPVRTexture::createGLTexture()
} }
CCPVRTexture * CCPVRTexture::initWithContentsOfFile(NSString *path) CCPVRTexture * CCPVRTexture::initWithContentsOfFile(string & path)
{ {
/** @todo /** @todo
if((self = [super init])) if((self = [super init]))
@ -270,7 +273,7 @@ CCPVRTexture * CCPVRTexture::initWithContentsOfFile(NSString *path)
}*/ }*/
CCPVRTexture * CCPVRTexture::pvrTextureWithContentsOfFile(NSString * path) CCPVRTexture * CCPVRTexture::pvrTextureWithContentsOfFile(string & path)
{ {
CCPVRTexture * pTexture = new CCPVRTexture(); CCPVRTexture * pTexture = new CCPVRTexture();
pTexture->initWithContentsOfFile(path); pTexture->initWithContentsOfFile(path);

View File

@ -35,9 +35,11 @@ THE SOFTWARE.
#include "ccConfig.h" #include "ccConfig.h"
#include "ccMacros.h" #include "ccMacros.h"
#include "CCTexture2D.h" #include "CCTexture2D.h"
/// @todo #include "CCPVRTexture.h" #include "CCPVRTexture.h"
#include "../CCConfiguration.h" #include "../CCConfiguration.h"
using namespace std;
#if CC_FONT_LABEL_SUPPORT #if CC_FONT_LABEL_SUPPORT
// FontLabel support // FontLabel support
@ -349,7 +351,7 @@ return self;
}*/ }*/
// implementation CCTexture2D (Text) // implementation CCTexture2D (Text)
CCTexture2D * CCTexture2D::initWithString(NSString *str, NSString *fontName, GLfloat fontSize) CCTexture2D * CCTexture2D::initWithString(string & str, string & fontName, GLfloat fontSize)
{ {
/** @todo /** @todo
CGSize dim; CGSize dim;
@ -365,7 +367,7 @@ CCTexture2D * CCTexture2D::initWithString(NSString *str, NSString *fontName, GLf
return [self initWithString:string dimensions:dim alignment:UITextAlignmentCenter fontName:name fontSize:size]; return [self initWithString:string dimensions:dim alignment:UITextAlignmentCenter fontName:name fontSize:size];
} }
- (id) initWithString:(NSString*)string dimensions:(CGSize)dimensions alignment:(UITextAlignment)alignment fontName:(NSString*)name fontSize:(CGFloat)size - (id) initWithString:(string & )string dimensions:(CGSize)dimensions alignment:(UITextAlignment)alignment fontName:(string & )name fontSize:(CGFloat)size
{ {
NSUInteger width, NSUInteger width,
height, height,
@ -516,7 +518,7 @@ CCTexture2D * CCTexture2D::initWithPVRTCData(const void *data, int level, int bp
return this; return this;
} }
CCTexture2D * CCTexture2D::initWithPVRTCFile(NSString* file) CCTexture2D * CCTexture2D::initWithPVRTCFile(string & file)
{ {
/** @todo /** @todo
if( ! [[CCConfiguration sharedConfiguration] supportsPVRTC] ) { if( ! [[CCConfiguration sharedConfiguration] supportsPVRTC] ) {

View File

@ -35,6 +35,8 @@ THE SOFTWARE.
// implementation CCTextureAtlas // implementation CCTextureAtlas
using namespace std;
CCTextureAtlas::CCTextureAtlas() CCTextureAtlas::CCTextureAtlas()
{ {
@ -87,7 +89,7 @@ void CCTextureAtlas::setQuads(ccV3F_C4B_T2F_Quad *var)
// TextureAtlas - alloc & init // TextureAtlas - alloc & init
CCTextureAtlas * CCTextureAtlas::textureAtlasWithFile(NSString *file, UINT32 capacity) CCTextureAtlas * CCTextureAtlas::textureAtlasWithFile(string & file, UINT32 capacity)
{ {
CCTextureAtlas * pTextureAtlas = new CCTextureAtlas(); CCTextureAtlas * pTextureAtlas = new CCTextureAtlas();
pTextureAtlas->initWithFile(file, capacity); pTextureAtlas->initWithFile(file, capacity);
@ -103,7 +105,7 @@ CCTextureAtlas * CCTextureAtlas::textureAtlasWithTexture(CCTexture2D *tex, UINT3
return pTextureAtlas; return pTextureAtlas;
} }
CCTextureAtlas * CCTextureAtlas::initWithFile(NSString *file, UINT32 capacity) CCTextureAtlas * CCTextureAtlas::initWithFile(string & file, UINT32 capacity)
{ {
// retained in property // retained in property
CCTexture2D *tex = CCTextureCache::sharedTextureCache()->addImage(file); CCTexture2D *tex = CCTextureCache::sharedTextureCache()->addImage(file);

View File

@ -33,14 +33,16 @@ THE SOFTWARE.
/// @todo EAGLContext static EAGLContext *auxEAGLcontext = NULL; /// @todo EAGLContext static EAGLContext *auxEAGLcontext = NULL;
using namespace std; using namespace std;
class CCAsyncObject : NSObject class CCAsyncObject : NSObject
{ {
public: public:
fpAsyncCallback m_pfnCallback; fpAsyncCallback m_pfnCallback;
NSObject* m_pTarget; NSObject* m_pTarget;
NSString* m_pData; std::string * m_pData;
public: public:
CCAsyncObject(); CCAsyncObject();
~CCAsyncObject() ~CCAsyncObject()
@ -142,7 +144,7 @@ sharegroup:[[[[CCDirector sharedDirector] openGLView] context] sharegroup]];
} }
/** @todo /** @todo
-(void) addImageAsync: (NSString*) filename target:(id)target selector:(SEL)selector -(void) addImageAsync: (string & ) filename target:(id)target selector:(SEL)selector
{ {
NSAssert(filename != nil, @"TextureCache: fileimage MUST not be nill"); NSAssert(filename != nil, @"TextureCache: fileimage MUST not be nill");
@ -166,9 +168,9 @@ sharegroup:[[[[CCDirector sharedDirector] openGLView] context] sharegroup]];
[asyncObject release]; [asyncObject release];
}*/ }*/
CCTexture2D * CCTextureCache::addImage(NSString *path) CCTexture2D * CCTextureCache::addImage(string & path)
{ {
NSAssert(path != NULL, "TextureCache: fileimage MUST not be nill"); NSAssert(!path.empty(), "TextureCache: fileimage MUST not be nill");
CCTexture2D * tex = NULL; CCTexture2D * tex = NULL;
@ -182,7 +184,7 @@ CCTexture2D * CCTextureCache::addImage(NSString *path)
if( ! tex ) { if( ! tex ) {
// Split up directory and filename // Split up directory and filename
NSString *fullpath = [CCFileUtils fullPathFromRelativePath: path ]; string & fullpath = [CCFileUtils fullPathFromRelativePath: path ];
// all images are handled by UIImage except PVR extension that is handled by our own handler // all images are handled by UIImage except PVR extension that is handled by our own handler
if ( [[path lowercaseString] hasSuffix:@".pvr"] ) if ( [[path lowercaseString] hasSuffix:@".pvr"] )
@ -210,10 +212,10 @@ CCTexture2D * CCTextureCache::addImage(NSString *path)
return tex; return tex;
} }
CCTexture2D* CCTextureCache::addPVRTCImage(NSString *path, int bpp, bool hasAlpha, int width) CCTexture2D* CCTextureCache::addPVRTCImage(string & path, int bpp, bool hasAlpha, int width)
{ {
NSAssert(path != NULL, "TextureCache: fileimage MUST not be nill"); NSAssert(!path.empty(), "TextureCache: fileimage MUST not be nill");
NSAssert( bpp==2 || bpp==4, "TextureCache: bpp must be either 2 or 4"); NSAssert( bpp==2 || bpp==4, "TextureCache: bpp must be either 2 or 4");
CCTexture2D * tex; CCTexture2D * tex;
@ -223,7 +225,7 @@ CCTexture2D* CCTextureCache::addPVRTCImage(NSString *path, int bpp, bool hasAlph
} }
// Split up directory and filename // Split up directory and filename
NSString *fullpath = [CCFileUtils fullPathFromRelativePath:path]; string & fullpath = [CCFileUtils fullPathFromRelativePath:path];
NSData *nsdata = [[NSData alloc] initWithContentsOfFile:fullpath]; NSData *nsdata = [[NSData alloc] initWithContentsOfFile:fullpath];
tex = [[CCTexture2D alloc] initWithPVRTCData:[nsdata bytes] level:0 bpp:bpp hasAlpha:alpha length:w]; tex = [[CCTexture2D alloc] initWithPVRTCData:[nsdata bytes] level:0 bpp:bpp hasAlpha:alpha length:w];
@ -238,9 +240,9 @@ CCTexture2D* CCTextureCache::addPVRTCImage(NSString *path, int bpp, bool hasAlph
return tex; return tex;
} }
CCTexture2D * CCTextureCache::addPVRTCImage(NSString* fileimage) CCTexture2D * CCTextureCache::addPVRTCImage(string & fileimage)
{ {
NSAssert(fileimage != NULL, "TextureCache: fileimage MUST not be nill"); NSAssert(!fileimage.empty(), "TextureCache: fileimage MUST not be nill");
CCTexture2D * tex; CCTexture2D * tex;
/** @todo /** @todo
@ -259,7 +261,7 @@ CCTexture2D * CCTextureCache::addPVRTCImage(NSString* fileimage)
} }
/** @todo /** @todo
-(CCTexture2D*) addCGImage: (CGImageRef) imageref forKey: (NSString *)key -(CCTexture2D*) addCGImage: (CGImageRef) imageref forKey: (string & )key
{ {
NSAssert(imageref != nil, @"TextureCache: image MUST not be nill"); NSAssert(imageref != nil, @"TextureCache: image MUST not be nill");
@ -315,9 +317,9 @@ void CCTextureCache::removeTexture(CCTexture2D* tex)
[textures removeObjectForKey:[keys objectAtIndex:i]];*/ [textures removeObjectForKey:[keys objectAtIndex:i]];*/
} }
void CCTextureCache::removeTextureForKey(NSString* textureKeyName) void CCTextureCache::removeTextureForKey(string & textureKeyName)
{ {
if( ! textureKeyName ) if( textureKeyName.empty() )
return; return;
/// @todo [textures removeObjectForKey:textureKeyName]; /// @todo [textures removeObjectForKey:textureKeyName];

View File

@ -35,7 +35,7 @@ typedef enum {
kTargetedTouchDelegate, kTargetedTouchDelegate,
} eTouchDelegteType; } eTouchDelegteType;
class CCTouchDelegate : public NSObject class CCTouchDelegate : virtual public NSObject
{ {
public: public:
eTouchDelegteType m_eType; eTouchDelegteType m_eType;

View File

@ -27,7 +27,7 @@ THE SOFTWARE.
#include "CCTouchDelegateProtocol.h" #include "CCTouchDelegateProtocol.h"
#include "../cocoa/NSObject.h" #include "../cocoa/NSObject.h"
#include "cocoa/NSMutableArray.h" #include "../cocoa/NSMutableArray.h"
typedef enum typedef enum
{ {