GitXplorerGitXplorer
g

RxSpriteKit

public
131 stars
4 forks
0 issues

Commits

List of commits on branch master.
Verified
40be0d3a027f20490f1fd1f39d6438c8e21859da

Update README.md

ggiginet committed 5 years ago
Verified
eb6d588c33c61c2776a32b727f83784216f4e8eb

Add badge

ggiginet committed 5 years ago
Verified
b2350a93a508e866507bd276fc87d3b1481d27b1

Merge pull request #2 from giginet/version2.0.0

ggiginet committed 5 years ago
Verified
06d8a30c11b9f1da3b9eb0aad4a5445324efdc8f

Drop pod lib lint on CI

ggiginet committed 5 years ago
Unverified
a962815998210ef3751d2d6ac9ca87cff4744ef7

SwiftPM support

ggiginet committed 5 years ago
Unverified
543263a62c683fc70d596bf591ff04e29b95afe1

Use --cache-builds

ggiginet committed 5 years ago

README

The README file for this repository.

RxSpriteKit

Build Status Language Carthage compatible CocoaPods Compatible Platform License

React extensions for SpriteKit 👾

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<Int>()

    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)
    }
}