问题标签 [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.
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.
- required: create the window and fill it with information.
- optional: anchor to tile and/or center in the screen. I haven't decided best solution yet.
- 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.
ios - 离机时SKTileMapNode消失,不再出现
我有一个使用平铺地图作为背景的 SpriteKit 平台游戏。有问题的背景位于主要内容上方 1 个屏幕高度(位于屏幕外),充当玩家上方的森林树冠。我以编程方式完成,如下所示:
一个摄像机节点跟随玩家。
问题:如果玩家跳起来,SKTileMapNode
当他下来时消失。它永远不会再次出现。它的父节点 ,container
仍然可见,所以我认为问题出在SKTileMapNode
, 而不是container
.
我尝试了什么:
我尝试了以下方法,并检查了数字 2-5 SKTileMapNode
:
- 设置
view.shouldCullNonVisibleNodes = false
。 - 检查
alpha
值。它总是1.0
。 - 检查
position
. 它总是CGPoint(x: 0, y: 0)
。 - 检查
anchorPoint
. 它总是CGPoint(x: 0.5, y: 0.5)
。 - 检查
zPosition
. 它不会改变,并且没有其他节点可以遮盖它SKTileMapNode
或其父节点。设置更高的值对问题没有影响。 - 检查是否
container
仍然可见。确实如此。
关于剔除:
似乎问题应该与剔除有关,但设置view.shouldCullNonVisibleNodes=false
对情况没有影响。我还检查以确保SKTileMapNode
始终作为container
. 这是。我想这意味着该节点没有被剔除。但是,如果我将其定位container
为始终在屏幕上,则根本不会出现问题;SKTileMapNode
遗骸可见。这让我很困惑,因为这些似乎是相互矛盾的事实。
在设备上: 至少使用模拟器,问题不会出现在 SE 和 iPhone 8 等旧款 iPhone 上。它只会出现在 iPhone 11 和 iPhone 12 等较新的 iPhone 上。 iPhone 11,我可以确认问题也发生在真实设备上。
问题:为什么我SKTileMapNode
在离机时消失了(即使禁用了剔除)?如何保持此节点可见?
谢谢!
swift - 在 Xcode 中使用 Tile Map Editor 剔除图块
我在 Xcode Tile Map Editor 中创建了一个 skTileMapNode,我以编程方式将其移至左侧。然而,似乎有时瓷砖在离开屏幕之前被移除/剔除,如此处链接的视频所示:
我试过设置 shouldCullNonVisibleNodes = false 但没有效果。
在 xcode 中是否有某种我不知道的垃圾收集?
swift - 如何在目标 C 中调用 SKTileSet init(named:)?
我能够在 xcode 上创建一个 SKTileSet 但似乎我很难通过这样的名称来初始化一个 SKTileSet:
https://developer.apple.com/documentation/spritekit/sktileset/1643819-init
这可以节省大量时间以编程方式创建整个集合、组、规则等......
谢谢!