All Projects → MitrofD → Tlanalogjoystick

MitrofD / Tlanalogjoystick

Licence: mit
Analog joystick component for iOS

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Tlanalogjoystick

Lifesaver
Conway's Game of Life implemented as an artistic, abstract macOS screensaver and tvOS app using SpriteKit
Stars: ✭ 113 (-49.33%)
Mutual labels:  spritekit
Sukermariobros
SukerMarioBros. — Swift + SpriteKit Super Mario Brosers "port"
Stars: ✭ 143 (-35.87%)
Mutual labels:  spritekit
Cleanclosurexcode
An Xcode Source Editor extension to clean the closure syntax.
Stars: ✭ 186 (-16.59%)
Mutual labels:  closure
Javascript.anomaly
Examples of not obvious behaviors for javascript beginner programmers
Stars: ✭ 124 (-44.39%)
Mutual labels:  closure
Vjoyserialfeeder
Feed Virtual Joystick driver with data from a serial port
Stars: ✭ 133 (-40.36%)
Mutual labels:  joystick
Flappy Fly Bird
🐦 Flappy Bird reincarnation [Swift 5.3, GameplayKit, SpriteKit, iOS 12].
Stars: ✭ 150 (-32.74%)
Mutual labels:  spritekit
Ios Learning Materials
📚Curated list of articles, web-resources, tutorials and code repositories that may help you dig a little bit deeper into iOS [and Apple Platforms].
Stars: ✭ 1,380 (+518.83%)
Mutual labels:  spritekit
Sktiled
Swift framework for working with Tiled assets in SpriteKit
Stars: ✭ 208 (-6.73%)
Mutual labels:  spritekit
Life Calendar
A look at the big picture.
Stars: ✭ 139 (-37.67%)
Mutual labels:  spritekit
Kommander Ios
A lightweight, pure-Swift library for manage the task execution in different threads. Through the definition a simple but powerful concept, Kommand.
Stars: ✭ 167 (-25.11%)
Mutual labels:  closure
Linker
🎯 Your easiest way to handle all URLs.
Stars: ✭ 129 (-42.15%)
Mutual labels:  closure
Sliders Swiftui
Collection of unique fully customizable SwiftUI sliders, joysticks, trackpads and more!
Stars: ✭ 132 (-40.81%)
Mutual labels:  joystick
Unitypausemenu
This is an open source Unity pause menu created for the game New Horizons, and it's completely free because of how a pause menu is a core component of a game, while the unity asset store was lacking in such an asset (until this was released on the asset store).
Stars: ✭ 160 (-28.25%)
Mutual labels:  joystick
Actionclosurable
Extensions which helps to convert objc-style target/action to swifty closures
Stars: ✭ 120 (-46.19%)
Mutual labels:  closure
Easyclosure
🍩 Unified communication patterns with easy closure in Swift
Stars: ✭ 200 (-10.31%)
Mutual labels:  closure
Retropie Joystick Selection
A script to let the user choose the controllers for RetroArch players 1-4
Stars: ✭ 106 (-52.47%)
Mutual labels:  joystick
Cocos Creator Joystick
🕹 Cocos Creator Joystick Demo 虚拟摇杆
Stars: ✭ 148 (-33.63%)
Mutual labels:  joystick
Breakouttorefresh
Play BreakOut while loading - A playable pull to refresh view using SpriteKit
Stars: ✭ 2,466 (+1005.83%)
Mutual labels:  spritekit
Freejoy
STM32F103 USB HID game device controller with flexible configuration
Stars: ✭ 207 (-7.17%)
Mutual labels:  joystick
Haskellspritekit
Haskell binding to Apple's SpriteKit framework
Stars: ✭ 165 (-26.01%)
Mutual labels:  spritekit

AnalogJoystick.swift

Preview

Analog joustick

Features

  • Begin handler
  • Tracking handler
  • Stop handler
  • Set/change joystick diameter
  • Set/change stick && substrate colors
  • Set/change stick && substrate images

Manual

  1. Just drop the AnalogJoystick.swift file into your project.
  2. That's it!

Init examples:

init with 100px diameter.Colors & images you can change later

let joystick = AnalogJoystick(diameter: 100)
// or
let joystick = 🕹(diameter: 100)

Substrate has 100px diameter, stick has 50px diameter

let joystick = AnalogJoystick(diameters: (100, 50)) 

init with 100px diameter.Substrate has blue color, stick has yellow color

let joystick = AnalogJoystick(diameter: 100, colors: (UIColor.blue(), UIColor.yellow()))

init with 100px diameter.Substrate has "substrate" image, stick has "stick" image

let joystick = AnalogJoystick(diameter: 100, images: (UIImage(named: "substrate"), UIImage(named: "stick")))

init with 100px diameter.Substrate has blue color && "substrate" image, stick has yellow color && "stick" image

let joystick = AnalogJoystick(diameter: 100, colors: (UIColor.blue(), UIColor.yellow()), images: (UIImage(named: "substrate"), UIImage(named: "stick")))

init with substrate && stick diameters.Substrate has blue color && "substrate" image, stick has yellow color && "stick" image

let joystick = AnalogJoystick(diameters: (100, 50), colors: (UIColor.blue(), UIColor.yellow()), images: (UIImage(named: "substrate"), UIImage(named: "stick")))

init with substrate && stick diameters.Substrate has blue color, stick has yellow color

let joystick = AnalogJoystick(diameters: (100, 50), colors: (UIColor.blue(), UIColor.yellow()))

init with substrate && stick diameters.Substrate has "substrate" image, stick has "stick" image

let joystick = AnalogJoystick(diameters: (100, 50), images: (UIImage(named: "substrate"), UIImage(named: "stick")))

Designated initializator

init(substrate: AnalogJoystickSubstrate, stick: AnalogJoystickStick)

WHERE:

  • substrate - substrate of joystick (AnalogJoystickSubstrate:AnalogJoystickComponent)
  • stick - stick of joystick (AnalogJoystickStick:AnalogJoystickComponent)

Convenience initializators:

convenience init(diameters: (substrate: CGFloat, stick: CGFloat?), colors: (substrate: UIColor?, stick: UIColor?)? = nil, images: (substrate: UIImage?, stick: UIImage?)? = nil)
convenience init(diameter: CGFloat, colors: (substrate: UIColor?, stick: UIColor?)? = nil, images: (substrate: UIImage?, stick: UIImage?)? = nil)

Typealias

typealias AnalogJoystick = 🕹

Example

let joystick = 🕹(diameter: 110) // it's equal let joystick = AnalogJoystick(diameter: 110)

Handlers

  • var beginHandler: (() -> Void)? // before move
  • var trackingHandler: ((AnalogJoystickData) -> ())? // when move
  • var stopHandler: (() -> Void)? // after move

Computed Properties

  • var stickColor: UIColor (get/set)
  • var substrateColor: UIColor (get/set)
  • var stickImage: UIImage? (get/set)
  • var substrateImage: UIImage? (get/set)
  • var diameter: CGFloat (get/set)

Examples

Create joystick

let joystick = AnalogJoystick(diameter: 100) // you can set images/color later

or with images

let joystick = AnalogJoystick(diameter: 100, images: (UIImage(named: "substrate"), UIImage(named: "stick")))

Tracking With Closure

joystick.beginHandler = { [unowned self] in
  // Something...
}

joystick.trackingHandler = { [unowned self] data in
  // Something...
  // data contains angular && velocity (data.angular, data.velocity)
}

joystick.stopHandler = { [unowned self] in
  // Something...
}

Change diameter

  joystick.diameter = 100 // set new diameter

Change colors

  joystick.stick.color = UIColor.yellow() // set yellow color to stick node
  joystick.substrate.color = UIColor.red() // set red color to substrate node

Change images

  joystick.stick.image = UIImage(imageNamed: "yourStickImage") // set image to stick node
  joystick.substrate.image = UIImage(imageNamed: "yourSubstrateImage") // set image to substrate node

License

The MIT License (MIT)

Copyright (c) 2015...2018 Dmitriy Mitrophanskiy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].