CollisionDetectable

protocol CollisionDetectable : NSObject

Collision Detection Support protocol

  • Animation object

    Declaration

    Swift

    var animationObject: SpinningAnimatorProtocol? { get set }
  • Edge Collision Detector

    Declaration

    Swift

    var edgeCollisionDetector: CollisionDetector { get set }
  • Center Collision Detector

    Declaration

    Swift

    var centerCollisionDetector: CollisionDetector { get set }
  • Starts all collision detectors if needed

    Declaration

    Swift

    func startCollisionDetectorsIfNeeded()
  • Stops all collision detectos if needed

    Declaration

    Swift

    func stopCollisionDetectorsIfNeeded()
  • Prepares all collision detectors if needed

    Declaration

    Swift

    func prepareAllCollisionDetectorsIfNeeded(with rotationDegree: CGFloat,
                                              animationDuration: CFTimeInterval,
                                              onEdgeCollision: ((_ progress: Double?) -> Void)? = nil,
                                              onCenterCollision: ((_ progress: Double?) -> Void)? = nil)

    Parameters

    rotationDegree

    Animation full rotation degree

    animationDuration

    Animation duration time

    onEdgeCollision

    On edge collision callback

    onCenterCollision

    On center collision callback

  • Prepare collision detector if needed by collision type

    Declaration

    Swift

    func prepareCollisionDetectorIfNeeded(for type: CollisionType,
                                          with rotationDegree: CGFloat,
                                          animationDuration: CFTimeInterval,
                                          onCollision: ((_ progress: Double?) -> Void)? = nil)

    Parameters

    type

    Collision type

    rotationDegree

    Animation full rotation degree

    animationDuration

    Animation duration time

    onCollision

    On collision callback

  • Prepare all collision detectors if needed with continuous animation

    Declaration

    Swift

    func prepareAllCollisionDetectorsIfNeeded(with rotationDegree: CGFloat,
                                              speed: CGFloat,
                                              speedAcceleration: CGFloat,
                                              onEdgeCollision: ((_ progress: Double?) -> Void)? = nil,
                                              onCenterCollision: ((_ progress: Double?) -> Void)? = nil)

    Parameters

    rotationDegree

    Animation full rotation degree

    speed

    Rotation speed

    speedAcceleration

    Rotation speed acceleration

    onEdgeCollision

    On edge collision callback

    onCenterCollision

    On center collision callback

  • Prepare collision detector if needed with continuous animation by collision type

    Declaration

    Swift

    func prepareCollisionDetectorIfNeeded(for type: CollisionType,
                                          with rotationDegree: CGFloat,
                                          speed: CGFloat,
                                          speedAcceleration: CGFloat,
                                          onCollision: ((_ progress: Double?) -> Void)? = nil)

    Parameters

    type

    Collision type

    rotationDegree

    Animation full rotation degree

    speed

    Rotation speed

    speedAcceleration

    Rotation speed acceleration

    onCollision

    On collision callback

  • rotationDegreeOffset(for:) Extension method

    Returns rotation degree offset to collision type

    Declaration

    Swift

    func rotationDegreeOffset(for type: CollisionType) -> CGFloat

    Parameters

    type

    Collision type

    Return Value

    Rotation degree offset

  • Starts collision detector if needed by collision type

    Declaration

    Swift

    func startCollisionDetectorIfNeeded(type: CollisionType)

    Parameters

    type

    Collision type

  • Stops collision detector if needed by collision type

    Declaration

    Swift

    func stopCollisionDetectorIfNeeded(type: CollisionType)

    Parameters

    type

    Collision type

  • isCollisionDetectorOn(for:) Extension method

    Checks are collision detector is on for collision type

    Declaration

    Swift

    func isCollisionDetectorOn(for type: CollisionType) -> Bool

    Parameters

    type

    Collision type

    Return Value

    Is collision detection on or off