Need help with RxSpriteKit?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

giginet
131 Stars 3 Forks MIT License 81 Commits 0 Opened issues

Description

:space_invader: Reactive Extensions for SpriteKit

Services available

!
?

Need anything else?

Contributors list

No Data

RxSpriteKit

Build Status Language Carthage compatible CocoaPods Compatible Platform License

React extensions for SpriteKit :space_invader:

Installation

Carthage

github "giginet/RxSpriteKit"

CocoaPods

use_framework!

pod "RxSpriteKit"

Usage

See

RxSpriteKitDemo
for detail.
import SpriteKit
import RxSpriteKit
import RxSwift
import RxCocoa

class GameScene: SKScene { private let disposeBag = DisposeBag() private var label: SKLabelNode! private let frameRelay = PublishRelay()

override func sceneDidLoad() {
    super.sceneDidLoad()

    guard let label = childNode(withName: "//helloLabel") as? SKLabelNode else {
        fatalError("Label is not defined")
    }
    self.label = label
    rx.update
        .scan(0, accumulator: { frameCount, _ in frameCount + 1 })
        .bind(to: frameRelay)
        .disposed(by: disposeBag)
    frameRelay
        .map { CGFloat($0) * 0.01 }
        .bind(to: label.rx.zRotation)
        .disposed(by: disposeBag)
    frameRelay
        .map { CGPoint(x: 0, y: $0) }
        .bind(to: label.rx.position)
        .disposed(by: disposeBag)
    frameRelay
        .map { String(describing: $0) }
        .bind(to: label.rx.text)
        .disposed(by: disposeBag)
}

}

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.