Skip to content

Instantly share code, notes, and snippets.

@bcbroom
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcbroom/c0705362d1eabd4481d1 to your computer and use it in GitHub Desktop.
Save bcbroom/c0705362d1eabd4481d1 to your computer and use it in GitHub Desktop.
//
// 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