Upgrade to Pro — share decks privately, control downloads, hide ads and more …

👾&⌚️

 👾&⌚️

try! Swift 2017

giginet

March 03, 2017
Tweet

More Decks by giginet

Other Decks in Programming

Transcript

  1. var texture: SKTexture { guard let videoBuffer: UnsafeRawPointer = emulatorCore.videoBuffer()

    else { fatalError() } let data = Data(bytes: videoBuffer, count: Int(bufferCount)) let size = CGSize(width: 256, height: 240) return SKTexture(data: data, size: size, flipped: true) }
  2. import AVFoundation // let destinationBuffer: AVAudioPCMBuffer! // Get source buffer

    let sourceBuffer = UnsafeBufferPointer<Int16>(start: head.assumingMemoryBound(to: Int16.self), count: bufferLength) // Copy samples to AVAudioPCMBuffer for channel in 0..<channelCount { let samples = UnsafeMutableBufferPointer<Float32>(start: destinationBuffer.floatChannelData?.pointee, count: bufferLength) for frame in 0..<frameLength { // Cast 16bit audio to 32bit samples[frame] = Float32(audioBuffer[frame * channelCount + channel]) } } AUDIO
  3. public enum Button: UInt32 { case a = 1 case

    b = 2 case select = 4 case start = 8 case up = 16 case down = 32 case left = 64 case right = 128 } if sender.state == .began { controllerState |= button.rawValue } else if sender.state == .ended { controllerState &= ~button.rawValue }