【发布时间】:2016-03-22 00:12:01
【问题描述】:
当我运行我的 SpriteKit 游戏时,我在控制台中多次收到此错误。据我所知(虽然我不完全确定),游戏本身不受影响,但该错误可能还有其他一些影响,以及拥挤的调试控制台。
我对该错误进行了一些研究,并找到了一些可能的解决方案,但似乎都没有完全奏效。这些解决方案包括将ignoresSiblingOrder 转换为false,并将纹理指定为SKTextureAtlas(named: "atlasName").textureNamed("textureName"),但这些都不起作用。
我认为错误来自资产目录中纹理和纹理图集的使用,尽管我不完全确定。以下是我如何实现其中一些纹理/图像:
let Texture = SKTextureAtlas(named: "character").textureNamed("\character1")
character = SKSpriteNode(texture: Texture)
还有:
let Atlas = SKTextureAtlas(named: "character")
var Frames = [SKTexture]()
let numImages = Atlas.textureNames.count
for var i=1; i<=numImages; i++ {
let textureName = "character(i)"
Frames.append(Atlas.textureNamed(textureName))
}
for var i=numImages; i>=1; i-- {
let TextureName = "character(i)"
Frames.append(Atlas.textureNamed(textureName))
}
let firstFrame = Frames[0]
character = SKSpriteNode(texture: firstFrame)
上面的代码只是用来创建一个数组来为角色设置动画,动画运行得很好。
对于我的所有其他精灵节点,我使用资产目录中的图像名称使用SKSpriteNode(imageNamed: "imageName") 进行初始化,但不在纹理图集中。所有图像都有@1x、@2x 和@3x 版本。
我不确定错误消息是否还有其他可能的来源,或者上面的示例是否是错误的来源。
这只是精灵套件的错误,还是我的代码或资产的合法错误?
谢谢!
【问题讨论】:
-
这个错误仍然存在于 Xcode 7.3 Beta 中。来吧苹果
-
如果直接从地图集中加载纹理,而不是通过使用
initWithImagedNamed:@"somestring"和类似方法,这确实会“消失”。
标签: swift sprite-kit asset-catalog sktexture sktextureatlas