SKUtilities2

Author:
Michael Redig
Version:
2.0b
Includes:
<Foundation/Foundation.h>
<QuartzCore/QuartzCore.h>
<SpriteKit/SpriteKit.h>
<CoreGraphics/CoreGraphics.h>

Introduction

SpriteKit Utilities 2

Discussion

This is a collection of functions, classes, and categories to greatly simplify and speed up development with SpriteKit.

Available for download at GitHub

Documentation available at GitHub Pages

Miscellaneous:

  • Run this as a script in a build phase to automatically increment build numbers

     
     #!/bin/bash
     bN=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
     bN=$((bN += 1))
     bN=$(printf "%d" $bN)
     /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bN" "$INFOPLIST_FILE"
     
     
  • Header formatting for documentation can be referenced here and here

  • To activate mouse movement capture on OSX, use this line in Obj C

     
     self.view.window.acceptsMouseMovedEvents = YES;
     
     

    or this line in Swift

     
     self.view!.window!.acceptsMouseMovedEvents = true;
     
     


Classes

SKUButton
SKUButtonLabelProperties
SKUButtonLabelPropertiesPackage
SKUButtonSpriteStateProperties
SKUButtonSpriteStatePropertiesPackage
SKUGameControllerState
SKUGCControllerController
SKUMultiLineLabelNode
SKUNode
SKUPositionObject
SKUPushButton
SKUScene
SKUShapeNode
SKUSliderButton
SKUSpriteNode
SKUtilities2
SKUToggleButton
SKUViewController

Protocols

SKUButtonDelegate

Categories

SKColor(Mixing)
SKNode(SKUModifications)
SKView(SKUModifications)


Groups

CGPoint Helpers

Group members:

 

Bezier Calculations

Group members:

 

Logging

Group members:

 

Common Constants

Group members:

 

CGVector Helpers

Group members:

 

Orientation

Group members:

 

Coordinate Format Conversions

Group members:

 

SKUButton Enums

Group members:

 

Number Interpolation

Group members:

 

Distance Functions

Group members:

 

Random Numbers

Group members:


Functions

bezierPoint
bezierTValueAtXValue
centerOSCursorInWindow
clipFloatWithinRange
clipIntegerWithinRange
distanceBetween
distanceBetweenIsWithinXDistance
distanceBetweenIsWithinXDistancePreSquared
getCGPointFromString
getStringFromPoint
hideOSCursor
linearInterpolationBetweenFloatValues
midPointOfRect
midPointOfSize
orientToFromDownFace
orientToFromLeftFace
orientToFromRightFace
orientToFromUpFace
pointAdd
pointAddValue
pointFromCGSize
pointFromCGVector
pointInterpolationLinearBetweenTwoPoints
pointInverse
pointIsBehindVictim
pointIsZero
pointMultiplyByFactor
pointMultiplyByPoint
pointRelativeToScene
pointStepTowardsPointWithInterval
pointStepVectorFromPoint
pointStepVectorFromPointWithInterval
rampToValue
randomFloatBetweenZeroAndHighend
randomUnsignedIntegerBetweenTwoValues
reverseLinearInterpolationBetweenFloatValues
SKULog
SKULogBinary
vectorAdd
vectorDistance
vectorFacingPoint
vectorFromCGPoint
vectorFromCGSize
vectorFromDegree
vectorFromRadian
vectorInverse
vectorIsZero
vectorMultiplyByFactor
vectorMultiplyByVector
vectorNormalize

bezierPoint


CGPoint bezierPoint (
    CGFloat t,
    CGPoint point0,
    CGPoint point1,
    CGPoint point2,
    CGPoint point3);  
Parameters
t

Interpolation between points.

point0

Anchor point 1.

point1

Handle point 1.

point2

Handle point 2.

point3

Anchor point 2.

Return Value

CGPoint value.

Discussion

Returns a point on a bezier curve. Provide it with the anchor points (point0 and point3) and the handle points (point1 and point2) and the value at which to evaluate between 0.0 and 1.0 (0 being point0 and 1.0 being point3).

See Also


bezierTValueAtXValue


double bezierTValueAtXValue (
    double x,
    double p0x,
    double p1x,
    double p2x,
    double p3x);  
Parameters
x

x value that you need to get the y value from

