Git Product home page Git Product logo

morespritekit's Introduction

PRs Welcome Carthage Platform support

MoreSpriteKit

This repository offers additional node types and effects which you can use in combination with SpriteKit. In addition it provides extensions to make complicated tasks a bit easier, and improve the readability of your code.

All sources are written in Swift.

MSKAnimatedLabel

SKNode that draws specified text over multiple lines, separated per newLine character. The text typing can also be animated, meaning each character will be added after a specified interval, creating a typewriter effect.

Use public initializer:

public init(text: String,
            horizontalAlignment: SKLabelHorizontalAlignmentMode = .center,
            durationPerCharacter: Double = 0.05,
            fontSize: CGFloat = 12,
            marginVertical: CGFloat = 15.0,
            fontColor: SKColor = .white,
            fontName: String = "Chalkduster",
            skipSpaces: Bool = true
            labelWidth: CGFloat = 0.0
            finishTypingOnTouch: Bool = false)

Where the text can be separated by new line characters to indicate start of new line. Specify a specific labelWidth to wrap all text to a specific width. MSKAnimatedLabel will create new lines where necessary. When the specified labelWidth is to small for a certain CharacterSequence, a fatal error is thrown.

When durationPerCharacter <= 0.0, all lines will be drawn immediately without any animation. When finishTypingOnTouch equals true, all remaining lines will be drawn instantly without any animation when a user taps the label.

Preview

MSKEmitterLabel

SKNode that draws specified text using an emitter that follows the characters outlines, over a given duration.

Use public initializer:

public init(text: String,
            font: UIFont,
            emitterName: String,
            marginHorizontal: CGFloat = 10.0,
            animationDuration: Double = 2.0,
            addEmitterInterval: Double = 0.1)

Preview

SKAction+Spiral

Extension on SKAction allowing to create a spiraling movement. Usage:

SKAction.spiral(startRadius: radius,
                endRadius: radius-50,
                totalAngle: CGFloat(.pi * 2.0),
                centerPoint: .zero,
                duration: 1.5)

Preview

SKAction+Shake

Extension on SKAction allowing to create a shake effect. NB preview as GIF is not very useful, for proper demonstration please see the example application.

Usage:

SKAction.shake(shakeDuration: 0.2,
               intensity: arc4random_uniform(40)+10,
               duration: 3)

Preview

SKShapeNode+Arrow

Extension on SKShapeNode allowing to create a node with an arrow shape. Usage:

let arrow = SKShapeNode(arrowWithFillColor: randomColor,
                        strokeColor: randomColor,
                        lineWidth: 4,
                        length: 100,
                        tailWidth: 20,
                        headWidth: 50,
                        headLength: 30)

Preview

SKTexture+RadialGradient

Extension on SKTexture allowing to create a texture with a radial gradiant. Could be used for example for range nodes, indicating a creatures attack range. Usage:

let radialGradientSize = CGSize(width: 150, height: 150)
let radialGradientColors = [UIColor.red, UIColor.blue, UIColor.green, UIColor.blue, UIColor.orange]
let radialGradientLocations: [CGFloat] = [0, 0.25, 0.45, 0.65, 1.0]

let radialTexture = SKTexture(radialGradientWithColors: radialGradientColors,
                              locations: radialGradientLocations,
                              size: radialGradientSize)

let radialNode = SKSpriteNode(texture: radialTexture)

Preview

SKAction+TimingMode and Array+SKAction

  • Public extensions on SKAction to add a timingMode or for example a repeatForever inline.
  • Public extensions on Array to convert it inline to a SKAction.group or SKAction.sequence.

Usage:

let actions: [SKAction] = [.run { self.addEmitterLabel() }, .wait(forDuration: 10)]
run(actions.sequence().forever())

CGFloat+Arithmetics

Public functions to easily add/ subtract/ multiply/ divide Int with CGFloat and vice versa. Return type is of CGFloat.

Tiled support

Todo

Requirements

  • iOS 10.3+
  • Xcode 10.1+
  • Swift 5+

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate MoreSpriteKit into your Xcode project using Carthage, specify it in your Cartfile:

github "sanderfrenken/MoreSpriteKit" "master"

Manually

If you prefer not to use any of the aforementioned dependency managers, you can integrate the desired sources in your project manually, by adding the corresponding Swift files to your project.

SwiftLint

We use Swiftlint from Realm to lint our code. SwiftLint has to be installed on your device. More info can be found on SwiftLint. Details about the specific settings for this project can be found in the .swiftlint.yml file.

Demo app

This project contains an application target being a demo project that demonstrates the usage of all offered functionalities.

Other information

  • If you think that something is missing or would like to propose new feature, please create an issue.
  • Please feel free to โญ๏ธ the project. This gives confidence that you like it which stimulates further development and support ๐Ÿคฉ

Games using MoreSpriteKit

The following games are using MoreSpriteKit:

License

MIT

morespritekit's People

Contributors

sanderfrenken avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

morespritekit's Issues

Add reusable Button component

I could make a start where you can init a button which you need to provide a texture for normalState, a texture for pressedState (optional), an action (optional), a font (optional) and a text (optional) and optional actions to run on touchesStarted/ touchesEnded. That way, you can give an action like `fadeOut` or `scaleTo` so it also facilitates some more complex stuff.

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.