Cocos2d-x 3.1.1 lua-tests开篇
  本篇博客打算从研究Cocos2d-x引擎提供的測试样例来写起,笔者针对Cocos2d-x 3.1.1这个版本号来介绍怎样来学习它给我们提供的样例,通过这些样例来深入学习Cocos2d-x核心API的使用。在学习过程中,笔者相同跟非常多刚開始学习的人一样有非常多疑惑,为了能帮助到很多其它刚開始学习的人,笔者会提出自己的疑惑然后进行解决,笔者会把每个样例都进行具体说明,对相关代码进行凝视,那么以后刚開始学习的人就能够对比笔者的博客来学习Cocos2d-x的使用,我想会事半功倍的。对笔者来说,什么版本号并不重要,重要的是学习的思路,接下来的系列博客就是笔者学习Cocos2d-x的思路。
  怎样開始呢?
  自然先到Cocos2d-x官网下载对应版本号的引擎,笔者这里是Cocos2d-x 3.1.1
  下载完毕后,希望童鞋们自己试着去搭建好开发环境,网络和笔者前面的博客均有介绍,笔者在这里就不多说了。
  最好要在win32平台、Android平台都执行成功过HelloWorld,有了这个基础之后,就能够找样例学习了。
 Cocos2d-x 3.1.1样例的代码在cocos2d-x-3.1.1\tests下:
 
这里就有我们的C++代码和Lua代码,我们要学习的是Lua项目,怎么执行这些项目呢,看下图:
双击使用Visual Studio打开,笔者这里是2012的。
  
右键设置lua-tests为启动项目,然后进行编译执行,成功之后的效果例如以下:
从这些样例,我们能够了解到Cocos2d-x全部相关API所能实现的基础效果,笔者觉得没有不论什么学习资料能比得上这些样例了。
怎么查看实现以上效果的Lua代码呢,以下笔者会给大家介绍。
笔者用到的一个开发工具是LDT,童鞋们能够到这里下载:http://www.eclipse.org/koneki/ldt/
打开LDT,切换工作空间到我们的lua-tests项目中,例如以下:
然后新建Lua项目,取名为src,这样我们就能够把当前文件夹下src全部的Lua代码都包括进来了:
这样我们就能够非常方便查看每个样例的Lua代码,查看它的具体实现。
我们的Lua项目的入口在哪里呢?
打开win32项目,找到AppDelegate.cpp,打开查看:
#include "cocos2d.h"
#include "AppDelegate.h"
#include "CCLuaEngine.h"
#include "audio/include/SimpleAudioEngine.h"
#include "lua_assetsmanager_test_sample.h" using namespace CocosDenshion; USING_NS_CC; AppDelegate::AppDelegate()
{
} AppDelegate::~AppDelegate()
{
SimpleAudioEngine::end();
} bool AppDelegate::applicationDidFinishLaunching()
{
// 获得导演类实例
auto director = Director::getInstance();
// 获取渲染全部东西的 EGLView NA NA
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLView::createWithRect("Lua Tests", Rect(0,0,900,640));
director->setOpenGLView(glview);
} // turn on display FPS
// 打开显示帧屏
director->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this
// 设置游戏画面每秒显示的帧数,默认是60帧。
director->setAnimationInterval(1.0 / 60); // 获得屏幕大小
auto screenSize = glview->getFrameSize(); // 获得设计大小
auto designSize = Size(480, 320); if (screenSize.height > 320)
{
auto resourceSize = Size(960, 640);
director->setContentScaleFactor(resourceSize.height/designSize.height);
} // 设置屏幕设计分辨率
glview->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::FIXED_HEIGHT); // register lua engine
LuaEngine* pEngine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(pEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID ||CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
LuaStack* stack = pEngine->getLuaStack();
register_assetsmanager_test_sample(stack->getLuaState());
#endif
// 执行脚本语言
pEngine->executeScriptFile("src/controller.lua"); return true;
} // This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
Director::getInstance()->stopAnimation(); SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
} // this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
Director::getInstance()->startAnimation(); SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
}

我们会发现代码中这么一段:

