问题标签 [sktilemapnode]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
64 浏览

swift - Equivalent of a popover in SpriteKit

I'm using Swift 5, SpriteKit, SKTileMap. I would like to use the equivalent of a popover. I'm using this term, because I use popovers rather frequently in other apps. Basically, a small window appears, and you read something and press OK, or maybe add a little information and press OK. What I'm trying to figure out how to do is something similar in SpriteKit.

The objective is, I want a user to long press a tile, and a small box pops up with information about the tile. What is the terrain? What resources are there? Is there a city? Is a player there? etc. It doesn't HAVE to be a view, but I'm guessing that's the way to go, because not only could there be quite a bit of text, I could see there being a button to dismiss, and maybe some tiny graphics, like a symbol corresponding to the resource, etc. Here's what I have already. I have a working long press gesture recognizer. I can already print all of the information I want to the console on the simulator. What I need to figure out is a few things.

  1. required: create the window and fill it with information.
  2. optional: anchor to tile and/or center in the screen. I haven't decided best solution yet.
  3. optional: dim background (probably just some alpha tweak)

The current code I have actually works very smooth. I have a good camera pinch to zoom and a good pan gesture. I load my map from a JSON file. I actually load it into a core data, database, and draw from a query against the database. That way, if you do any action, it just hits the database. What's on tile 5,5? just query the database. It works nice. I just don't know how to do the popover window in SpriteKit. I tried adding an actual popover to the content view my map is in, but it just dims the screen a little. I don't think that's a good anchor.

0 投票
1 回答
78 浏览

ios - 离机时SKTileMapNode消失,不再出现

我有一个使用平铺地图作为背景的 SpriteKit 平台游戏。有问题的背景位于主要内容上方 1 个屏幕高度(位于屏幕外),充当玩家上方的森林树冠。我以编程方式完成,如下所示:

一个摄像机节点跟随玩家。

问题:如果玩家跳起来,SKTileMapNode当他下来时消失。它永远不会再次出现。它的父节点 ,container仍然可见,所以我认为问题出在SKTileMapNode, 而不是container.

我尝试了什么: 我尝试了以下方法,并检查了数字 2-5 SKTileMapNode

  1. 设置view.shouldCullNonVisibleNodes = false
  2. 检查alpha值。它总是1.0
  3. 检查position. 它总是CGPoint(x: 0, y: 0)
  4. 检查anchorPoint. 它总是CGPoint(x: 0.5, y: 0.5)
  5. 检查zPosition. 它不会改变,并且没有其他节点可以遮盖它SKTileMapNode或其父节点。设置更高的值对问题没有影响。
  6. 检查是否container仍然可见。确实如此。

关于剔除: 似乎问题应该与剔除有关,但设置view.shouldCullNonVisibleNodes=false对情况没有影响。我还检查以确保SKTileMapNode始终作为container. 这是。我想这意味着该节点没有被剔除。但是,如果我将其定位container为始终屏幕上,则根本不会出现问题;SKTileMapNode遗骸可见。这让我很困惑,因为这些似乎是相互矛盾的事实。

在设备上: 至少使用模拟器,问题不会出现在 SE 和 iPhone 8 等旧款 iPhone 上。它只会出现在 iPhone 11 和 iPhone 12 等较新的 iPhone 上。 iPhone 11,我可以确认问题也发生在真实设备上。

问题:为什么我SKTileMapNode在离机时消失了(即使禁用了剔除)?如何保持此节点可见?

谢谢!

0 投票
0 回答
22 浏览

swift - 在 Xcode 中使用 Tile Map Editor 剔除图块

我在 Xcode Tile Map Editor 中创建了一个 skTileMapNode,我以编程方式将其移至左侧。然而,似乎有时瓷砖在离开屏幕之前被移除/剔除,如此处链接的视频所示:

https://youtu.be/oKy8DYunyiQ

我试过设置 shouldCullNonVisibleNodes = false 但没有效果。

在 xcode 中是否有某种我不知道的垃圾收集?

0 投票
1 回答
18 浏览

swift - 如何在目标 C 中调用 SKTileSet init(named:)?

我能够在 xcode 上创建一个 SKTileSet 但似乎我很难通过这样的名称来初始化一个 SKTileSet:

https://developer.apple.com/documentation/spritekit/sktileset/1643819-init

这可以节省大量时间以编程方式创建整个集合、组、规则等......

谢谢!