我正在尝试将一堆动画纹理从纹理图集中加载到数组中,但是在尝试将帧附加到数组时出现错误。
基本上我想要一个多维纹理数组,其中每一行代表一个动画,它是一个帧数组。像这样的东西:
[[FirstFrameTexture, SecondFrameTexture, ThirdFrameTexture...], //first animation
[FirstFrameTexture, SecondFrameTexture, ThirdFrameTexture...], //second animation
[FirstFrameTexture, SecondFrameTexture, ThirdFrameTexture...]] //third animation
我初始化了一个这样的数组:
var animations = [[SKTexture]]()
但是当我尝试像这样将纹理附加到数组中时
animations[0].append(SKTexture(imageNamed: "test"))
我在这一行收到一条错误消息:
fatal error: Cannot index empty buffer
关于如何解决这个问题的任何想法?