pEngine->executeScriptFile("src/controller.lua");
这个就是我们的入口文件,我们执行Lua的代码是从controller.lua这个文件開始的。
我们用LDT查看一下它的代码:
-- avoid memory leak
-- 避免内存泄漏
collectgarbage("setpause", 100)
collectgarbage("setstepmul", 5000) require "src/mainMenu"
---------------- -- run local glView = cc.Director:getInstance():getOpenGLView()
local screenSize = glView:getFrameSize()
local designSize = {width = 480, height = 320}
local fileUtils = cc.FileUtils:getInstance() if screenSize.height > 320 then
local searchPaths = {}
table.insert(searchPaths, "hd")
fileUtils:setSearchPaths(searchPaths)
end local targetPlatform = cc.Application:getInstance():getTargetPlatform()
local resPrefix = ""
if cc.PLATFORM_OS_IPAD == targetPlatform or cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_MAC == targetPlatform then
resPrefix = ""
else
resPrefix = "res/"
end local searchPaths = fileUtils:getSearchPaths()
table.insert(searchPaths, 1, resPrefix)
table.insert(searchPaths, 1, resPrefix .. "cocosbuilderRes") if screenSize.height > 320 then
table.insert(searchPaths, 1, resPrefix .. "hd")
table.insert(searchPaths, 1, resPrefix .. "ccs-res")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/Images")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ArmatureComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/AttributeComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/BackgroundComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/EffectComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/LoadSceneEdtiorFileTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ParticleComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/SpriteComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TmxMapComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/UIComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TriggerTest")
else
table.insert(searchPaths, 1, resPrefix .. "ccs-res/Images")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ArmatureComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/AttributeComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/BackgroundComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/EffectComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/LoadSceneEdtiorFileTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ParticleComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/SpriteComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TmxMapComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/UIComponentTest")
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TriggerTest")
end fileUtils:setSearchPaths(searchPaths) -- 创建场景
local scene = cc.Scene:create()
-- 加入菜单
scene:addChild(CreateTestMenu())
if cc.Director:getInstance():getRunningScene() then
cc.Director:getInstance():replaceScene(scene)
else
-- 依据给定的场景进入 Director的主循环 仅仅能调用他执行你的第一个场景.
cc.Director:getInstance():runWithScene(scene)
end

然后我们就能够依据这个,来理清整个測试项目的脉路,我们或许想知道,样例中的那些菜单是怎么显示出来的,样例中又是怎样进行切换场景的。仅仅要我们知道怎样開始了,以后我们就能够慢慢分析每个样例所给我提供的代码。

