ios - Why is my Swift Program stalling and not running? -
class gameviewcontroller: uiviewcontroller { func shuffle<c: mutablecollectiontype c.index == int>(var list: c) -> c { let c = count(list) in 0..<(c - 1) { let j = int(arc4random_uniform(uint32(c - i))) + swap(&list[i], &list[j]) } return list } @iboutlet weak var backround: uiimageview! @iboutlet weak var button1: uibutton! @iboutlet weak var button2: uibutton! @iboutlet weak var button3: uibutton! @iboutlet weak var button4: uibutton! @iboutlet weak var button5: uibutton! @iboutlet weak var earthy: uiimageview! @iboutlet weak var blocker: uiimageview! @iboutlet weak var asteroid5: uiimageview! @iboutlet weak var asteroid4: uiimageview! @iboutlet weak var asteroid3: uiimageview! @iboutlet weak var asteroid2: uiimageview! @iboutlet weak var asteroid1: uiimageview! let realasteroid = uiimage(named: "asteroid") var numberarray = ["1", "2", "3", "4", "5"] var playerscore = 0 var aliveornah:bool = true var positioningnumrock = arc4random_uniform(5) + 1 var positioningnumblocker = arc4random_uniform(5) + 1 //set random numbers override func viewdidload(){ var shufflednumarray:array = shuffle(numberarray) println(shufflednumarray) var but1string:string = shufflednumarray[0] var but2string:string = shufflednumarray[1] var but3string:string = shufflednumarray[2] var but4string:string = shufflednumarray[3] var but5string:string = shufflednumarray[4] self.button1.settitle(but1string,forstate: uicontrolstate.normal) self.button2.settitle(but2string,forstate: uicontrolstate.normal) self.button3.settitle(but3string,forstate: uicontrolstate.normal) self.button4.settitle(but4string,forstate: uicontrolstate.normal) self.button5.settitle(but5string,forstate: uicontrolstate.normal) var posrandnum = arc4random_uniform(5) + 1 func offwiththerocks(){ switch posrandnum{ case 1: self.asteroid1.center.y += view.bounds.height uiview.animatewithduration(10.0, animations: { self.asteroid1.center.y -= self.view.bounds.height - 100 }) case 2: self.asteroid2.center.y += view.bounds.height uiview.animatewithduration(10.0, animations: { self.asteroid2.center.y -= self.view.bounds.height - 100 }) case 3: self.asteroid3.center.y += view.bounds.height uiview.animatewithduration(10.0, animations: { self.asteroid3.center.y -= self.view.bounds.height - 100 }) case 4: self.asteroid4.center.y += view.bounds.height uiview.animatewithduration(10.0, animations: { self.asteroid4.center.y -= self.view.bounds.height - 100 }) case 5: self.asteroid5.center.y += view.bounds.height uiview.animatewithduration(10.0, animations: { self.asteroid5.center.y -= self.view.bounds.height - 100 }) default: break } }
}
}
this code builds whenever hit play button move onto view program stalls , code above not run. suggestions? know did wrong? beginner aware have made dumb mistake or something.
the switch/case code never run, because have placed inside function declaration func offwiththerocks(){ ... }
, function never called. try deleting func offwiththerocks(){
, associated trailing }
.
Comments
Post a Comment