p0x

x value from point 0

p1x

x value from point 1

p2x

x value from point 2

p3x

x value from point 3

Return Value

t value for given x value - you can then get the y value from the previous function

Discussion

Since bezier paths are distributed more densely in some areas, while more sparse in others, sometimes you need to be able to get the point at a certain x value instead of a t value. Provide this function with the x values of the curve and what x value you need the y value for.

See Also


centerOSCursorInWindow


Discussion

Centers the Mac OS Cursor in the center of the window. Typically used incoordination of mouseMoved events. Mac only, but harmless on other platforms.

See Also


clipFloatWithinRange


CGFloat clipFloatWithinRange (
    CGFloat value,
    CGFloat minimum,
    CGFloat maximum);  
Parameters
value

CGFloat value that is evaluated

minimum

CGFloat input of the low end range of what the output value could be

maximum

CGFloat input of the high end range of what the output value could be

Discussion

Returns a CGFloat clipped within the range provided.

See Also


clipIntegerWithinRange


NSInteger clipIntegerWithinRange (
    NSInteger value,
    NSInteger minimum,
    NSInteger maximum);  
Parameters
value

NSInteger value that is evaluated

minimum

NSInteger input of the low end range of what the output value could be

maximum

NSInteger input of the high end range of what the output value could be

Discussion

Returns an NSInteger clipped within the range provided.

See Also


distanceBetween


CGFloat distanceBetween (
    CGPoint pointA,
    CGPoint pointB);  
Parameters
pointA

CGPoint start or end point

pointB

CGPoint start or end point

Discussion

Returns a CGFloat value measuring the distance between two CGPoint values.

See Also


distanceBetweenIsWithinXDistance


bool distanceBetweenIsWithinXDistance (
    CGPoint pointA,
    CGPoint pointB,
    CGFloat xDistance);  
Parameters
pointA

CGPoint start or end point

pointB

CGPoint start or end point

xDistance

CGFloat max distance between points

Discussion

Returns a bool value determining if the distance between two points is less than a predetermined maximum value.

See Also


distanceBetweenIsWithinXDistancePreSquared


bool distanceBetweenIsWithinXDistancePreSquared (
    CGPoint pointA,
    CGPoint pointB,
    CGFloat xDistancePresquared);  
Parameters
pointA

CGPoint start or end point

pointB

CGPoint start or end point

xDistancePresquared

CGFloat max distance between points, squared (x * x)

Discussion

Returns a bool value determining if the distance between two points is less than a predetermined maximum value. This is a small optimization over the previous function as it saves the step of squaring the x value.

See Also


getCGPointFromString


CGPoint getCGPointFromString (
    NSString *string);  
Parameters
string

