Skip to content

rvenieris/SpriteKitMagic

Repository files navigation

SpriteKitMagic

A Spritekit Framework Protocol Based to make our lives easier handling gestures and motion

How to Use it

  1. Copy the "GestureManagement" group to your project
  2. Create Subclasses of your SKNodes (See examples in prroject)
  3. Create your GameScene as subclass of HandledGestureSKScene
  4. Conform your nodes with the new Protocols listed below as you need

Protocols

  • protocol TouchableSKNode

    • Just mark your node as touchable
  • protocol TapableSKNode

    • Mark your node as able to receive TAP gesture
  • protocol TapableToogleSelectedSKNode

    • Executes func toogleSelected() on single tap
  • protocol PannableSKNode

    • Handles PAN gesture, moving node
  • protocol PannableLimitInScreenSKNode

    • Make the node return to first full visible position at end of PAN
  • protocol PannableRemoveOutScreenSKNode

    • remove node from Scene if invisible at the end of TAP
  • protocol PannableHaveInertia

    • Execute PAN inertia movement depending on pan velocity and friction parameter
  • protocol ScalableSKNode

    • Make node Pinch Scalable
  • protocol ScalableFitScrenSKNode

    • Reduce to Fit node in scene at the end of scale, if result is a node bigger than scene
  • protocol ScalableFillScrenSKNode

    • Reduce to Fill node in scene at the end of scale, if result is a node bigger than scene

Useful functions

  • UITouch & Set extensions

    • func firstTouchedNode(of type:T.Type, in node:SKNode)->T? Returns first touched node of this UITouch of a Given Type or the root node of this query
  • UIGestureRecognizer extensions

    • firstTouchedNode:SKNode? Returns first touched node of this UIGestureRecognizer
    • orientedLocation: CGPoint Returns correct Y signal location
    • firstTouchedNode(of type:T.Type)->T? Returns first touched node of this UIGestureRecognizer of a Given Type or the root node of this query
  • SKNode extensions

    • pulse(_ times:Int = 1, duration: TimeInterval = 0.1) Run a pulse animation
    • scaleValueToFitScreen:CGFloat
    • scaleValueToFillScreen:CGFloat
    • proportionToScreen:CGPoint
    • isOffScene:Bool
    • isFullOffScene:Bool
    • removeFromParentIfOffScene()
    • bounceBackIfOffScreen()
    • frameInScene:CGRect A frame representant in adjusted to the scene

About

A Spritekit Framework Protocol Based to make our lives easier handling gestures and motion

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages