The following content describes and provides detailed information on the RxSpriteKit document, a Swift-based Reactive Programming library dedicated to the SpriteKit framework.
Description
RxSpriteKit is a Swift-based Reactive Programming library for SpriteKit which is especially designed to make it easier to create high-performance, highly scalable, concurrent and simple-to-write iOS applications. It’s part of the larger RxSwift Community.
Features
- Reactive extensions for SKView, SKScene, and SKNode
- Handling SKScene lifecycle
- Handling scene transition
- SKAction creation with an easy, reactive syntax
Installation
RxSpriteKit can be installed via Swift Package Manager, CocoaPods, or Carthage. Each method is explained below.
Swift Package Manager
Ideal for use with Xcode. Adding the RxSpriteKit to your project is done through adding the following line into your Package.swift:
“` dependencies: [ .package(url: “https://github.com/RxSwiftCommunity/RxSpriteKit.git”, from: “lastest_version”) ] “`CocoaPods
For using CocoaPods, insert the following line into your Podfile:
“` pod ‘RxSpriteKit’ “`Carthage
If you’re using Carthage, include the following line to your Cartfile:
“` github “RxSwiftCommunity/RxSpriteKit” “`Usage
RxSpriteKit’s reactive extensions provide a simple and powerful way to manage SpriteKit components. Below are a few examples of its usage.
SKScene Presentation and Transition
When managing scene transitions, let’s say from MenuScene to GameScene, you can use the presentScene function:
“` let gameScene = GameScene() menuScene.rx .presentScene(gameScene, transition: .doorsOpenHorizontal(withDuration: 0.5)) .subscribe() .disposed(by: disposeBag) “`Documentation
Further information on the functionalities and examples of RxSpriteKit can be found in the in-depth documentation. Here
License
RxSpriteKit is distributed under the MIT license, which permits use in both free and commercial applications. Full license details can be found here.