Better Easing for SpriteKit in Swift

Overview

SpriteKitEasingSwift: Better Easing for SpriteKit in Swift.

CI Status Version License Platform

This easing library began life as a port of buddingmonkey's Objective C SpriteKit Easing library to Swift.

This library extends upon the basic easing equations available in the SpriteKit framework by Apple.

Sprite Kit Easing makes available the following standard easing equations as SKActions.

easing.gif

Use SKEase methods to tween properties of an SKNode, such as:

  • move
  • scale
  • scaleX
  • scaleY
  • rotate
  • fade
  • tweenLabelColor
  • tweenShapeFillColor

If you want to tween a variable, use:

  • createPointTween
  • createFloatTween
  • createColorTween

The SKEase functions return an SKAction that performs the ease. You can then run the SKAction in the same manner you would any other SKAction in SpriteKit.

//eg an SKLabelNode(which extends SKNode) flies in from the right with an elastic tween:
//first create an SKNode, let's create a label node
let titleLabel = SKLabelNode(fontNamed:"Avenir-Light")
titleLabel.text = "Hello world"
titleLabel.fontSize = 65
titleLabel.fontColor = UIColor.white
titleLabel.position = CGPoint(x:self.frame.midX, y:self.frame.midY)
self.addChild(titleLabel)
//perform elastic ease
titleLabel.run(SKEase.move(easeFunction: .curveTypeElastic,
easeType: .easeTypeOut,
time: 2,
from: CGPoint(x: frame.width+titleLabel.frame.width/2, y: titleLabel.position.y),
to:CGPoint(x: -titleLabel.frame.width/2, y: titleLabel.position.y)))

Installation

via CocoaPods

SpriteKitEasingSwift is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SpriteKitEasingSwift'

To run the example project, clone the repo, and run pod install from the Example directory first.

Don't forget to import the Pod where you would like to use it:

import SpriteKitEasingSwift

via Github:

Clone the project at Github (https://github.com/craiggrummitt/SpriteKitEasingSwift). You will find an example project there as well. To use the framework drag the SpriteKitEasingSwift/Classes folder to your project.

Author

Craig Grummitt

Again, credit and thanks go to SpriteKitEasing and AHEasing and the legend of easing, Robert Penner.

License

SpriteKitEasingSwift is available under the MIT license. See the LICENSE file for more info.

Comments
  • Installation using Carthage does not work

    Installation using Carthage does not work

    Xcode 8.2.1

    Nominal cartfile command:

    github "craiggrummitt/SpriteKitEasingSwift"

    Result

    *** Fetching SpriteKitEasingSwift
    *** Checking out SpriteKitEasingSwift at "0.10"
    *** xcodebuild output can be found in /var/folders/58/hyg_pchn4_30kg9m492kb1hw0000gr/T/carthage-xcodebuild.r2qTKq.log
    *** Building scheme "SpriteKitEasingSwift" in SpriteKitEasingSwift.xcworkspace
    ** BUILD FAILED **
    
    
    The following build commands failed:
    	CodeSign /<SOME_USER>/Library/Developer/Xcode/DerivedData/SpriteKitEasingSwift-epniaidvjimhcqhkddmmjehnoybt/Build/Products/Release-iphonesimulator/SpriteKitEasingSwift.bundle
    (1 failure)
    A shell task (/usr/bin/xcrun xcodebuild -workspace /<SOME_PROJECT>/Carthage/Checkouts/SpriteKitEasingSwift/Example/SpriteKitEasingSwift.xcworkspace -scheme SpriteKitEasingSwift -configuration Release -sdk iphonesimulator -destination "platform=iOS Simulator,id=528DD4DD-9FE8-434E-9F93-B4C0BDE5F3AA" -destination-timeout 3 ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:
    ** BUILD FAILED **
    
    
    The following build commands failed:
    	CodeSign /<SOME_USER>/Library/Developer/Xcode/DerivedData/SpriteKitEasingSwift-epniaidvjimhcqhkddmmjehnoybt/Build/Products/Release-iphonesimulator/SpriteKitEasingSwift.bundle
    (1 failure)
    
    wontfix pending 
    opened by ghost 4
  • Cocoapods uses tag 0.10 instead of master

    Cocoapods uses tag 0.10 instead of master

    Hi Craig,

    you fixed "Silencing warnings by changing M_PI to .pi" on your master, but in the podspecs you are telling to use tag 0.10. Could you maybe update the file?

    Thx! :)

    opened by SonOfCrypto 2
  • Do not use SKNode as target parameter

    Do not use SKNode as target parameter

    In action method, SKNode target parameter is used to retrieve node property. Thus chain actions cannot be done because SKNode properties change along actions.

    In place, remove this parameter and replace it by the needed property. For example, for scaleToWithNode, as the needed property is scale use initialScale:CGFloat as parameter.

    opened by ghost 2
  • SPM Support and dropping iOS 8

    SPM Support and dropping iOS 8

    Had to drop support for iOS 8 because Quick & Nimble used in the tests only support iOS 9 and up. Also, Xcode doesn't support iOS 8 anymore.

    The version also needed to be 0.15.0 instead of 0.15 to make it work for SPM

    opened by simonsalomons 1
  • Variable easing

    Variable easing

    hello, your lib works great, feels like flash.

    one wish, I need a way to ease a variable. in Tweener theres an nice option to ease everything.

    regards

    opened by bluelemonade 1
  • Add a license

    Add a license

    Hey @craiggrummitt, I'm interested in using the library in one of my projects. Would you mind adding a license file to the repo, so I know under which conditions I may reuse the code? Thank you!

    opened by snorpey 1
  • Wrong parameter type in move  methods

    Wrong parameter type in move methods

    In all move methods there is a parameter of CGVectortype to designate from or to data. This parameter suppose this is a delta from a given position but in methods this parameter is used as a position data.

    So CGPointwill better suit for parameter type.

    opened by ghost 1
Owner
Craig Grummitt
Founder: interactivecoconut.com  Book: manning.com/books/ios-development-with-swift    Video course: manning.com/livevideo/ios-development-with-swift-lv
Craig Grummitt
Compose SpriteKit animations quickly in a declarative SwiftUI-style

ActionBuilder Caveat developer: As this package is pre-release, the API may change significantly without notice. It has not been tested, so use it at

Kuba Szulaczkowski 6 Dec 30, 2022
Framework to help you better manage UITableViews

UITableView made simple ?? Main Features ?? Skip the UITableViewDataSource & UITableViewDelegate boilerplate and get right to building your UITableVie

null 84 Feb 4, 2022
A SwiftUI component to make handling of email links better.

EmailLink A SwiftUI component to make handling of email links better. Not only will EmailLink use the correct default client, it will also prompt the

Joe Scotto 16 Sep 24, 2022
☄️Comets: Animating Particles in Swift

Comets ☄️ Comets: Animating Particles in Swift animation made by kevin as part of Voicy design implements Bennet van der Linden medium Comets: Animati

Cruz 593 Dec 28, 2022
A DSL to make animation easy on iOS with Swift.

This project is highly inspired by JHChainableAnimations, If you project is developed with Objective-C, use JHChainableAnimations instead. With DKChai

Draven 1.9k Dec 9, 2022
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!

ver 2.0 NB! Breaking changes in 2.0 - due to a lot of requests EasyAnimation does NOT automatically install itself when imported. You need to enable i

Marin Todorov 3k Dec 27, 2022
Elegant SVG animation kit for swift

Elephant This is SVG animation presentation kit for iOS. Example You can run example app. Please open Example-iOS/Elephant-iOS.xcworkspace! Usage You

Kazumasa Shimomura 127 Dec 14, 2022
Gemini is rich scroll based animation framework for iOS, written in Swift.

Overview What is the Gemini? Gemini is rich scroll based animation framework for iOS, written in Swift. You can easily use GeminiCollectionView, which

Shohei Yokoyama 3k Dec 27, 2022
Swift interpolation for gesture-driven animations

Interpolate Interpolate is a powerful Swift interpolation framework for creating interactive gesture-driven animations. Usage The ?? idea of Interpola

Roy Marmelstein 1.8k Dec 20, 2022
Pulse animation for iOS written with Swift.

Pulsator Pulse animation for iOS written with Swift. Great For: Pulses of Bluetooth, BLE, beacons (iBeacon), etc. Map Annotations Installation CocoaPo

Shuichi Tsutsumi 1.3k Jan 6, 2023
A library to simplify iOS animations in Swift.

Updated for Swift 4.2 Requires Xcode 10 and Swift 4.2. Installation Drop in the Spring folder to your Xcode project (make sure to enable "Copy items i

Meng To 14k Jan 3, 2023
Swift library for choreographing animations on the screen.

Spruce iOS Animation Library (and Android) What is it? Spruce is a lightweight animation library that helps choreograph the animations on the screen.

WillowTree, LLC 3.4k Jan 3, 2023
A fantastic Physical animation library for swift

A fantastic Physical animation library for swift(Not Just Spring !!!), it is base on UIDynamic and extension to it, friendly APIs make you use it or c

August 2.9k Jan 4, 2023
A slider widget with a popup bubble displaying the precise value selected written on Swift.

A slider widget with a popup bubble displaying the precise value selected written on Swift. We specialize in the designing and coding of

Ramotion 1.9k Dec 23, 2022
Navigation toolbar is a Swift slide-modeled UI navigation controller.

Navigation toolbar is a Swift slide-modeled UI navigation controller. We specialize in the designing and coding of custom UI for Mo

Ramotion 596 Nov 17, 2022
Animate easy and with less code with Swift

JDAnimationKit is designed to be extremely easy to use. You can animate your UI withe less lines of code. This library use internally POP framework, a

Jelly Development 610 Sep 9, 2022
A simple animated progress bar in Swift

DSGradientProgressView Introduction DSGradientProgressView is a simple and customizable animated progress bar written in Swift. Inspired by GradientPr

Dhol Studio 445 Oct 13, 2022
Composable animations in Swift

Composable animations in Swift. Blog Installation Cocoapods The easiest way to get started is to use CocoaPods. Just add the following line to your Po

Reid Chatham 195 Dec 5, 2022
Gravity is a simple Swift Package Manager to add gravity to UI objects easily.

Gravity -- Gravity is a simple Swift Package to add gravity to UI objects easily. -- How to use: Add a new Swift Package from XCode and paste the url

alberto 1 Nov 23, 2021