cocos2d-x 开发中的小问题 在xcode4环境下

转自:http://hi.baidu.com/baby_66_/item/302353174f19521cd0d66df2

1。如果你在想怎么去搞定程序的开始运行的背景一闪而过的大图 以及icon想换成自己的图,请你别挣扎了,直接弄个名字一样的图片覆盖吧,当然可以直接删掉!不过最好的就是覆盖。

2。如果你定义了float a1,a2、double a1,a2的数据变量,恰好你又要用这些变量做乘除,那么你发现这个除法怎么都不对的时候,你应该这样试试:a1/1 then a1/a2得到直接期待的答案!

3。如果你switch的时候 发现case报错(switch case is in protected scope) 那么请把case下面的用{}包裹起来 例如:switch(){case:{xxoo;break;}}

4。在使用多维数组特别是bool的,在java的时候,一般初始化后默认为false,但是c++就不行了,一定要写个循环初始化再使用,这个问题浪费我2个小时。囧

5。切换到hd分辨率:选中模拟器 ->硬件 ->设备 -> iphone(retina)。

6。如果在hd模拟器分辨率下图片是乱的那么在加载图片的是乱的 CC_CONTENT_SCALE_FACTOR() 这个函数的问题 有很多地方貌似没有*这个函数 搜索整个代码有的地方又用了 乱。ps:今儿又弄了下 发现:<1:visit()的数据要*CC_CONTENT_SCALE_FACTOR();<2:CCSprite* sprite=CCSprite::spriteWithFile(filePath.c_str(),CCRectMake(0,x*8/CC_CONTENT_SCALE_FACTOR(),8/CC_CONTENT_SCALE_FACTOR(),8/CC_CONTENT_SCALE_FACTOR())); <3:sprite ->setPosition(ccp(x/CC_CONTENT_SCALE_FACTOR(),y/CC_CONTENT_SCALE_FACTOR()); 说明有的地方用的是WinSize而有的地方用的是WinSizeInPixels。比个中指吧!

7。得到系统的毫秒时间。

long millisecondNow()

{

structcc_timeval now;

CCTime::gettimeofdayCocos2d(&now,NULL);

return (now.tv_sec * 1000 + now.tv_usec / 1000);

}

8。随机数 arc4random();

9。takinginstalllock错误 表示你真机上正有软件在安装 暂时无法安装程序。真机使用的时候确保没有软件在下载,下载ing再去测试就悲剧鸟。

10。“Could not find mapped image "错误 在4s上 插着线做真机测试 结果点击广告调用浏览器 然后再双击home回到游戏直接黑屏或者屏幕停止运行或者只有背景图 找寻很久木法 结果直接拔线测试 完全不会那样 omg!无语 反正这样解决就好了 =。=

11。objc[2341]: Object 0x9886250 of class __NSArrayM autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

objc[2341]: Object 0x98867f0 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

objc[2341]: Object 0x9887270 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

objc[2341]: Object 0x98873f0 of class NSPathStore2 autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

objc[2341]: Object 0x98874e0 of class NSPathStore2 autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

并不一定是多线程问题 多线程在线程起始需要加入如下代码

// create autorelease pool for iOS

CCThread thread;

thread.createAutoreleasePool();

很有可能你也用过这样的定义:const std::string defaultPngPath = cocos2d::CCFileUtils::getWriteablePath()+"games";

12:Xcode 4.3+ NSLog中文不输出Bug及解决方法 按住Option点Run(或者 Product >> Edit Scheme…),Info >> Debugger 设置为GDB

原文地址:https://www.cnblogs.com/yssgyw/p/3255033.html