2016-03-02 110 views
0

我收到此错误调试器:斯威夫特:精灵动画的Bug

CUICatalog:无效请求:请求亚型没有指定成语

任何想法,我怎么能解决这个问题?它似乎只是在图像加载/动画时第一次出现。我注意到这一点,因为表现受到影响,角色似乎略有滞后和淡入。

这里是我的代码:

override func didMoveToView(view: SKView) { 

    setUpDiplo() 

} 

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { 
    /* Called when a touch begins */ 
    diplo.runAction(SKAction.repeatAction(SKAction.animateWithTextures(textureArray, timePerFrame: 0.1), count: 10)) 

} 

func setUpDiplo(){ 

    textureAtlas = SKTextureAtlas(named: "Diplo") 

    for i in 1...textureAtlas.textureNames.count { 

     var name = "Diplo\(i)@3x.png" 

     textureArray.append(SKTexture(imageNamed: name)) 

    } 
    diplo = SKSpriteNode(imageNamed: "[email protected]") 
    diplo.size = CGSize(width: 971/3, height: 1727/3) 
    diplo.position = CGPoint(x: (self.view?.bounds.width)! * 0.5, y: (self.view?.bounds.height)! * 0.5) 
    self.addChild(diplo) 
} 

回答

0

您没有使用纹理地图的正确方法。出于某种原因,您将其大小加倍,这很可能超出了地图集的限制。

只要您的文件安装正确(图像,image @ 2x和image @ 3x位于同一目录中),Apple会自动选择您需要的正确文件。

只要像这样设置你的代码。

func setUpDiplo(){ 

    textureAtlas = SKTextureAtlas(named: "Diplo") 

    diplo = SKSpriteNode(texture: textureAtlas.textureNamed("Diplo1")) 
    //took out the size unless you need the node to be larger than the texture @1x 
    diplo.position = CGPoint(x: (self.view?.bounds.width)! * 0.5, y: (self.view?.bounds.height)! * 0.5) 
    self.addChild(diplo) 
} 
+0

textureAtlas变量从未这里使用... – Whirlwind

+0

好抓,忘了,他并没有使用图谱来开始将其添加在对他来说,那是什么扔我 – Knight0fDragon

+0

是啊,我看你是什么说...顺便说一句,你需要diplo = SKSpriteNode(texture:textureAtlas.textureNamed(“Diplo1”))...你不能在纹理地图集实例上使用下标语法(如果可能的话, )。 – Whirlwind