Cocos2d-x 3(2),2024Android大厂面试经验分享_cocos2d-x 2024年-程序员宅基地

技术标签: 2024年程序员学习  游戏引擎  cocos2d  

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给我们提供的例子进行学习。

下一篇博客,笔者将会介绍第一个例子-重力加速器,非常感谢你的关注。

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
img

设计模式学习笔记

设计模式系列学习视频

很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**
[外链图片转存中…(img-grpow78S-1711179907786)]
[外链图片转存中…(img-aiy0MVoo-1711179907787)]
[外链图片转存中…(img-jNgbmki7-1711179907787)]
[外链图片转存中…(img-IzrYyB0E-1711179907787)]

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
[外链图片转存中…(img-Y3cR5xjy-1711179907788)]

设计模式学习笔记

[外链图片转存中…(img-aiTZBQC8-1711179907788)]

设计模式系列学习视频

[外链图片转存中…(img-hhaTtOkM-1711179907789)]

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/2401_83740107/article/details/136968817

智能推荐

hive使用适用场景_大数据入门:Hive应用场景-程序员宅基地

文章浏览阅读5.8k次。在大数据的发展当中,大数据技术生态的组件,也在不断地拓展开来,而其中的Hive组件,作为Hadoop的数据仓库工具,可以实现对Hadoop集群当中的大规模数据进行相应的数据处理。今天我们的大数据入门分享,就主要来讲讲,Hive应用场景。关于Hive,首先需要明确的一点就是,Hive并非数据库,Hive所提供的数据存储、查询和分析功能,本质上来说,并非传统数据库所提供的存储、查询、分析功能。Hive..._hive应用场景

zblog采集-织梦全自动采集插件-织梦免费采集插件_zblog 网页采集插件-程序员宅基地

文章浏览阅读496次。Zblog是由Zblog开发团队开发的一款小巧而强大的基于Asp和PHP平台的开源程序,但是插件市场上的Zblog采集插件,没有一款能打的,要么就是没有SEO文章内容处理,要么就是功能单一。很少有适合SEO站长的Zblog采集。人们都知道Zblog采集接口都是对Zblog采集不熟悉的人做的,很多人采取模拟登陆的方法进行发布文章,也有很多人直接操作数据库发布文章,然而这些都或多或少的产生各种问题,发布速度慢、文章内容未经严格过滤,导致安全性问题、不能发Tag、不能自动创建分类等。但是使用Zblog采._zblog 网页采集插件

Flink学习四:提交Flink运行job_flink定时运行job-程序员宅基地

文章浏览阅读2.4k次,点赞2次,收藏2次。restUI页面提交1.1 添加上传jar包1.2 提交任务job1.3 查看提交的任务2. 命令行提交./flink-1.9.3/bin/flink run -c com.qu.wc.StreamWordCount -p 2 FlinkTutorial-1.0-SNAPSHOT.jar3. 命令行查看正在运行的job./flink-1.9.3/bin/flink list4. 命令行查看所有job./flink-1.9.3/bin/flink list --all._flink定时运行job

STM32-LED闪烁项目总结_嵌入式stm32闪烁led实验总结-程序员宅基地

文章浏览阅读1k次,点赞2次,收藏6次。这个项目是基于STM32的LED闪烁项目,主要目的是让学习者熟悉STM32的基本操作和编程方法。在这个项目中,我们将使用STM32作为控制器,通过对GPIO口的控制实现LED灯的闪烁。这个STM32 LED闪烁的项目是一个非常简单的入门项目,但它可以帮助学习者熟悉STM32的编程方法和GPIO口的使用。在这个项目中,我们通过对GPIO口的控制实现了LED灯的闪烁。LED闪烁是STM32入门课程的基础操作之一,它旨在教学生如何使用STM32开发板控制LED灯的闪烁。_嵌入式stm32闪烁led实验总结

Debezium安装部署和将服务托管到systemctl-程序员宅基地

