Iâm trying to build this game in xCode 7.3.1 and Iâm getting the following errors:
Use of unresolved identifier ârawValueâ in the following code block:
var spriteName: String {
let spriteNames = [
âCroissantâ,
âCupcakeâ,
âDanishâ,
âDonutâ,
âMacaroonâ,
âSugarCookieâ]
return spriteNames[rawValue - 1]
}
Type âCookie.CookieTypeâ does not conform to protocol âCustonStringConvertibleâ in the following code block:
enum CookieType: Int, CustomStringConvertible {
case Unknown = 0, Croissant, Cupcake, Danish, Donut, Macaroon, SugarCookie
}
Note that CustomStringConvertible was recommended to replace Printable.
Here is the entire class code for context:
import SpriteKit
class Cookie: CustomStringConvertible {
var column: Int
var row: Int
let cookieType: CookieType
var sprite: SKSpriteNode?
init(column: Int, row: Int, cookieType: CookieType) {
self.column = column
self.row = row
self.cookieType = cookieType
}
enum CookieType: Int, CustomStringConvertible {
case Unknown = 0, Croissant, Cupcake, Danish, Donut, Macaroon, SugarCookie
}
var spriteName: String {
let spriteNames = [
"Croissant",
"Cupcake",
"Danish",
"Donut",
"Macaroon",
"SugarCookie"]
return spriteNames[rawValue - 1]
//return spriteNames.rawValue - 1
}
var description: String {
return "type:\(cookieType) square: (\(column),\(row))"
}
var highlightedSpriteName: String {
return spriteName + "-Highlighted"
}
static func random() -> CookieType {
return CookieType(rawValue: Int(arc4random_uniform(6)) + 1)!
}
}
Any help is greatly appreciated.
Thanks!indent preformatted text by 4 spaces