我的Cocos2d-x学习笔记(十九)CCString、CCArray

我的Cocos2d-x学习笔记(十九)CCString、CCArray,第1张

概述一、CCString 代码如下: class CC_DLL CCString : public CCObject{public: CCString(); CCString(const char* str); CCString(const std::string& str); CCString(const CCString& str); CCString& operator= (con

一、CCString

代码如下:

class CC_DLL CCString : public CCObject{public:	CCString();	CCString(const char* str);	CCString(const std::string& str);	CCString(const CCString& str);	CCString& operator= (const CCString& other);	/** convert to int value */	int intValue() const;	/** convert to unsigned int value */	unsigned int uintValue() const;	/** convert to float value */	float floatValue() const;	/** convert to double value */	double doubleValue() const;	/** convert to bool value */	bool boolValue() const;	/** get the C string */	const char* getCString() const;	/** get the length of string */	unsigned int length() const;	/** compare to a c string */	int compare(const char *) const;	virtual CCObject* copyWithZone(CCZone* pZone);	virtual bool isEqual(const CCObject* pObject);	static CCString* create(const std::string& str);	static CCString* createWithFormat(const char* format,...) CC_FORMAT_PRINTF(1,2);	/** create a string with binary data	*/	static CCString* createWithData(const unsigned char* pData,unsigned long nLen);	/** create a string with a file,*/	static CCString* createWithContentsOffile(const char* pszfilename);public:	std::string m_sstring;};


二、CCArray

代码如下:

class CC_DLL CCArray : public CCObject{public:	/** Create an array */	static CCArray* create();	/** Create an array with some objects	*/	static CCArray* create(CCObject* pObject,...);	/** Create an array with one object */	static CCArray* createWithObject(CCObject* pObject);	/** Create an array with capacity */	static CCArray* createWithCapacity(unsigned int capacity);	/** Create an array with an existing array */	static CCArray* createWithArray(CCArray* otherArray);	static CCArray* createWithContentsOffile(const char* pfilename);	static CCArray* createWithContentsOffileThreadSafe(const char* pfilename);	/** Returns element count of the array */	unsigned int count() const;	/** Returns capacity of the array */	unsigned int capacity() const;	/** Returns index of a certain object,return UINT_MAX if doesn't contain the object */	unsigned int indexOfObject(CCObject* object) const;	/** Returns an element with a certain index */	CCObject* objectAtIndex(unsigned int index);	/** Returns last element */	CCObject* lastObject();	/** Returns a random element */	CCObject* randomObject();	/** Returns a Boolean value that indicates whether object is present in array. */	bool containsObject(CCObject* object) const;	/** Add a certain object */	voID addobject(CCObject* object);	/** Add all elements of an existing array */	voID addobjectsFromArray(CCArray* otherArray);	/** Insert a certain object at a certain index */	voID insertObject(CCObject* object,unsigned int index);	/** Remove last object */	voID removeLastObject(bool bReleaSEObj = true);	/** Remove a certain object */	voID removeObject(CCObject* object,bool bReleaSEObj = true);	/** Remove an element with a certain index */	voID removeObjectAtIndex(unsigned int index,bool bReleaSEObj = true);	/** Remove all elements */	voID removeObjectsInArray(CCArray* otherArray);	/** Remove all objects */	voID removeAllObjects();	/** Fast way to remove a certain object */	voID fastRemoveObject(CCObject* object);	/** Fast way to remove an element with a certain index */	voID fastRemoveObjectAtIndex(unsigned int index);	/** Swap two elements */	voID exchangeObject(CCObject* object1,CCObject* object2);	/** Swap two elements with certain indexes */	voID exchangeObjectAtIndex(unsigned int index1,unsigned int index2);	/** Replace object at index with another object. */	voID replaceObjectAtIndex(unsigned int uIndex,CCObject* pObject,bool bReleaSEObject = true);	/** Revers the array */	voID reverSEObjects();	/* Shrinks the array so the memory footprint corresponds with the number of items */	voID reduceMemoryFootprint();};
总结

以上是内存溢出为你收集整理的我的Cocos2d-x学习笔记(十九)CCString、CCArray全部内容,希望文章能够帮你解决我的Cocos2d-x学习笔记(十九)CCString、CCArray所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1059666.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存