在controller.lua文件里引入了maniMenu.lua
通过这个语句:require "src/mainMenu"
我们来看看mainMenu的代码:
-- 引入资源文件
require "Cocos2d"
require "Cocos2dConstants"
require "Opengl"
require "OpenglConstants"
require "StudioConstants"
require "GuiConstants"
require "src/helper"
require "src/testResource"
require "src/VisibleRect" require "src/AccelerometerTest/AccelerometerTest"
require "src/ActionManagerTest/ActionManagerTest"
require "src/ActionsEaseTest/ActionsEaseTest"
require "src/ActionsProgressTest/ActionsProgressTest"
require "src/ActionsTest/ActionsTest"
require "src/AssetsManagerTest/AssetsManagerTest"
require "src/BugsTest/BugsTest"
require "src/ClickAndMoveTest/ClickAndMoveTest"
require "src/CocosDenshionTest/CocosDenshionTest"
require "src/CocoStudioTest/CocoStudioTest"
require "src/CurrentLanguageTest/CurrentLanguageTest"
require "src/DrawPrimitivesTest/DrawPrimitivesTest"
require "src/EffectsTest/EffectsTest"
require "src/EffectsAdvancedTest/EffectsAdvancedTest"
require "src/ExtensionTest/ExtensionTest"
require "src/FontTest/FontTest"
require "src/IntervalTest/IntervalTest"
require "src/KeypadTest/KeypadTest"
require "src/LabelTest/LabelTest"
require "src/LabelTestNew/LabelTestNew"
require "src/LayerTest/LayerTest"
require "src/MenuTest/MenuTest"
require "src/MotionStreakTest/MotionStreakTest"
require "src/NewEventDispatcherTest/NewEventDispatcherTest"
require "src/NodeTest/NodeTest"
require "src/OpenGLTest/OpenGLTest"
require "src/ParallaxTest/ParallaxTest"
require "src/ParticleTest/ParticleTest"
require "src/PerformanceTest/PerformanceTest"
require "src/RenderTextureTest/RenderTextureTest"
require "src/RotateWorldTest/RotateWorldTest"
require "src/Sprite3DTest/Sprite3DTest"
require "src/SpriteTest/SpriteTest"
require "src/SceneTest/SceneTest"
require "src/SpineTest/SpineTest"
require "src/Texture2dTest/Texture2dTest"
require "src/TileMapTest/TileMapTest"
require "src/TouchesTest/TouchesTest"
require "src/TransitionsTest/TransitionsTest"
require "src/UserDefaultTest/UserDefaultTest"
require "src/ZwoptexTest/ZwoptexTest"
require "src/LuaBridgeTest/LuaBridgeTest"
require "src/XMLHttpRequestTest/XMLHttpRequestTest"
require "src/PhysicsTest/PhysicsTest" -- 行间距
local LINE_SPACE = 40 -- 当前位置
local CurPos = {x = 0, y = 0}
-- 開始位置
local BeginPos = {x = 0, y = 0} -- 定义一张表
local _allTests = {
{ isSupported = true, name = "Accelerometer" , create_func= AccelerometerMain },
{ isSupported = true, name = "ActionManagerTest" , create_func = ActionManagerTestMain },
{ isSupported = true, name = "ActionsEaseTest" , create_func = EaseActionsTest },
{ isSupported = true, name = "ActionsProgressTest" , create_func = ProgressActionsTest },
{ isSupported = true, name = "ActionsTest" , create_func = ActionsTest },
{ isSupported = true, name = "AssetsManagerTest" , create_func = AssetsManagerTestMain },
{ isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain },
{ isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain },
{ isSupported = true, name = "BugsTest" , create_func= BugsTestMain },
{ isSupported = false, name = "ChipmunkAccelTouchTest" , create_func= ChipmunkAccelTouchTestMain },
{ isSupported = true, name = "ClickAndMoveTest" , create_func = ClickAndMoveTest },
{ isSupported = true, name = "CocosDenshionTest" , create_func = CocosDenshionTestMain },
{ isSupported = true, name = "CocoStudioTest" , create_func = CocoStudioTestMain },
{ isSupported = false, name = "CurlTest" , create_func= CurlTestMain },
{ isSupported = true, name = "CurrentLanguageTest" , create_func= CurrentLanguageTestMain },
{ isSupported = true, name = "DrawPrimitivesTest" , create_func= DrawPrimitivesTest },
{ isSupported = true, name = "EffectsTest" , create_func = EffectsTest },
{ isSupported = true, name = "EffectAdvancedTest" , create_func = EffectAdvancedTestMain },
{ isSupported = true, name = "ExtensionsTest" , create_func= ExtensionsTestMain },
{ isSupported = true, name = "FontTest" , create_func = FontTestMain },
{ isSupported = true, name = "IntervalTest" , create_func = IntervalTestMain },
{ isSupported = true, name = "KeypadTest" , create_func= KeypadTestMain },
{ isSupported = true, name = "LabelTest" , create_func = LabelTest },
{ isSupported = true, name = "LabelTestNew" , create_func = LabelTestNew },
{ isSupported = true, name = "LayerTest" , create_func = LayerTestMain },
{ isSupported = true, name = "LuaBridgeTest" , create_func = LuaBridgeMainTest },
{ isSupported = true, name = "MenuTest" , create_func = MenuTestMain },
{ isSupported = true, name = "MotionStreakTest" , create_func = MotionStreakTest },
{ isSupported = false, name = "MutiTouchTest" , create_func= MutiTouchTestMain },
{ isSupported = true, name = "NewEventDispatcherTest" , create_func = NewEventDispatcherTest },
{ isSupported = true, name = "NodeTest" , create_func = CocosNodeTest },
{ isSupported = true, name = "OpenGLTest" , create_func= OpenGLTestMain },
{ isSupported = true, name = "ParallaxTest" , create_func = ParallaxTestMain },
{ isSupported = true, name = "ParticleTest" , create_func = ParticleTest },
{ isSupported = true, name = "PerformanceTest" , create_func= PerformanceTestMain },
{ isSupported = true, name = "PhysicsTest" , create_func = PhysicsTest },
{ isSupported = true, name = "RenderTextureTest" , create_func = RenderTextureTestMain },
{ isSupported = true, name = "RotateWorldTest" , create_func = RotateWorldTest },
{ isSupported = true, name = "SceneTest" , create_func = SceneTestMain },
{ isSupported = true, name = "SpineTest" , create_func = SpineTestMain },
{ isSupported = false, name = "SchdulerTest" , create_func= SchdulerTestMain },
{ isSupported = false, name = "ShaderTest" , create_func= ShaderTestMain },
{ isSupported = true, name = "Sprite3DTest" , create_func = Sprite3DTest },
{ isSupported = true, name = "SpriteTest" , create_func = SpriteTest },
{ isSupported = false, name = "TextInputTest" , create_func= TextInputTestMain },
{ isSupported = true, name = "Texture2DTest" , create_func = Texture2dTestMain },
{ isSupported = false, name = "TextureCacheTest" , create_func= TextureCacheTestMain },
{ isSupported = true, name = "TileMapTest" , create_func = TileMapTestMain },
{ isSupported = true, name = "TouchesTest" , create_func = TouchesTest },
{ isSupported = true, name = "TransitionsTest" , create_func = TransitionsTest },
{ isSupported = true, name = "UserDefaultTest" , create_func= UserDefaultTestMain },
{ isSupported = true, name = "XMLHttpRequestTest" , create_func = XMLHttpRequestTestMain },
{ isSupported = true, name = "ZwoptexTest" , create_func = ZwoptexTestMain }
} local TESTS_COUNT = table.getn(_allTests) -- create scene 创建场景
local function CreateTestScene(nIdx)
cc.Director:getInstance():purgeCachedData()
local scene = _allTests[nIdx].create_func()
return scene
end
-- create menu 创建菜单
function CreateTestMenu()
-- 菜单层
local menuLayer = cc.Layer:create() local function closeCallback()
-- 结束执行,释放正在执行的场景。
cc.Director:getInstance():endToLua()
end -- 菜单回调
local function menuCallback(tag)
print(tag)
local Idx = tag - 10000
local testScene = CreateTestScene(Idx)
if testScene then
-- 切换场景
cc.Director:getInstance():replaceScene(testScene)
end
end -- add close menu 加入关闭菜单
local s = cc.Director:getInstance():getWinSize()
local CloseItem = cc.MenuItemImage:create(s_pPathClose, s_pPathClose)
CloseItem:registerScriptTapHandler(closeCallback)
CloseItem:setPosition(cc.p(s.width - 30, s.height - 30)) local CloseMenu = cc.Menu:create()
CloseMenu:setPosition(0, 0)
CloseMenu:addChild(CloseItem)
menuLayer:addChild(CloseMenu)
-- 获取目标平台
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) then
CloseMenu:setVisible(false)
end -- add menu items for tests
-- 加入菜单项
local MainMenu = cc.Menu:create()
local index = 0
local obj = nil
for index, obj in pairs(_allTests) do
-- 创建文本(obj.name 为文本名称, s_arialPath为字体,24为字体大小)
local testLabel = cc.Label:createWithTTF(obj.name, s_arialPath, 24)
-- 设置锚点
testLabel:setAnchorPoint(cc.p(0.5, 0.5))
-- 创建菜单项标签
local testMenuItem = cc.MenuItemLabel:create(testLabel)
-- 假设此项不支持,则设置菜单项不可用
if not obj.isSupported then
testMenuItem:setEnabled(false)
end
-- 注冊脚本处理句柄
testMenuItem:registerScriptTapHandler(menuCallback)
-- 设置菜单标签显示的位置,设置到居中的位置
testMenuItem:setPosition(cc.p(s.width / 2, (s.height - (index) * LINE_SPACE)))
-- 加入菜单项到菜单中去
MainMenu:addChild(testMenuItem, index + 10000, index + 10000)
end -- 设置菜单内容大小
MainMenu:setContentSize(cc.size(s.width, (TESTS_COUNT + 1) * (LINE_SPACE)))
MainMenu:setPosition(CurPos.x, CurPos.y)
-- 将菜单加入到层中去
menuLayer:addChild(MainMenu) -- handling touch events
-- 处理触摸事件
local function onTouchBegan(touch, event)
-- 获取触摸点的位置
BeginPos = touch:getLocation()
-- CCTOUCHBEGAN event must return true
return true
end -- 手指移动时触发
local function onTouchMoved(touch, event)
local location = touch:getLocation()
local nMoveY = location.y - BeginPos.y
local curPosx, curPosy = MainMenu:getPosition()
local nextPosy = curPosy + nMoveY
local winSize = cc.Director:getInstance():getWinSize()
if nextPosy < 0 then
MainMenu:setPosition(0, 0)
return
end if nextPosy > ((TESTS_COUNT + 1) * LINE_SPACE - winSize.height) then
MainMenu:setPosition(0, ((TESTS_COUNT + 1) * LINE_SPACE - winSize.height))
return
end --
MainMenu:setPosition(curPosx, nextPosy)
BeginPos = {x = location.x, y = location.y}
CurPos = {x = curPosx, y = nextPosy}
end -- 创建事件监听器
local listener = cc.EventListenerTouchOneByOne:create()
-- 注冊事件监听
listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
listener:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )
-- 获取事件派发器
local eventDispatcher = menuLayer:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, menuLayer) return menuLayer
end

