Noa*_*vey 22 sprite-kit asset-catalog sktextureatlas sktexture swift
当我运行我的SpriteKit游戏时,我在控制台中多次收到此错误.据我所知(尽管我不完全确定),游戏本身并未受到影响,但错误可能会产生一些其他影响,同时拥挤调试控制台.
我对错误进行了一些研究,并找到了一些可能的解决方案,其中没有一个似乎完全有效.这些解决方案包括转向ignoresSiblingOrder到false,并指定纹理作为SKTextureAtlas(named: "atlasName").textureNamed("textureName"),但这些并没有工作.
我认为错误来自于资产目录中纹理和纹理图集的使用,尽管我并不完全确定.以下是我如何实现其中一些纹理/图像:
let Texture = SKTextureAtlas(named: "character").textureNamed("\character1")
character = SKSpriteNode(texture: Texture)
Run Code Online (Sandbox Code Playgroud)
也:
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)
Run Code Online (Sandbox Code Playgroud)
上面的代码仅用于创建一个数组,从中可以为角色设置动画,动画运行完全正常.
对于我所有的其他精灵节点,我使用SKSpriteNode(imageNamed: "imageName")资产目录中的图像名称初始化,但不在纹理图集中.所有图像都有@ 1x,@ 2x和@ 3x版本.
我不确定错误消息是否还有其他可能的来源,或者上述示例是否是错误的来源.
这只是精灵套件的错误,还是我的代码或资产的合法错误?
谢谢!
| 归档时间: |
|
| 查看次数: |
7001 次 |
| 最近记录: |