Giter Site home page Giter Site logo

fengweijp / hlspritekit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hilogames/hlspritekit

0.0 0.0 0.0 492 KB

SpriteKit scene and node subclasses, plus various utilities.

License: MIT License

Objective-C 96.41% Ruby 0.08% C 0.95% Shell 2.57%

hlspritekit's Introduction

HLSpriteKit

CI Status Version License Platform

SpriteKit scene and node subclasses, plus various utilities.

Classes

HLGestureTarget

A gesture target handles gestures from UIGestureRecognizers. It can be attached to any SKNode using the class category SKNode+HLGestureTarget.

The use pattern is this: The SKScene knows about its view, and so the scene is the UIGestureHandlerDelegate. It manages a collection of shared gesture recognizers, which it attaches to and detaches from its view as appropriate. When a certain gesture is recognized by a gesture recognizer, the scene figures out which node or nodes are the target of the gesture, and it forwards the gestures to those nodes using the HLGestureTarget interface.

Here's the point: The scene can effectively use UIGestureRecognizers rather than touchesBegan, and the gesture handling code can be encapsulated within node subclasses (rather than dumped into a bloated scene).

HLLayoutManager

A layout manager provides a single method (layout) to lay out nodes. It can be attached to any SKNode using the class category SKNode+HLLayoutManager.

The only layout manager currently provided in HLSpriteKit is HLTableLayoutManager, for table-like layouts, but more are planned.

Putting layout code in a third-party object (rather than in the SKScene or SKNode subclass) allows for easier re-use of common layout math.

Custom SKNode Subclasses

HLSpriteKit includes a number of custom SKNode subclasses.

  • HLGridNode. Organizes content into a grid of same-size squares, with visual formatting and interaction options.

  • HLLabelButtonNode. A simple SKLabelNode displayed over an SKSpriteNode, but with extra sizing and alignment options. In particular, it can size the sprite node to the text, and it can do baseline alignment so that the full font size (including descender) is vertically centered in the background; the math for the calculation is provided for all SKLabelNodes in a category SKLabelNode+HLLabelNodeAdditions.

  • HLMenuNode. An interface and model of a hierarchical menu of buttons. The interface is a simple vertical stack of buttons, for now, but it provides a few layout and animation features.

  • HLMessageNode. Shows a text message over a solid or textured background, with some animation options.

  • HLScrollNode. Provides support for scrolling and scaling its content with pan and pinch gestures. The interface is deliberately analagous to UIScrollView.

  • HLToolbarNode. A horizontal toolbar of squares, with various visual formatting, sizing, and animation options.

  • HLTiledNode. Behaves like an SKSpriteNode that tiles its texture to fit a specified size.

HLScene

HLScene contains functionality useful to many scenes, including but not limited to:

  • loading scene assets in a background thread
  • a shared gesture recognition system and an HLGestureTarget-aware gesture delegate implementation
  • modal presentation of a node above the scene
  • registration of nodes for common scene-related behaviors (e.g. resizing when the scene resizes; not encoding when the scene encodes; etc)

Development

HLSpriteKit is under active development, and so includes other experimental classes and functions which seem general enough for reuse. For instance, a generic SKTexture store and SKEmitterNode store are included, but it's not clear they are useful.

Installation

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

pod 'HLSpriteKit'

Author

Karl Voskuil [email protected]

License

HLSpriteKit is available under the MIT License. See the LICENSE file for more info.

hlspritekit's People

Contributors

karlvoskuil avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.