cocos2dx 2.2.62.2中CCLayer,CCDirecter…还可以用在3.10中的版本吗?

CSJson在cocos2dx2.2.2版本中要引入什么头文件,或者CSJson被什么取代了?_百度知道
CSJson在cocos2dx2.2.2版本中要引入什么头文件,或者CSJson被什么取代了?
CSJson在cocos2dx2.2.2版本中要引入什么头文件,或者CSJson被什么取代了?
在2.2.2版本里找不到json_lib.h这个头文件
我有更好的答案
Json.h&quot.csdn.net/w/article/details/" target="_blank">http://spine/
具体可以参考<a href="http://blog用Json
引入头#include &quot
采纳率:73%
为您推荐:
其他类似问题
&#xe675;换一换
回答问题,赢新手礼包&#xe6b9;
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。cocos2dx 3.3版本的 WebView 怎么用_百度知道
cocos2dx 3.3版本的 WebView 怎么用
我有更好的答案
我们还可以设置WebView的回调;_webView-&loadUrl(&2);_webView-&gt:create();_webView-&gt::didFailLoading = CC_CALLBACK_2(WebViewTest:.google.com&/called when web page is fail loading_webView-&/called when web page is finish loading_webView-&), this);&#47:onWebViewShouldStartLoadingWebViewWebView是一个新的控件类型,允许你在Cocos2d-x中显示网页内容://www::WebView:
资深电脑人
为您推荐:
其他类似问题
&#xe675;换一换
回答问题,赢新手礼包&#xe6b9;
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)博客分类:
Coos2d-x网站:
Windows下开发,所以下载源码解压后先用build-win32.bat编译可执行文件,编译完后在HelloLua或者multi-platform-lua工程中修改一下C++源代码,不改也可以。
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
lpCmdLine,
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
#ifdef USE_WIN32_CONSOLE
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
// create the application instance
CCUserDefault* userDefault = CCUserDefault::sharedUserDefault(); //用于从XML文件读取用户配置
std::string viewName = userDefault-&getStringForKey("viewName", "WinApp");
float viewWidth = userDefault-&getFloatForKey("viewWidth", 480);
float viewHeight = userDefault-&getFloatForKey("viewHeight", 320);
float zoomFactor = userDefault-&getFloatForKey("zoomFactor", 1);
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
eglView-&setViewName(viewName.c_str());
eglView-&setFrameSize(viewWidth, viewHeight);
eglView-&setFrameZoomFactor(zoomFactor);
int ret = CCApplication::sharedApplication()-&run();
#ifdef USE_WIN32_CONSOLE
FreeConsole();
修改了一些地方,将一些配置从xml文件中读取,免得以后对要他们修改还要重新编译:
CCUserDefault* userDefault = CCUserDefault::sharedUserDefault(); //用于从XML文件读取用户配置
std::string viewName = userDefault-&getStringForKey("viewName", "WinApp");
float viewWidth = userDefault-&getFloatForKey("viewWidth", 480);
float viewHeight = userDefault-&getFloatForKey("viewHeight", 320);
float zoomFactor = userDefault-&getFloatForKey("zoomFactor", 1);
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
eglView-&setViewName(viewName.c_str());
eglView-&setFrameSize(viewWidth, viewHeight);
eglView-&setFrameZoomFactor(zoomFactor);
CCUserDefault会利用tinyxml2读写xml文件,从而保存或者读取我们所需要的基本类型数据。
这样也避免了转码操作。
在AppDelegate初始化时加载Lua文件,主要就改了一下路径:
std::string searchPath = _userDefault-&getStringForKey("searchPath", "script");
std::string scriptName = _userDefault-&getStringForKey("scriptName", "main.lua");
//std::string path = CCFileUtils::sharedFileUtils()-&fullPathForFilename("hello.lua");
CCFileUtils::sharedFileUtils()-&addSearchPath(searchPath.c_str());
pEngine-&executeScriptFile(scriptName.c_str());
这样启动时就去执行script/main.lua
编译后就不用管C++代码了,以后的lua代码修改后也不用再编译。
现在有了可执行文件,拷到没装VisualStudio的PC上也可以开发cocos了
下面写lua代码:
local function main()
-- avoid memory leak
collectgarbage("setpause", 100)
collectgarbage("setstepmul", 5000)
print(os.date())
--打印系统时间
local scene = CCScene:create()
local layer = CCLayer:create()
layer:setTouchEnabled(true)
layer:registerScriptTouchHandler(function(eventType, x, y)
--响应屏幕触摸事件
if eventType == "began" then
print(eventType, x, y)
return true
elseif eventType == "ended" then
print(eventType, x, y)
scene:addChild(layer)
CCDirector:sharedDirector():setDisplayStats(true);
CCDirector:sharedDirector():runWithScene(scene)
debug程序通过print打印
参照LuaTest代码写一个小电子时钟程序
local function main()
-- avoid memory leak
collectgarbage("setpause", 100)
collectgarbage("setstepmul", 5000)
--获取定时任务队列
local scheduler = CCDirector:sharedDirector():getScheduler()
--获取屏幕尺寸
local winSize = CCDirector:sharedDirector():getWinSize()
--创建layer
local layer = CCLayer:create()
--获取位图字体
local bmpFontTime = CCLabelBMFont:create(os.date('%X'), "bitmapFontTest3.fnt")
local bmpFontDate = CCLabelBMFont:create(os.date('%x'), "bitmapFontTest3.fnt")
local bmpFontFast = CCLabelBMFont:create('0', "bitmapFontTest3.fnt")
--设置坐标
bmpFontTime:setPosition(winSize.width / 2, winSize.height / 2)
bmpFontDate:setPosition(winSize.width / 2, winSize.height / 2 + 48)
bmpFontFast:setPosition(winSize.width / 2, winSize.height / 2 - 48)
--添加到layer
layer:addChild(bmpFontTime)
layer:addChild(bmpFontDate)
layer:addChild(bmpFontFast)
--定时器响应函数
local function secondInterval(dt)
print(dt, os.date('%X'))
bmpFontTime:setString(os.date('%X'))
bmpFontDate:setString(os.date('%x'))
--定时器响应函数
local interval = 0
local function fastInterval(dt)
interval = interval+1
print(interval)
bmpFontFast:setString(interval)
--设置定时任务
local schedulerEntry1 = nil
local schedulerEntry2 = nil
layer:registerScriptHandler(function(event)
if event == "enter" then
print('schedule enter')
schedulerEntry1 = scheduler:scheduleScriptFunc(secondInterval, 1.0, false)
schedulerEntry2 = scheduler:scheduleScriptFunc(fastInterval, 0.1, false)
elseif event== "exit" then
print('schedule exit')
scheduler:unscheduleScriptEntry(schedulerEntry1)
scheduler:unscheduleScriptEntry(schedulerEntry2)
if CCDirector:sharedDirector():isPaused() then
CCDirector:sharedDirector():resume()
--响应屏幕触摸事件
layer:setTouchEnabled(true)
layer:registerScriptTouchHandler(function(eventType, x, y)
if eventType == "began" then
print(eventType, x, y)
return true
elseif eventType == "ended" then
print(eventType, x, y)
CCDirector:sharedDirector():setDisplayStats(not CCDirector:sharedDirector():isDisplayStats());
local scene = CCScene:create()
scene:addChild(layer)
CCDirector:sharedDirector():runWithScene(scene)
(839.2 KB)
下载次数: 3
下载次数: 3
下载次数: 7
下载次数: 5
浏览: 676384 次
来自: 珠海
“这个电脑蓝牙不可用!”原因多半是你没打开蓝牙
这个加密压缩后, linux环境下可以解压缩吗
兄弟简单明了。顶你
不像有的文章 介绍一大堆没整明白是什么地下 赞一个 ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'}

我要回帖

更多关于 cocos2dx 2.1.4下载 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信