- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我的项目在 iPhone 6 上以 55-60FPS 的速度运行,但任何旧版本都完全无法播放,因为某些东西正在占用 CPU。
我认为问题与 map 上的图 block 和层数有关(64x256,4 层),Instruments 显示“SKCRenderer:preprocessSpriteImp(...”运行时间为 5198 毫秒 (23.2%)。
JSTileMap 是否一次加载每个图 block 的图像(可见或不可见)? RW 的这篇文章表明情况确实如此,并且可以通过解决它来大幅提升性能: http://www.raywenderlich.com/forums/viewtopic.php?f=29&t=9479
In another performance note - Sprite Kit checks all it's nodes and decides which ones it needs to display each frame. If you have a big tile map, this can be a big performance hit. JSTileMap loads all the nodes (SKSpriteNode for each tile) when it loads the tile map. So, I was also seeing performance issues in the Sprite Kit version with my maps (which are 500 x 40 tiles). I added a check to my version of JSTileMap that's included in the kit that marks the hidden property of each tile, then intelligently unhides and hides only the tiles that enter/exit the screen space. That increased performance on these larger maps significantly.
不幸的是,该帖子没有详细说明为解决此问题所采取的步骤。
我的第一个想法是(我是初学者,请保持温和)通过遍历每个点并检查特定层上的图 block 来创建一个节点数组。从那里我会根据与玩家的距离添加/删除它们。
这没有用,因为向数组添加节点的过程只会导致应用在较大的 map 上永远挂起。
有人可以帮忙吗?我喜欢使用更大/更复杂的图 block map ,但这个性能问题正在毁掉我的大脑。
感谢阅读!
更新:非常感谢 SKAToolKit: https://github.com/SpriteKitAlliance/SKAToolKit
他们的剔除功能解决了我的问题,我现在可以用不到 35% 的 CPU 运行更大的 map 。
最佳答案
JSTileMap 在处理较大的 map 时会遇到一些问题,但您确实有几个选项需要考虑:
我个人发现无法使用 JSTileMap 完成#3,因为我找不到包含 map 图 block 的数组。我使用 SKAToolKit 解决了这个问题它提供了对 map 图 block 阵列的轻松访问。它是解析在 Tiled 中创建的 map 的绝佳资源。
关于ios - SpriteKit 在运行带有大型 tilemap (JSTileMap) 的游戏时使用 95-100% CPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30749955/
我在 cocos2d-x 中使用等距 tilemap,我面临的一个问题与深度管理有关。玩家 Sprite 没有正确地隐藏在放置在不同瓷砖 map 层上的树木和房屋后面。我已申请 cc_vertexz
我正在尝试制作一个 TileMap,但是当我去渲染tileMap 并迭代 map 中的所有整数时,我得到一个ArrayIndexOutOfBoundsException。 这是渲染方法: public
我正在开发一个小应用程序,我在其中将 tilemap ( JSTilemap ) 加载到 sprite kit 中。 这一切都很好,除了瓦片 map 在纵向上看起来正常而且很好,但是当我翻转到横向时它
我在做一些本应非常简单的事情时遇到了一些麻烦。我无法让瓷砖的地板显示在背景图片上方。然而,我可以让我的所有其他游戏对象从我的控制面板显示到我的 HUD,甚至是在同一个瓷砖 map 中设置的硬币和怪物。
如何在基于 2D 图 block 的游戏中映射负 map 坐标?前任。 (-180,100)或 (10, -8) 我需要用 O(1) 来访问它们。我不想创建一个巨大的二维 vector 并将 (500
我正在创建一个 2d 横向卷轴游戏并且有一个关于碰撞的问题。我一直在阅读各种文章,其中一些文章说您应该有一个碰撞层,它与平铺层的样式完全相同,但只是存储位。我理解这个逻辑,但如果我的图 block 实
我用周围瓷砖的所有可能组合制作了一个自定义组。 我将它与我的 TileMap 上启用的自动映射模式一起使用,结果如下: 如您所见,有几个错误: 我以编程方式和在编辑器中都尝试过。行为是相同的。 我的想
我尝试了很多不同的解决方案,但我不太确定这是否是问题所在使用我的方法或者如果代码不起作用 例如, 我希望能够在我最初设置的值中设置下面数组中的值,这是我的尝试 function makepointfr
我找不到解决问题的方法。我平铺了一个图像并将其保存到一个位图数组中。现在我想把它填成一个 7 x 7 的网格。我需要这样做,因为我想访问并可能更改单个磁贴。我尝试了 Gridview,但似乎我只能设置
下面的代码应该用空格替换 tilemap 索引,但是没有任何反应。 瓷砖 map : var tilemap = [ "wwwwwwwwwwwwwwww", "wmmmmmmmmm
我希望用户在那里选择 map 大小,所以我不知道运行时 map 的大小。我一直在寻找如何实现这一点,但收效甚微。最接近正常工作的是 vector 变体,但在它运行时仍然无法正常工作。 我想要一个 3
我有两个瓷砖 map 。可以使用 WASD 移动一个(瓦片会立即移动到新位置),我想检测此瓦片 map 的瓦片何时与另一个瓦片 map 的瓦片发生碰撞。 两者都有 tilemapcollider2d
我使用 SDL 编写了一个显示相当大的瓷砖 map (大约 240*240 瓷砖)的模拟。由于我对 SDL 库还很陌生,所以我真的无法判断渲染超过 50,000 个图 block 时相当慢的性能是否真
我有兴趣尝试为 2D 游戏创建逼真的流体(水)。这个游戏类似于泰拉瑞亚。我听说过如何在场景中拍打一堆碰撞粒子并在其上进行渲染,瞧,逼真的水。 Terraria 使用基于瓷砖的水,我不喜欢它……我想要更
我正在计划使用 SpriteKit 和 Swift 为 iOS 开发一款平台游戏。我研究了如何处理玩家 Sprite 的碰撞并偶然发现了这篇文章。 http://www.learn-cocos2d.c
我正在使用 SDL2 编写一个在每一帧都显示瓦片 map 的游戏,但性能太慢了。我写了一个小程序来隔离问题。假设“temp.bmp”是一张 16x16 的图像。 #include #include
我正在寻找一种方法来创建一种新型的六边形规则图 block 来完成一些相当简单和具体的事情。我想创建一个六边形规则图 block ,该图 block 能够根据与它相邻的其他类型的六角形图 block
我正在尝试在运行时将我的一个可编写脚本的图块添加到我的 Unity Tilemap 中。我可以在编辑器中绘制磁贴,一切看起来都很好,但我想在运行时添加它。 我尝试实例化 ScriptableObjec
我使用 Tiled 软件创建了以下 map ,我想让箱子发挥作用。实际上,我想知道玩家和宝箱何时重叠,但即使搜索了几个小时我也找不到解决方案。 我正在使用 ARCADE 物理。我尝试使用对象层但没有任
这是我现在用来尝试生成 tilemap 的代码: // --- Javascript --- window.onload = function (){ var can = document.get
我是一名优秀的程序员,十分优秀!