我们就能够发现,这里就是界面中菜单的实现,mainMenu中还引入了其它文件,比方testResource.lua

s_pPathGrossini       = "Images/grossini.png"
s_pPathSister1 = "Images/grossinis_sister1.png"
s_pPathSister2 = "Images/grossinis_sister2.png"
s_pPathB1 = "Images/b1.png"
s_pPathB2 = "Images/b2.png"
s_pPathR1 = "Images/r1.png"
s_pPathR2 = "Images/r2.png"
s_pPathF1 = "Images/f1.png"
s_pPathF2 = "Images/f2.png"
s_pPathBlock = "Images/blocks.png"
s_back = "Images/background.png"
s_back1 = "Images/background1.png"
s_back2 = "Images/background2.png"
s_back3 = "Images/background3.png"
s_stars1 = "Images/stars.png"
s_stars2 = "Images/stars2.png"
s_fire = "Images/fire.png"
s_snow = "Images/snow.png"
s_streak = "Images/streak.png"
s_PlayNormal = "Images/btn-play-normal.png"
s_PlaySelect = "Images/btn-play-selected.png"
s_AboutNormal = "Images/btn-about-normal.png"
s_AboutSelect = "Images/btn-about-selected.png"
s_HighNormal = "Images/btn-highscores-normal.png"
s_HighSelect = "Images/btn-highscores-selected.png"
s_Ball = "Images/ball.png"
s_Paddle = "Images/paddle.png"
s_pPathClose = "Images/close.png"
s_MenuItem = "Images/menuitemsprite.png"
s_SendScore = "Images/SendScoreButton.png"
s_PressSendScore = "Images/SendScoreButtonPressed.png"
s_Power = "Images/powered.png"
s_AtlasTest = "Images/atlastest.png" -- tilemaps resource
s_TilesPng = "TileMaps/tiles.png"
s_LevelMapTga = "TileMaps/levelmap.tga" -- spine test resource
s_pPathSpineBoyJson = "spine/spineboy.json"
s_pPathSpineBoyAtlas = "spine/spineboy.atlas" -- fonts resource
s_markerFeltFontPath = "fonts/Marker Felt.ttf"
s_arialPath = "fonts/arial.ttf"
s_thonburiPath = "fonts/Thonburi.ttf"
s_tahomaPath = "fonts/tahoma.ttf"