NSString formatted like { ##,## } where ## are numbers.

Discussion

Returns a CGPoint struct converted from a properly formatted string.

See Also


getStringFromPoint


NSString* getStringFromPoint (
    CGPoint location);  
Parameters
location

CGPoint struct

Discussion

Returns a properly formatted NSString to later be converted back to a CGPoint. This is useful for saving to plist files.

See Also


hideOSCursor


void hideOSCursor(
    BOOL hide);  
Parameters
hide

Boolean determining if

Discussion

Used to show or hide the OS Cursor. Mac only, but harmless on other platforms.

See Also


linearInterpolationBetweenFloatValues


CGFloat linearInterpolationBetweenFloatValues (
    CGFloat valueA,
    CGFloat valueB,
    CGFloat pointBetween,
    bool clipped);  
Parameters
valueA

CGFloat low end value

valueB

CGFloat high end value

pointBetween

CGFloat value between the two numbers to interpolate to; 0.0 = valueA, 1.0 = valueB

clipped

bool determines whether or not pointBetween can be a value beyond the range of 0.0 to 1.0

Discussion

Returns a CGFloat interpolated linearly between two values. Clipped determines whether it can go beyond the bounds of the values.

See Also


midPointOfRect


CGPoint midPointOfRect (
    CGRect rect);  
Parameters
rect

CGRect rect struct that you need the midpoint of.

Discussion

Returns a CGPoint struct positioned at the midpoint of a CGRect, including the offset of the origin of the CGRect.

See Also


midPointOfSize


CGPoint midPointOfSize (
    CGSize size);  
Parameters
size

CGSize size struct that you need the midpoint of.

Discussion

Returns a CGPoint struct positioned at the midpoint of a CGSize struct.

See Also


orientToFromDownFace


CGFloat orientToFromDownFace (
    CGPoint facing,
    CGPoint from);  
Parameters
facing

CGPoint a point in the direction that the node should be facing.

from

CGPoint point that the node is located at

Discussion

Returns a float value in radians to rotate a node at position *from* to face *facing*, when the node is facing down at 0 rotation.

See Also


orientToFromLeftFace


CGFloat orientToFromLeftFace (
    CGPoint facing,
    CGPoint from);  
Parameters
facing

CGPoint a point in the direction that the node should be facing.

from

CGPoint point that the node is located at

Discussion

Returns a float value in radians to rotate a node at position *from* to face *facing*, when the node is facing left at 0 rotation.

See Also


orientToFromRightFace


CGFloat orientToFromRightFace (
    CGPoint facing,
    CGPoint from);  
Parameters
facing

CGPoint a point in the direction that the node should be facing.

from

CGPoint point that the node is located at

Discussion

Returns a float value in radians to rotate a node at position *from* to face *facing*, when the node is facing right at 0 rotation.

See Also


orientToFromUpFace


CGFloat orientToFromUpFace (
    CGPoint facing,
    CGPoint from);  
Parameters
facing

CGPoint a point in the direction that the node should be facing.

from

CGPoint point that the node is located at

Discussion

Returns a float value in radians to rotate a node at position *from* to face *facing*, when the node is facing up at 0 rotation.

See Also


pointAdd


CGPoint pointAdd (
    CGPoint pointA,
    CGPoint pointB);  
Parameters
pointA

CGPoint point A

pointB

CGPoint point B

Discussion

Returns a CGPoint struct as a sum from both CGPoint input parameters.

See Also


pointAddValue


CGPoint pointAddValue (
    CGPoint point,
    CGFloat value);  
Parameters
point

CGPoint point

value

CGFloat value

Discussion

Returns a CGPoint struct with value added to both dimensions

See Also


pointFromCGSize


CGPoint pointFromCGSize (
    CGSize size);  
Parameters
size

CGSize size

Discussion

Returns a CGPoint struct converted from a CGSize

See Also


pointFromCGVector


CGPoint pointFromCGVector (
    CGVector vector);  
Parameters
vector

CGVector vector

Discussion

Returns a CGPoint struct converted from a CGVector

See Also


pointInterpolationLinearBetweenTwoPoints


CGPoint pointInterpolationLinearBetweenTwoPoints (
    CGPoint pointA,
    CGPoint pointB,
    CGFloat factorBetween);  
Parameters
pointA

CGPoint start or end point

pointB

CGPoint start or end point

factorBetween

CGFloat value at which to interpolate to between the points. For example, a value of 0.5 would be halfway between the two points, a value of 0.25 would only be a quarter of the way between them.

Discussion

Returns a CGPoint struct positioned at a varying value between two points, based on the input of "factorBetween"

See Also


pointInverse


CGPoint pointInverse (
    CGPoint point);  
Parameters
point

CGPoint point struct to be inverted

Discussion

Returns a CGPoint struct with negated values.

See Also


pointIsBehindVictim


bool pointIsBehindVictim (
    CGPoint origin,
    CGPoint victim,
    CGVector normalVictimFacingVector,
    CGFloat latitude);  
Parameters
origin

CGPoint the point in contention

victim

CGPoint position of the victim

normalVictimFacingVector

CGVector normalized vector determining the direction victim is facing

latitude

CGFloat value determining how precisely behind origin has to be to be valid

Discussion

Returns a bool determining whether origin is behind victim, based on victim's facing direction.


pointIsZero


BOOL pointIsZero (
    CGPoint point);  
Parameters
point

CGPoint point struct to be evaluated as to whether it is equal to CGPointZero or not.

Discussion

Returns a boolean stating whether the given point was equal to CGPointZero or not.


pointMultiplyByFactor


CGPoint pointMultiplyByFactor (
    CGPoint point,
    CGFloat factor);  
Parameters
point

CGPoint point struct to be factored.

factor

CGFloat value to multiply both x and y by.

Discussion

Returns a CGPoint that is the product of multiplying both values by the same factor.

See Also


pointMultiplyByPoint


CGPoint pointMultiplyByPoint (
    CGPoint pointA,
    CGPoint pointB);  
Parameters
pointA

CGPoint point struct to be factored.

pointB

CGPoint point struct to be factored.

Discussion

Returns a CGPoint that is the product of two other CGPoints (Ax * Bx, Ay * By)

See Also


pointRelativeToScene


CGPoint pointRelativeToScene (
    SKScene *scene,
    CGPoint point);  
Parameters
scene

scene

point

point (anchor point style: 0.0 - 1.0 range)

Discussion

Returns a CGPoint that is the result of multiplying the scene size by the point provided

See Also


pointStepTowardsPointWithInterval


CGPoint pointStepTowardsPointWithInterval (
    CGPoint origin,
    CGPoint destination,
    CFTimeInterval interval,
    CFTimeInterval maxInterval,
    CGFloat speed,
    CGFloat speedModifiers);  
Parameters
origin

CGPoint where the point is in the current frame, prior to moving to the next frame

destination

CGPoint the point that the node is trying to move toward.

interval

CFTimeInterval The amount of time that has passed since the previous frame.

maxInterval

CFTimeInterval The maximum amount of time to alot between frames. This is useful for keeping things from jumping around the screen too far in the event of lag.

speed

CGFloat value determining how fast (in points) this is moving per second. That is points per second speed.

speedModifiers

CGFlaot value to conveniently modify speed based on buffs or debuffs

Discussion

Returns a CGPoint struct that is the result of movement based on the factors provided

See Also


pointStepVectorFromPoint


CGPoint pointStepVectorFromPoint (
    CGPoint origin,
    CGVector normalVector,
    CGFloat distance);  
Parameters
origin

CGPoint where the point is in the current frame, prior to moving to the next frame

normalVector

CGVector vector determining where the movement is headed. This is assumed to be normalized. If it is not normal, calculations will go awry.

distance

CGFloat value: The distance to move in the direction of the vector.

Discussion

Returns a CGPoint struct that is the result of movement based on the factors provided

See Also


pointStepVectorFromPointWithInterval


CGPoint pointStepVectorFromPointWithInterval (
    CGPoint origin,
    CGVector normalVector,
    CFTimeInterval interval,
    CFTimeInterval maxInterval,
    CGFloat speed,
    CGFloat speedModifiers);  
Parameters
origin

CGPoint where the point is in the current frame, prior to moving to the next frame

normalVector

CGVector vector determining where the movement is headed. This is assumed to be normalized. If it is not normal, calculations will go awry.

interval

CFTimeInterval The amount of time that has passed since the previous frame.

maxInterval

CFTimeInterval The maximum amount of time to alot between frames. This is useful for keeping things from jumping around the screen too far in the event of lag.

speed

CGFloat value determining how fast (in points) this is moving per second. That is points per second speed.

speedModifiers

CGFlaot value to conveniently modify speed based on buffs or debuffs

Discussion

Returns a CGPoint struct that is the result of movement based on the factors provided

See Also


rampToValue


CGFloat rampToValue (
    CGFloat idealValue,
    CGFloat currentValue,
    CGFloat stepValue);  
Parameters
idealValue

CGFloat value that you are approaching

currentValue

CGFloat input value of where you are now

stepValue

CGFloat amount to iterate by

Discussion

Returns a CGFloat modifying currentValue that iteratively changes over time to become closer to idealValue in iterations of stepValue

See Also


randomFloatBetweenZeroAndHighend


CGFloat randomFloatBetweenZeroAndHighend (
    CGFloat highend);  
Parameters
highend

CGFloat max range value

Discussion

Returns a CGFloat value randomized between zero and a higher value.

See Also


randomUnsignedIntegerBetweenTwoValues


u_int32_t randomUnsignedIntegerBetweenTwoValues (
    u_int32_t lowend,
    u_int32_t highend);  
Parameters
lowend

u_int32_t low end range value

highend

u_int32_t high end range value

Return Value

random u_int32_t value

Discussion

Returns a u_int_32_t value randomized between two other values.

See Also


reverseLinearInterpolationBetweenFloatValues


CGFloat reverseLinearInterpolationBetweenFloatValues (
    CGFloat valueA,
    CGFloat valueB,
    CGFloat valueBetween,
    bool clipped);  
Parameters
valueA

CGFloat low end range value

valueB

CGFloat high end range value

valueBetween

CGFloat point between the two numbers to interpolate to; valueA = 0.0, valueB = 1.0

clipped

bool determines whether or not valueBetween can be a value beyond the range of valueA to valueB

Discussion

Returns a CGFloat of the value of pointBetween interpolated linearly between two values. Clipped determines whether it can go beyond the bounds of the values. If that didn't make sense, it's a reversal of what linearInterpolationBetweenFloatValues does - it will return the value of "pointBetween" from linearInterpolationBetweenFloatValues.

See Also


SKULog


void SKULog(
    NSInteger verbosityLevelRequired,
    NSString *format,
    ...);  
Discussion

Prints text to the console using NSLog, but only prints if verbosityLevelRequired is lower than SKUSharedUtilities.verbosityLevel. Also only prints in compiler debug mode.

Language:

Objective-C

See Also


SKULogBinary


void SKULogBinary(
    uint32_t value);  
Parameters
value

uint32_t value.

Discussion

Prints the 0s and 1s of a number. Useful for visualizing flags.


vectorAdd


CGVector vectorAdd (
    CGVector vectorA,
    CGVector vectorB);  
Parameters
vectorA

CGVector vector struct to be added.

vectorB

CGVector vector struct to be added.

Discussion

Returns a CGVector that is the sum of two other CGVectors

See Also


vectorDistance


CGFloat vectorDistance (
    CGVector vector);  
Parameters
vector

vector to check

Return Value

distance value

Discussion

Calculates the distance of a vector


vectorFacingPoint


CGVector vectorFacingPoint (
    CGPoint destination,
    CGPoint origin,
    bool normalize);  
Parameters
destination

CGPoint struct

origin

CGPoint struct

normalize

bool value determining whether to normalize the result or not

Discussion

Returns a CGVector that would face the destination point from the origin point


vectorFromCGPoint


CGVector vectorFromCGPoint (
    CGPoint point);  
Parameters
point

CGPoint point struct to be converted

Discussion

Returns a CGVector struct converted from a CGPoint struct.

See Also


vectorFromCGSize


CGVector vectorFromCGSize (
    CGSize size);  
Parameters
size

CGSize size struct to be converted

Discussion

Returns a CGVector struct converted from a CGSize struct.

See Also


vectorFromDegree


CGVector vectorFromDegree (
    CGFloat degreeAngle);  
Parameters
degreeAngle

CGFloat degree value

Discussion

Returns a normal CGVector converted from a degree value


vectorFromRadian


CGVector vectorFromRadian (
    CGFloat radianAngle);  
Parameters
radianAngle

CGFloat radian value

Discussion

Returns a normal CGVector converted from a radian value


vectorInverse


CGVector vectorInverse (
    CGVector vector);  
Parameters
vector

CGVector vector struct to be inverted

Discussion

Returns a CGVector struct with negated values.

See Also


vectorIsZero


BOOL vectorIsZero (
    CGVector vector);  
Parameters
vector

value to check

Return Value

boolean determining whether it was equal to zero or not

Discussion

Checks if a vector is equal to CGVectorZero


vectorMultiplyByFactor


CGVector vectorMultiplyByFactor (
    CGVector vector,
    CGFloat factor);  
Parameters
vector

CGVector vector struct to be multiplied.

factor

CGFloat value to multiply both dx and dy by.

Discussion

Returns a CGVector that is the product of multiplying both values by the same factor.

See Also


vectorMultiplyByVector


CGVector vectorMultiplyByVector (
    CGVector vectorA,
    CGVector vectorB);  
Parameters
vectorA

CGVector vector struct to be factored.

vectorB

CGVector vector struct to be factored.

Discussion

Returns a CGVector that is the product of two other CGVectors (dx * dx, dy * dy)

See Also


vectorNormalize


CGVector vectorNormalize (
    CGVector vector);  
Parameters
vector

CGVector vector struct to be normalized

Discussion

Returns a CGVector normalized to have a distance of 1.0.


Constants

HIDDEN
kSKUDegToRadConvFactor
kSKUNavConstantCurrentFocusedNode
kSKUPadFromPhoneScale
kSKUPadToPhoneScale
kSKUPhoneFromPadScale
kSKUPhoneToPadScale
kSKURadToDegConvFactor
kSKURemoteInteractionOff
kSKURemoteInteractionOn
VISIBLE

HIDDEN


static const BOOL HIDDEN = 1;  
Discussion

BOOLEAN determining visibility For node.hidden properties, this is more intuitive than YES/NO

 
 node.hidden = VISIBLE; //this is visible
 node.hidden = HIDDEN; //this is hidden
 
 

kSKUDegToRadConvFactor


static const CGFloat kSKUDegToRadConvFactor = 0.017453292519943295;  // pi/180 
Discussion

Constant value to convert from degrees to radians. (0.017453292519943295)


kSKUNavConstantCurrentFocusedNode


extern NSString* const kSKUNavConstantCurrentFocusedNode;  
Discussion

Constant for retrieving whatever node is currently focused.


kSKUPadFromPhoneScale


static const CGFloat kSKUPadFromPhoneScale = (
    (
        CGFloat) 2.40003840061441);  
Discussion

Constant approximate value (2.40003840061441) good for scaling assets.


kSKUPadToPhoneScale


static const CGFloat kSKUPadToPhoneScale = (
    CGFloat) 0.41666;  
Discussion

Constant approximate value (0.41666) good for scaling assets.


kSKUPhoneFromPadScale


static const CGFloat kSKUPhoneFromPadScale = (
    CGFloat) 0.41666;  
Discussion

Constant approximate value (0.41666) good for scaling assets.


kSKUPhoneToPadScale


static const CGFloat kSKUPhoneToPadScale = (
    CGFloat) 2.40003840061441;  //likely very low usage as it would be upscaling 
Discussion

Constant approximate value (2.40003840061441) good for scaling assets.


kSKURadToDegConvFactor


static const CGFloat kSKURadToDegConvFactor = 57.29577951308232;  // 180/pi 
Discussion

Constant value to convert from radians to degrees. (57.29577951308232)


kSKURemoteInteractionOff


extern NSString* const kSKURemoteInteractionOff;  
Discussion

Constant for posting notification to turn user interface interaction off for the remote and controllers on tvOS.


kSKURemoteInteractionOn


extern NSString* const kSKURemoteInteractionOn;  
Discussion

Constant for posting notification to turn user interface interaction on for the remote and controllers on tvOS.


VISIBLE


static const BOOL VISIBLE = 0;  
Discussion

BOOLEAN determining visibility

For node.hidden properties, this is more intuitive than YES/NO

 
 node.hidden = VISIBLE; //this is visible
 node.hidden = HIDDEN; //this is hidden
 
 

Typedefs

kSKUButtonMethods
kSKUButtonStates
kSKUButtonTypes
kSKUGamepadButtonStates
kSKUGamePadInputs
kSKUGamePadPlayerFlags
kSKUMouseButtonFlags
kSKUNavModes

kSKUButtonMethods


typedef enum { 
    kSKUButtonMethodPostNotification = 1, 
    kSKUButtonMethodDelegate = 1 << 1, 
    kSKUButtonMethodRunActions = 1 << 2, 
} kSKUButtonMethods;  
Constants
kSKUButtonMethodPostNotification

Sends out an NSNotification with a name determined by either the notificationNameDown or notificationNameUp property. Only sends button release notifications if the release remained within the button bounds.

kSKUButtonMethodDelegate

Calls doButtonDown or doButtonUp on the delegate, set with the delegate property. This is the only way to detech button releases that aren't within the bounds of the button.

kSKUButtonMethodRunActions

Calls selectors set with methods setDownAction and setUpAction. Only sends button release calls if the release remained within the button bounds.

To get the same result in Swift, be sure to use rawValue

Discussion

Enumerator/flags for determining how buttons send signals.

See Also


kSKUButtonStates


typedef enum { 
    kSKUButtonStateUndefined = 1 << 0, 
    kSKUButtonStateDefault = 1 << 1, 
    kSKUButtonStatePressed = 1 << 2, 
    kSKUButtonStatePressedOutOfBounds = 1 << 3, 
    kSKUButtonStateHovered = 1 << 4, 
    kSKUButtonStateDisabled = 1 << 5,  
} kSKUButtonStates;  
Constants
kSKUButtonStateUndefined

Hopefully true if no state is present. Should never be the case.

kSKUButtonStateDefault

Flagged when enabled, yet sitting dormat.

kSKUButtonStatePressed

Flagged when enabled and actively pressed down.

kSKUButtonStatePressedOutOfBounds

Flagged when enabled and pressed down, but the current location of the input is beyond the bounds of the button.

kSKUButtonStateHovered

Flagged when button is hovered. (This will either be an OS X mouse or a tvOS focus)

kSKUButtonStateDisabled

Flagged when the button is disabled.

To get the same result in Swift, be sure to use rawValue

Discussion

Enumerator/flags for determining the state of buttons. States can coexist, but are unlikely for anything other than Hovered and either Pressed or Default to coincide.

See Also


kSKUButtonTypes


typedef enum { 
    kSKUButtonTypePush = 1, 
    kSKUButtonTypeToggle, 
    kSKUButtonTypeSlider, 
} kSKUButtonTypes;  
Constants
kSKUButtonTypePush

Determines push button type.

kSKUButtonTypeToggle

Determines toggle button type.

kSKUButtonTypeSlider

Determines slider button type.

Discussion

Enumerator to differentiate button types from each other.

See Also


kSKUGamepadButtonStates


typedef enum { 
    kSKUGamepadButtonStateBegan, 
    kSKUGamepadButtonStateChanged, 
    kSKUGamepadButtonStateEnded, 
    // kSKUGamepadButtonStateCancelled, 
} kSKUGamepadButtonStates;  
Constants
kSKUGamepadButtonStateBegan

Represents when a button is first pressed.

kSKUGamepadButtonStateChanged

Represents when a button's value changes, but remains pressed.

kSKUGamepadButtonStateEnded

Represents when a button is released.

Discussion

Enumeration describing the state of a button press from a gamepad.


kSKUGamePadInputs


Constants
kSKUGamePadInputLeftShoulder

Represents the left shoulder button.

kSKUGamePadInputLeftTrigger

Represents the left trigger button.

kSKUGamePadInputLeftThumbstick

Represents the left thumbstick axis.

kSKUGamePadInputRightShoulder

Represents the right shoulder button.

kSKUGamePadInputRightTrigger

Represents the right trigger button.

kSKUGamePadInputRightThumbstick

Represents the right thumbstick axis.

kSKUGamePadInputDirectionalPad

Represents the dpad axis.

kSKUGamePadInputButtonA

Represents the A button.

kSKUGamePadInputButtonB

Represents the B button.

kSKUGamePadInputButtonX

Represents the X button.

kSKUGamePadInputButtonY

Represents the Y button.

kSKUGamePadInputButtonPause

Represents the Pause button.

Discussion

Gamepad buttons enumerated as flags.

See Also


kSKUGamePadPlayerFlags


typedef enum { 
    kSKUGamePadPlayerFlag1 = 1 << 0, 
    kSKUGamePadPlayerFlag2 = 1 << 1, 
    kSKUGamePadPlayerFlag3 = 1 << 2, 
    kSKUGamePadPlayerFlag4 = 1 << 3, 
} kSKUGamePadPlayerFlags;  
Discussion

Player IDs enumerated as flags. Used to turn flags for which players can control nav, but you can use it for your own purposes as well.

See Also


kSKUMouseButtonFlags


typedef enum { 
    kSKUMouseButtonFlagLeft = 1 << 0, 
    kSKUMouseButtonFlagRight = 1 << 1, 
    kSKUMouseButtonFlagOther = 1 << 2, 
} kSKUMouseButtonFlags;  
Constants
kSKUMouseButtonFlagLeft

Flag for when left mouse is used.

kSKUMouseButtonFlagRight

Flag for when right mouse is used.

kSKUMouseButtonFlagOther

Flag for when other mouse is used (mouse buttons 3 and greater).

To get the same result in Swift, be sure to use rawValue

Discussion

Mouse button type enumerator/flags for Mac.

Platforms:

OSX

See Also


kSKUNavModes


typedef enum { 
    kSKUNavModeOn = 1, 
    kSKUNavModeOff, 
    kSKUNavModePressed, 
} kSKUNavModes;  
Constants
kSKUNavModeOn

Nav mode on.

kSKUNavModeOff

Nav mode off.

kSKUNavModePressed

Nav mode paused while a press is in progress. (Don't set this manually).

Discussion

Nav mode enumerator for focus based navigation.

See Also


Macro Definitions

SKUFont
SKUFont
SKUImage
SKUImage_multideclaration_block
SKUSharedUtilities
TARGET_OS_OSX_SKU

SKUFont


#define SKUFont UIFont 
Discussion

Allows simplification between platforms, using similar classes. On iOS and tvOS, remaps UIImage to SKUImage and UIFont to SKUFont and on OS X, remaps NSImage to SKUImage and NSFont to SKUFont as they are close enough that most methods work on all platforms. Also defines a constant that is only true on OS X for conditional targetting.

To get the same result in Swift, use this in a global scope:

 
 #if os(OSX)
	typealias SKUImage = NSImage;
	typealias SKUFont = NSFont;
 #else
	typealias SKUImage = UIImage;
	typealias SKUFont = UIFont;
 #endif
 
 

See Also


SKUFont


#define SKUFont NSFont 
Discussion

Allows simplification between platforms, using similar classes. On iOS and tvOS, remaps UIImage to SKUImage and UIFont to SKUFont and on OS X, remaps NSImage to SKUImage and NSFont to SKUFont as they are close enough that most methods work on all platforms. Also defines a constant that is only true on OS X for conditional targetting.

To get the same result in Swift, use this in a global scope:

 
 #if os(OSX)
	typealias SKUImage = NSImage;
	typealias SKUFont = NSFont;
 #else
	typealias SKUImage = UIImage;
	typealias SKUFont = UIFont;
 #endif
 
 

See Also


SKUImage


#define SKUImage NSImage 
Discussion

Allows simplification between platforms, using similar classes. On iOS and tvOS, remaps UIImage to SKUImage and UIFont to SKUFont and on OS X, remaps NSImage to SKUImage and NSFont to SKUFont as they are close enough that most methods work on all platforms. Also defines a constant that is only true on OS X for conditional targetting.

To get the same result in Swift, use this in a global scope:

 
 #if os(OSX)
	typealias SKUImage = NSImage;
	typealias SKUFont = NSFont;
 #else
	typealias SKUImage = UIImage;
	typealias SKUFont = UIFont;
 #endif
 
 

See Also


SKUImage_multideclaration_block


#if TARGET_OS_IPHONE 
#define SKUImage UIImage 
#define SKUFont UIFont 
#else 
#define SKUImage NSImage 
#define SKUFont NSFont 
#define TARGET_OS_OSX_SKU 1 
#endif  
Discussion

Allows simplification between platforms, using similar classes. On iOS and tvOS, remaps UIImage to SKUImage and UIFont to SKUFont and on OS X, remaps NSImage to SKUImage and NSFont to SKUFont as they are close enough that most methods work on all platforms. Also defines a constant that is only true on OS X for conditional targetting.

To get the same result in Swift, use this in a global scope:

 
 #if os(OSX)
	typealias SKUImage = NSImage;
	typealias SKUFont = NSFont;
 #else
	typealias SKUImage = UIImage;
	typealias SKUFont = UIFont;
 #endif
 
 

Language:

Objective-C

See Also


SKUSharedUtilities


Discussion

Simplifies access to the singleton.

To get the same result in Swift, use this in a global scope:

 
 let SKUSharedUtilities = SKUtilities2.sharedUtilities();
 
 

Language:

Objective-C


TARGET_OS_OSX_SKU


#define TARGET_OS_OSX_SKU 1 
Discussion

Allows simplification between platforms, using similar classes. On iOS and tvOS, remaps UIImage to SKUImage and UIFont to SKUFont and on OS X, remaps NSImage to SKUImage and NSFont to SKUFont as they are close enough that most methods work on all platforms. Also defines a constant that is only true on OS X for conditional targetting.

To get the same result in Swift, use this in a global scope:

 
 #if os(OSX)
	typealias SKUImage = NSImage;
	typealias SKUFont = NSFont;
 #else
	typealias SKUImage = UIImage;
	typealias SKUFont = UIFont;
 #endif
 
 

See Also