文章浏览阅读63次。本文介绍了安装和部署Debezium的详细步骤,并演示了如何将Debezium服务托管到systemctl以进行方便的管理。本文将详细介绍如何安装和部署Debezium,并将其服务托管到systemctl。解压缩后,将得到一个名为"debezium"的目录,其中包含Debezium的二进制文件和其他必要的资源。注意替换"ExecStart"中的"/path/to/debezium"为实际的Debezium目录路径。接下来,需要下载Debezium的压缩包,并将其解压到所需的目录。

Android 控制屏幕唤醒常亮或熄灭_android实现拿起手机亮屏-程序员宅基地

文章浏览阅读4.4k次。需求:在诗词曲文项目中,诗词整篇朗读的时候,文章没有读完会因为屏幕熄灭停止朗读。要求:在文章没有朗读完毕之前屏幕常亮,读完以后屏幕常亮关闭;1.权限配置:设置电源管理的权限。

随便推点

目标检测简介-程序员宅基地

文章浏览阅读2.3k次。目标检测简介、评估标准、经典算法_目标检测

记SQL server安装后无法连接127.0.0.1解决方法_sqlserver 127 0 01 无法连接-程序员宅基地

文章浏览阅读6.3k次,点赞4次,收藏9次。实训时需要安装SQL server2008 R所以我上网上找了一个.exe 的安装包链接:https://pan.baidu.com/s/1_FkhB8XJy3Js_rFADhdtmA提取码:ztki注:解压后1.04G安装时Microsoft需下载.NET,更新安装后会自动安装如下:点击第一个傻瓜式安装,唯一注意的是在修改路径的时候如下不可修改:到安装实例的时候就可以修改啦数据..._sqlserver 127 0 01 无法连接

js 获取对象的所有key值,用来遍历_js 遍历对象的key-程序员宅基地

文章浏览阅读7.4k次。1. Object.keys(item); 获取到了key之后就可以遍历的时候直接使用这个进行遍历所有的key跟valuevar infoItem={ name:'xiaowu', age:'18',}//的出来的keys就是[name,age]var keys=Object.keys(infoItem);2. 通常用于以下实力中 <div *ngFor="let item of keys"> <div>{{item}}.._js 遍历对象的key

粒子群算法(PSO)求解路径规划_粒子群算法路径规划-程序员宅基地

文章浏览阅读2.2w次,点赞51次,收藏310次。粒子群算法求解路径规划路径规划问题描述    给定环境信息,如果该环境内有障碍物,寻求起始点到目标点的最短路径, 并且路径不能与障碍物相交,如图 1.1.1 所示。1.2 粒子群算法求解1.2.1 求解思路    粒子群优化算法(PSO),粒子群中的每一个粒子都代表一个问题的可能解, 通过粒子个体的简单行为,群体内的信息交互实现问题求解的智能性。    在路径规划中,我们将每一条路径规划为一个粒子,每个粒子群群有 n 个粒 子,即有 n 条路径,同时,每个粒子又有 m 个染色体,即中间过渡点的_粒子群算法路径规划

量化评价:稳健的业绩评价指标_rar 海龟-程序员宅基地

文章浏览阅读353次。所谓稳健的评估指标,是指在评估的过程中数据的轻微变化并不会显著的影响一个统计指标。而不稳健的评估指标则相反,在对交易系统进行回测时,参数值的轻微变化会带来不稳健指标的大幅变化。对于不稳健的评估指标,任何对数据有影响的因素都会对测试结果产生过大的影响,这很容易导致数据过拟合。_rar 海龟

IAP在ARM Cortex-M3微控制器实现原理_value line devices connectivity line devices-程序员宅基地

文章浏览阅读607次,点赞2次,收藏7次。–基于STM32F103ZET6的UART通讯实现一、什么是IAP,为什么要IAPIAP即为In Application Programming(在应用中编程),一般情况下,以STM32F10x系列芯片为主控制器的设备在出厂时就已经使用J-Link仿真器将应用代码烧录了,如果在设备使用过程中需要进行应用代码的更换、升级等操作的话,则可能需要将设备返回原厂并拆解出来再使用J-Link重新烧录代码,这就增加了很多不必要的麻烦。站在用户的角度来说,就是能让用户自己来更换设备里边的代码程序而厂家这边只需要提供给_value line devices connectivity line devices