Skip to content

Commit

Permalink
latest xcode swift changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jashmenn committed Sep 15, 2015
1 parent 636cd43 commit d239eb9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions FlappyBird.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
437451F2193D163700654986 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0600;
ORGANIZATIONNAME = Fullstack.io;
TargetAttributes = {
Expand Down
6 changes: 3 additions & 3 deletions FlappyBird/GameScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate{
self.addChild(bird)

// create the ground
var ground = SKNode()
let ground = SKNode()
ground.position = CGPointMake(0, groundTexture.size().height)
ground.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(self.frame.size.width, groundTexture.size().height * 2.0))
ground.physicsBody?.dynamic = false
Expand Down Expand Up @@ -168,7 +168,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate{
pipeUp.physicsBody?.contactTestBitMask = birdCategory
pipePair.addChild(pipeUp)

var contactNode = SKNode()
let contactNode = SKNode()
contactNode.position = CGPointMake( pipeDown.size.width + bird.size.width / 2, CGRectGetMidY( self.frame ) )
contactNode.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake( pipeUp.size.width, self.frame.size.height ))
contactNode.physicsBody?.dynamic = false
Expand Down Expand Up @@ -202,7 +202,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate{
// Restart animation
moving.speed = 1
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */
if moving.speed > 0 {
for touch: AnyObject in touches {
Expand Down
13 changes: 9 additions & 4 deletions FlappyBird/GameViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ extension SKNode {

let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks")

let sceneData = NSData(contentsOfFile: path!, options: .DataReadingMappedIfSafe, error: nil)
let sceneData: NSData?
do {
sceneData = try NSData(contentsOfFile: path!, options: .DataReadingMappedIfSafe)
} catch _ {
sceneData = nil
}
let archiver = NSKeyedUnarchiver(forReadingWithData: sceneData!)

archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene")
Expand Down Expand Up @@ -49,11 +54,11 @@ class GameViewController: UIViewController {
return true
}

override func supportedInterfaceOrientations() -> Int {
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
return UIInterfaceOrientationMask.AllButUpsideDown
} else {
return Int(UIInterfaceOrientationMask.All.rawValue)
return UIInterfaceOrientationMask.All
}
}

Expand Down

0 comments on commit d239eb9

Please sign in to comment.