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

智能推荐

EasyDarwin开源流媒体云平台之EasyRMS录播服务器功能设计_开源录播系统-程序员宅基地

文章浏览阅读3.6k次。需求背景EasyDarwin开发团队维护EasyDarwin开源流媒体服务器也已经很多年了,之前也陆陆续续尝试过很多种服务端录像的方案,有:在EasyDarwin中直接解析收到的RTP包,重新组包录像;也有:在EasyDarwin中新增一个RecordModule,再以RTSPClient的方式请求127.0.0.1自己的直播流录像,但这些始终都没有成气候;我们的想法是能够让整套EasyDarwin_开源录播系统

oracle Plsql 执行update或者delete时卡死问题解决办法_oracle delete update 锁表问题-程序员宅基地

文章浏览阅读1.1w次。今天碰到一个执行语句等了半天没有执行:delete table XXX where ......,但是在select 的时候没问题。后来发现是在执行select * from XXX for update 的时候没有commit,oracle将该记录锁住了。可以通过以下办法解决: 先查询锁定记录 Sql代码 SELECT s.sid, s.seri_oracle delete update 锁表问题

Xcode Undefined symbols 错误_xcode undefined symbols:-程序员宅基地

文章浏览阅读3.4k次。报错信息error:Undefined symbol: typeinfo for sdk::IConfigUndefined symbol: vtable for sdk::IConfig具体信息:Undefined symbols for architecture x86_64: "typeinfo for sdk::IConfig", referenced from: typeinfo for sdk::ConfigImpl in sdk.a(config_impl.o) _xcode undefined symbols:

项目05(Mysql升级07Mysql5.7.32升级到Mysql8.0.22)_mysql8.0.26 升级32-程序员宅基地

文章浏览阅读249次。背景《承接上文,项目05(Mysql升级06Mysql5.6.51升级到Mysql5.7.32)》,写在前面需要(考虑)检查和测试的层面很多,不限于以下内容。参考文档https://dev.mysql.com/doc/refman/8.0/en/upgrade-prerequisites.htmllink推荐阅读以上链接,因为对应以下问题,有详细的建议。官方文档:不得存在以下问题:0.不得有使用过时数据类型或功能的表。不支持就地升级到MySQL 8.0,如果表包含在预5.6.4格_mysql8.0.26 升级32

高通编译8155源码环境搭建_高通8155 qnx 源码-程序员宅基地

文章浏览阅读3.7k次。一.安装基本环境工具:1.安装git工具sudo apt install wget g++ git2.检查并安装java等环境工具2.1、执行下面安装命令#!/bin/bashsudoapt-get-yinstall--upgraderarunrarsudoapt-get-yinstall--upgradepython-pippython3-pip#aliyunsudoapt-get-yinstall--upgradeopenjdk..._高通8155 qnx 源码

firebase 与谷歌_Firebase的好与不好-程序员宅基地

文章浏览阅读461次。firebase 与谷歌 大多数开发人员都听说过Google的Firebase产品。 这就是Google所说的“ 移动平台,可帮助您快速开发高质量的应用程序并发展业务。 ”。 它基本上是大多数开发人员在构建应用程序时所需的一组工具。 在本文中,我将介绍这些工具,并指出您选择使用Firebase时需要了解的所有内容。 在开始之前,我需要说的是,我不会详细介绍Firebase提供的所有工具。 我..._firsebase 与 google

随便推点

k8s挂载目录_kubernetes(k8s)的pod使用统一的配置文件configmap挂载-程序员宅基地

文章浏览阅读1.2k次。在容器化应用中,每个环境都要独立的打一个镜像再给镜像一个特有的tag,这很麻烦,这就要用到k8s原生的配置中心configMap就是用解决这个问题的。使用configMap部署应用。这里使用nginx来做示例,简单粗暴。直接用vim常见nginx的配置文件,用命令导入进去kubectl create cm nginx.conf --from-file=/home/nginx.conf然后查看kub..._pod mount目录会自动创建吗

java计算机毕业设计springcloud+vue基于微服务的分布式新生报到系统_关于spring cloud的参考文献有啥-程序员宅基地

文章浏览阅读169次。随着互联网技术的发发展,计算机技术广泛应用在人们的生活中,逐渐成为日常工作、生活不可或缺的工具,高校各种管理系统层出不穷。高校作为学习知识和技术的高等学府,信息技术更加的成熟,为新生报到管理开发必要的系统,能够有效的提升管理效率。一直以来,新生报到一直没有进行系统化的管理,学生无法准确查询学院信息,高校也无法记录新生报名情况,由此提出开发基于微服务的分布式新生报到系统,管理报名信息,学生可以在线查询报名状态,节省时间,提高效率。_关于spring cloud的参考文献有啥

VB.net学习笔记(十五)继承与多接口练习_vb.net 继承多个接口-程序员宅基地

文章浏览阅读3.2k次。Public MustInherit Class Contact '只能作基类且不能实例化 Private mID As Guid = Guid.NewGuid Private mName As String Public Property ID() As Guid Get Return mID End Get_vb.net 继承多个接口

【Nexus3】使用-Nexus3批量上传jar包 artifact upload_nexus3 批量上传jar包 java代码-程序员宅基地

文章浏览阅读1.7k次。1.美图# 2.概述因为要上传我的所有仓库的包,希望nexus中已有的包,我不覆盖,没有的添加。所以想批量上传jar。3.方案1-脚本批量上传PS:nexus3.x版本只能通过脚本上传3.1 批量放入jar在mac目录下,新建一个文件夹repo,批量放入我们需要的本地库文件夹,并对文件夹授权(base) lcc@lcc nexus-3.22.0-02$ mkdir repo2..._nexus3 批量上传jar包 java代码

关于去隔行的一些概念_mipi去隔行-程序员宅基地

文章浏览阅读6.6k次,点赞6次,收藏30次。本文转自http://blog.csdn.net/charleslei/article/details/486519531、什么是场在介绍Deinterlacer去隔行处理的方法之前,我们有必要提一下关于交错场和去隔行处理的基本知识。那么什么是场呢,场存在于隔行扫描记录的视频中,隔行扫描视频的每帧画面均包含两个场,每一个场又分别含有该帧画面的奇数行扫描线或偶数行扫描线信息,_mipi去隔行

ABAP自定义Search help_abap 自定义 search help-程序员宅基地

文章浏览阅读1.7k次。DATA L_ENDDA TYPE SY-DATUM. IF P_DATE IS INITIAL. CONCATENATE SY-DATUM(4) '1231' INTO L_ENDDA. ELSE. CONCATENATE P_DATE(4) '1231' INTO L_ENDDA. ENDIF. DATA: LV_RESET(1) TY_abap 自定义 search help