CCRenderTexture内部使用一个sprite来显示texture,如position、anchorPoint、contentSize等属性通过这个sprite获得,CCRenderTexture自身作为一个容器不设置这些值。
CCTouchDispatcher处理touch事件按照priority值从小到大,与zOrder值无关。
背景图片重复,要确保图片长宽是2的幂:
ccTexParams tp = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT }; [backgroundPattern.texture setTexParameters:¶ms];
CocosBuilder的tutorial
后台运行cocos2d
ios5的multitask只支持audio、location update、voip,通过播放无声audio让cocos2d后台运行:
- 在Info.plist中
Application does not run in background
设为YES
,Required background modes
添加App plays audio
- 使用MTAudioPlayer(参见这里)后台播放音乐,其主要是设置audio session category为
kAudioSessionCategory_MediaPlayback
cocos2d还要
[CCDirector setDirectorType:kCCDirectorTypeDefault];
,若用默认的kCCDirectorTypeDisplayLink
则锁屏尚可执行但屏幕一关闭就暂停。- 在Info.plist中
看项目是否开启ARC:Build Settings->Apple LLVM compiler->ObjC++ ARC
没ARC项目的个别文件开ARC:设Build Phases->Compile Sources->Compiler Flag为-fobjc-arc
开ARC项目的个别文件关ARC:设Compiler Flag为-fno-objc-arc
添加push通知:
按照tutorial,开启App ID中的push功能(若无CSR文件则用钥匙串访问生成),下载安装生成的ssl证书并导出p12文件。然后生成新的Provisioning Profile并下载安装。
将p12文件传到Parse或Urban Airship
在AppDelegate的
application:didFinishLaunchingWithOptions:
里:[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
然后在
application:didRegisterForRemoteNotificationsWithDeviceToken:
里使用Orbiter只能在设备上测试
使用umeng的错误分析:
- 在Xcode中Product->Archive->Distribute->Export as Xcode Archive
- 将导出的xxx.xcarchive中Products/Applications/xxx.app和dSYMs/xxx.app.dSYM拷到一个目录下
- 在命令行输入
atos -arch armv7 -o xxx.app/xxx
,输入umeng错误日志中的地址0xaddress就可显示对应的源码行