首页 > 其他 > 详细

cocos2dx中的三种基本的数据类型

时间:2014-11-14 14:08:28      阅读:402      评论:0      收藏:0      [点我收藏+]

1.cocos2dx中提供了三种基本的数据类型:CCString(字符串),CCArray(数组),CCDictionary(数据字典(哈希的功能))

2.CCString的用法

class  CCString : public CCObject,可见CCString本质是一个CCObject,因此支持create方法和其他CCObject的特性

a.CCString的创建:

CCString *str=CCString("abc");

CCString *str=CCString::create("1234");//CCObject的特性

CCString *str=CCString::createwithformat("id%d",3);//格式化初始化

static CCString* createWithData(const unsigned char* pData, unsigned long nLen);//使用二进制数据里创建一个字符串

static CCString* createWithContentsOfFile(const char* pszFileName);//根据文件来创建一个字符串

b.CCString与其他数据类型的转换:

int intValue() const;

unsigned int uintValue() const;

float floatValue() const;

double doubleValue() const;

bool boolValue() const;

2.CCArray是一个数组容器,用来盛放CCObject类型的对象

a.CCArray的创建方法:

/** 创建一个数组*/
static CCArray* create();
/** 使用一些对象创建数组*/
static CCArray* create(CCObject* pObject, …);
/** 使用一个对象创建数组*/
static CCArray* createWithObject(CCObject* pObject);
/** 创建一个指定大小的数组*/
static CCArray* createWithCapacity(unsigned int capacity);
/** 使用一个现有的CCArray 数组来新建一个数组*/
static CCArray* createWithArray(CCArray* otherArray);

 

cocos2dx中的三种基本的数据类型

原文:http://www.cnblogs.com/ttss/p/4096983.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!