Ken_Rao's blog

Indie game developer is my end goal

Cocos2d-x 网络Http篇

谈到Cocos2d-x中的Http网络编程,它的基本流程是:

  1. 创建HttpRequest
  2. 创建setResponseCallback()回调函数来设置如何对请求回复后的信息进行操作
  3. 通过HttpClient发送HttpRequest请求

因此,你首先要知道3个类:

  • HttpRequest
  • HttpResponse
  • HttpClient

了解了它们之后再来看引擎cpp-test中的cpp-test/Classes/ExtensionsTest/NetworkTest/HttpClientTest,就能对Cocos2d-x中Http的用法基本了解了。

Blog_1

如何利用Question2Answer创建QA库

这几天由于工作原因需要搭建一个Cocos2d0x的QA库,一开始打算放在我自己的博客,以博文的形式(大家可以看到我的博文里已经有一些QA的文章了)。后来老板告诉我有一个这样的Question2Answer的框架,我浏览了一下,觉得是很很不错,又是开源免费的,于是花了1天时间把它搭建出来,大家可以看看效果Cocos2d-x QA库,整个是类似于stackoverflow的形式,不管怎么样,比起我这些简短的博文来说肯定是更高大上了,在这里就把创建这个QA库的过程整理一下,作为自己的知识财富,也分享给有同样需求的朋友参考。

QA_List_1

Question 1: Cocos2dx编译错误Symbol(s) not found for architecture armv7

使用版本:3.0,3.1,3.2
运行环境:Mac OS 10.9.3    
开发环境:Xcode 5.1
出现问题:Other Linker Flags中增加-ObjC选项会出现如下编译错误。

(null): "_GCControllerDidDisconnectNotification", referenced from:

(null): -[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)

(null): "_GCControllerDidConnectNotification", referenced from:

(null): -[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)

(null): "_OBJC_CLASS_$_GCController", referenced from:

(null): Objc-class-ref in libcocos2dx iOS.a(CCController-iOS.o)

(null): (maybe you meant: _OBJC_CLASS_$_GCControllerConnectionEventHandler)

(null): Symbol(s) not found for architecture armv7

(null): Linker command failed with exit code 1 (use -v to see invocation)