-
-
Save bcbroom/c0705362d1eabd4481d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// GameScene.swift | |
// | |
// Created by Brian Broom on 7/3/14. | |
// Copyright (c) 2014 Brian Broom. All rights reserved. | |
// | |
import SpriteKit | |
class GameScene: SKScene { | |
override func didMoveToView(view: SKView) { | |
/* Setup your scene here */ | |
let ship = Spaceship() | |
ship.position = CGPointMake(200, 300) | |
self.addChild(ship) | |
} | |
} | |
class Spaceship : SKSpriteNode { | |
var weapon :String | |
init() { | |
weapon = "cannon" | |
let texture = SKTexture(imageNamed: "Spaceship") | |
super.init(texture: texture, color: nil, size: texture.size()) | |
} | |
} | |
// init(texture:color:size:) is marked as designated in comments of the | |
// generated header that swift uses, but the other init methods are not marked | |
// convienience, but seem to act that way. | |
// seems like Xcode can't figure out which is the designated initializer for | |
// the superclass, maybe because it is Objective-C? | |
// I'm also surprised that this is a runtime error, and not a compiler error. | |
// this isn't a terrible way to init, but still seems redundant | |
// and doesn't seem obvious that the color should be nil for a image sprite | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment