Giter Club home page Giter Club logo

skjoystick's Introduction

SKJoystick

SKJoystick is a retro-arcade joystick for SpriteKit

Language Build Status Platform License

demo

Available directions:

SKJoystick is a library written in Swift to create a typical retro arcade joystick for SpriteKit. Using a couple of textures , the famous SKEase library to simulate the elastic bouncing animation. I've added also three buttons to have a complete control scene to move your hero, jump, fire and made other actions..

Features

Creating a joystick node :

    - convenience init(texture: SKTexture?, color: SKColor = .clear, size: CGSize = CGSize(width:200.0,height:200.0),knob:String! = "blueKnob.png") {
      Initializes a new SKSpriteNode object aka our joystick.
  • 8 directions: up, down, left, righ and diagonals
  • change color, alpha and size
  • knowing in time real the directions and the releasing through delegate methods

ToDo

  • new knob textures

Requirements

  • iOS 9.0+
  • Xcode 9.2+
  • Swift 4.0+

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

Add the source folder to your project and use it.

Usage

class GameScene: SKScene, SKJoystickDelegate {
    var joyStick : SKJoystick!
    override func didMove(to view: SKView) {
        // Show joystick
        let joySize = CGSize(width:300,height:300)
        joyStick = SKJoystick.init(texture: nil, color: .clear, size: joySize, knob:"blueKnob.png")
        self.addChild(joyStick)
        joyStick.zPosition = 1
        joyStick.alpha = 0.5
        joyStick.position = CGPoint(x:self.frame.width/7,y:self.frame.height/4)
        joyStick.isUserInteractionEnabled = true
        joyStick.delegate = self
    }

Follow the example located to GameScene.swift to understand the delegate methods (really simple to use..), the property direction contain one of these constants:

enum Sense: Int {
    case UP = 0
    case UP_RIGHT = 1
    case RIGHT = 2
    case DOWN_RIGHT = 3
    case DOWN = 4
    case DOWN_LEFT = 5
    case LEFT = 6
    case UP_LEFT = 7
    case RELEASED = 8
}

License

SKJoystick is released under the MIT License

skjoystick's People

Contributors

aornano avatar

Watchers

James Cloos 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.