这个文件定义了全部的资源路径,一些图片、json资源、字体资源等。

其它相关的文件,笔者在这里就不贴代码,这个大家私下去查看,我在这里仅仅是提供相关的思路,让大家理清怎样使用Cocos2d-x给我们提供的样例进行学习。
下一篇博客,笔者将会介绍第一个样例-重力加速器,非常感谢你的关注。

Cocos2d-x 3.1.1 lua-tests 开篇的更多相关文章

  1. Cocos2d Lua 越来越小样本 内存游戏

    1.游戏简介 一个"记忆"类的比赛游戏.你和电脑对战,轮到谁的回合,谁翻两张牌,假设两张牌一样.就消掉这两张牌,得2分,能够继续翻牌,假设两张牌不一样,就换一个人.直到最后.看谁的 ...

  2. 在cocos code ide的基础上构建自己的lua开发调试环境

    对于一种语言,其所谓开发调试环境, 大体有以下两方面的内容: 1.开发, 即代码编写, 主要是代码提示.补齐, 更高级一点的如变量名颜色等. 2.调试, 主要是运行状态下断点.查看变量.堆栈等. 现在 ...

  3. cocos2d-x 使用Lua

    转自:http://www.benmutou.com/blog/archives/49 1. Lua的堆栈和全局表 我们来简单解释一下Lua的堆栈和全局表,堆栈大家应该会比较熟悉,它主要是用来让C++ ...

  4. Cocos Code IDE + Lua初次使用FastTiledMap的坑

    近期想玩玩Lua.又想玩玩Cocos Code IDE.更加想写一个即时战斗的.防守的.会动的.有迷雾的.要探索的(旁白:给我停!)跑地图游戏. 于是我就用Cocos Code IDE来写游戏了.挑战 ...

  5. LTUI v1.1, 一个基于lua的跨平台字符终端UI界面库

    简介 LTUI是一个基于lua的跨平台字符终端UI界面库. 此框架源于xmake中图形化菜单配置的需求,类似linux kernel的menuconf去配置编译参数,因此基于curses和lua实现了 ...

  6. 关于Protobuf在游戏开发中的运用

    最近在研究protobuf在项目中的使用,由于我们项目服务端采用的是C++,客户端是cocos2dx-cpp,客户端与服务端的消息传输是直接对象的二进制流.如果客户端一直用C++来写,问题到不大,但是 ...

  7. A*算法实现

    A* 算法非常简单.算法维护两个集合:OPEN 集和 CLOSED 集.OPEN 集包含待检测节点.初始状态,OPEN集仅包含一个元素:开始位置.CLOSED集包含已检测节点.初始状态,CLOSED集 ...

  8. Windows 安装 python2.7

    Windows 安装 python2.7 python2.7下载地址: https://www.python.org/downloads/release/python-2714/ 安装过程: 设置系统 ...

  9. 数据库性能测试:sysbench用法详解

    1.简介和安装 sysbench是一个很不错的数据库性能测试工具. 官方站点:https://github.com/akopytov/sysbench/ rpm包下载:https://packagec ...

