這是讓我走的那些問題之一「我怎麼辦?」在'Cat'類型上使用實例成員'meow'是否意味着使用'Cat'類型的值?
這是編譯器錯誤我得到:
Use of instance member 'getAttackUPSequence_Frames' on type 'SKFootmanSprite' did you mean to use a value of type 'SKFootmanSprite' instead?
我得到這個爲我所有_Frames變量。 這裏是我的公共屬性SKFootmanSprite:
// ATTACK
static let attackUp_Frames = getAttackUPSequence_Frames()
static let attackDown_Frames: [SKTexture] = getAttackDOWNSequence_Frames()
static let attackLeft_Frames: [SKTexture] = getAttackLEFTSequence_Frames()
static let attackRight_Frames: [SKTexture] = getAttackRIGHTSequence_Frames()
static let attackUpRight_Frames: [SKTexture] = getAttackUPRIGHTSequence_Frames()
static let attackUpLeft_Frames: [SKTexture] = getAttackUPLEFTSequence_Frames()
static let attackDownLeft_Frames: [SKTexture] = getAttackDOWNLEFTSequence_Frames()
static let attackDownRight_Frames: [SKTexture] = getAttackDOWNRIGHTSequence_Frames()
這是該得到的攻擊順序的功能之一:
func getAttackUPSequence_Frames() -> [SKTexture] {
var textures = [SKTexture]()
for var i = 1; i < 7; i+=1 {
let imageName = "footman_attack_up0" + String(i)
textures.append(SKTexture(imageNamed: imageName))
}
let imageName = "footman_up_stand"
textures.append(SKTexture(imageNamed: imageName))
return textures
}
我想我的精靈幀使用let
而不是var
。 (由蘋果官方雨燕教科書把使用let
代替var
這樣的事情非常強調的。)