CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.
TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2015 |
Maintained by Sven Korset.
INSpriteKit adds some functionality to use with Sprite Kit. This library is designed prior for iOS, but may also be used with OS X. On OS X mouse events (especially left mouse button clicks) are interpreted as touches.
userInteractionEnabled
property.touchPriority
to get touches even when not on top of all other nodes.ScalarNearOther()
to determine if a CGFloat is the same as another plus minus epsilon.insertChildOrNil:atIndex:
as a working replacement for insertChild:atIndex:
which is buggy on iOS 7.bringToFront
and sendToBack
for manipulating the tree order.changeParent:
replaces the node's parent and converts its position.stringifyNodeTree
creates a NSString from a node's tree for debugging purposes.isPointInside:
checks if a position point is inside of the sprite node's texture.sizeUnscaled
returns the sprite's non-scaled size.emitterLife
calculates an emitter's total life time.runActionToRemoveWhenFinished
adds an action which will remove the emitter if finished emitting.There are two example projects one for iOS and the other for OS X. They both use the same example scenes and tests and can be found inside of the 'Example' directory.
To run an example project run pod install
from the project directory first (cocoapods installed required).
Then open the workspace file INSpriteKitExample.xcworkspace
with Xcode and run the example or the tests.
The example scenes are within the 'ExampleScenes' directory, just go through them to see how to use the library.
To see the difference in behavior between INSKView and SKView just rename the skView classes' name in the Storyboard (WindowController.xib file for the OS X project) from INSKView to SKView.
iOS 7+ or OS X 10.9+, ARC enabled
Needs the following Frameworks:
or clone the repo manually, add the INSpriteKit directory to your project and add the necessary frameworks mentioned in the requirements section to your project.
Include the INSpriteKit.h header file into your project to get access to all additions.
If using OS X and iOS code in the same project it may be handy to also include INSKOSBridge.h which adds some types and methods which are otherwise not available for the other OS.
On OS X there may occur a touch delivery bug when having AppKit controls over the Sprite Kit scene. Some mouse up events may be lost.
To reproduce the bug run the OS X example project and start the TouchHandlingScene. Move the mouse over the upper left corner of the AppKit button at the bottom of the scene so the mouse is also over the red button pointing to both buttons. Pressing the left mouse button will now trigger the AppKit button and pressing the right mouse button will trigger the red Sprite Kit button.
However, when pressing and holding the left mouse button there, then pressing and holding the right mouse button and afterwards releasing the left mouse button prior the right will result in a lost event. In this case the mouse down event of the right mouse button won't be delivered to the scene, but the right mouse button up event so it will be overreleased.
Reverting the order will produce a click down event which will not be lifted. So when pressing and holding the right mouse button there, then pressing and holding the left mouse button and afterwards releasing the right mouse button prior the left will also result in a lost event. In this case the mouse up event of the right mouse button won't be delivered.
You can see the lost events by watching the little green/cyan square at the right of the buttons. When the total number of buttons pressed is negative the square will disappear and when a click is not released the size of the square won't shrink back to the normal size.
Using [NSEvent addLocalMonitorForEventsMatchingMask:handler:] for event observing instead will result in a likewise buggy behavior, because clicks on the table view's cells won't deliver the corresponding touch up events.
Any help will be appreciated, so if anybody can fix this or point me to a good direction don't hesitate to drop me a message.
INSpriteKit is available under the MIT license. See the LICENSE file for more info.