随机推荐

  1. Java进阶01 String类

    链接地址:http://www.cnblogs.com/vamei/archive/2013/04/08/3000914.html 作者:Vamei 出处:http://www.cnblogs.com ...

  2. 基于集合成工控机Ubuntu系统安装分区详解

    基于集合成工控机Ubuntu系统安装分区详解 硬件描述:双核的CPU,128G的固态硬盘 软件描述:使用Ubuntu12.04系统,内核3.8.0-29版本,QT4.8.1版本 1.新建分区表 /de ...

  3. log4net使用流程

    前面大致介绍了一下log4net的概述和结构.既然都清楚了,下面我来介绍一下如何使用log4net. 使用流程 1.这里所说的使用流程就是使用log4net.dll,首先要根据你的平台来找出对应的版本 ...

  4. maven项目部署到Repository(Nexus)

    目录[-] (一)下载并安装Nexus (二)配置Nexus Repository 说明: (三)在项目中配置Nexus Repository的信息 (四)发布到Nexus Repository 本文 ...

  5. Can't call commit when autocommit=true(转)

    java.sql.SQLException: Can't call commit when autocommit=true at com.mysql.jdbc.SQLError.createSQLEx ...

  6. android multicast 多播(组播)问题

    有谁遇到过同样问题的可以探讨下,或者已经解决问题的,能够指导下我    获取组播锁 private  InetAddress   group; WifiManager  wm=(WifiManager ...

  7. Effective C++_笔记_条款08_别让异常逃离析构函数

    (整理自Effctive C++,转载请注明.整理者:华科小涛@http://www.cnblogs.com/hust-ghtao/) C++并不禁止析构函数吐出异常,但它不鼓励你这样做.考虑如下代码 ...

  8. 大数据实时处理-基于Spark的大数据实时处理及应用技术培训

    随着互联网.移动互联网和物联网的发展,我们已经切实地迎来了一个大数据 的时代.大数据是指无法在一定时间内用常规软件工具对其内容进行抓取.管理和处理的数据集合,对大数据的分析已经成为一个非常重要且紧迫的 ...

  9. Swift - 导航条(UINavigationBar)的使用

    与导航控制器(UINavigationController)同时实现导航条和页面切换功能不同. 导航条(UINavgationBar)可以单独使用,添加至任何的UIView中.UINavigation ...

  10. Spinner的用法实现

    界面上只有一个textview和一个spinner,实现下拉列表框. spinner.xml: <?xml version="1.0" encoding="utf- ...