cocos2d-x3.0 实现HTTP请求GET、POST
生活随笔
收集整理的這篇文章主要介紹了
cocos2d-x3.0 实现HTTP请求GET、POST
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
HTTP請(qǐng)求實(shí)現(xiàn)
把以下代碼拷貝到新創(chuàng)建的project中就能看到效果
HelloWorldScene.h
#include "cocos2d.h" /*記得要引頭文件*/ #include "extensions/cocos-ext.h" #include "network/HttpClient.h" USING_NS_CC; USING_NS_CC_EXT; using namespace network;class HelloWorld : public cocos2d::Layer { public:// there's no 'id' in cpp, so we recommend returning the class instance pointerstatic cocos2d::Scene* createScene();// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphonevirtual bool init(); // a selector callbackvoid menuCloseCallback(cocos2d::Ref* pSender);void onMenuGetTestClicked(Ref* sender);void onMenuPostBinaryTestClicked(Ref* sender);//Http Response Callbackvoid onHttpRequestCompleted(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response);// implement the "static create()" method manuallyCREATE_FUNC(HelloWorld); };
HelloWorldScene.cpp
本文轉(zhuǎn)自mfrbuaa博客園博客,原文鏈接:http://www.cnblogs.com/mfrbuaa/p/5061672.html,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的cocos2d-x3.0 实现HTTP请求GET、POST的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 系统、网络运维好帮手:expect
- 下一篇: centos国内yum源