Skip to content

Repository files navigation

GameWidget

GitHub issuesGitHub licenseSwift

User interface widgets for SpriteKit.

DEMO

import GameWidget
import SpriteKit
letnode=Display().place{Button(.init("Select")).modifiable
.position(CGPoint(x:0, y:32))Button(.init("Cancel")).modifiable
.position(CGPoint(x:0, y:-32))}.node()

Layout widgets

Display

Display multiple widgets in one SKNode.

letnode=Display().place{Button(.init("Select")).modifiable
.position(CGPoint(x:0, y:32))Button(.init("Cancel")).modifiable
.position(CGPoint(x:0, y:-32))}.place{Button(.init("Select_B")).modifiable
.position(CGPoint(x:0, y:64))Button(.init("Cancel_B")).modifiable
.position(CGPoint(x:0, y:-64))HorizontalSingleBarChart(name:.init("Bar"))}.node()

Up to 10 widgets can be placed on a single Display.place.

Node

Node widget is modifiable with the values used for SKNode parameters.

letnode=Node{Button(.init("Select")).modifiable
.position(CGPoint(x:0, y:32))Button(.init("Cancel")).modifiable
.position(CGPoint(x:0, y:-32))}.modifiable
.posisition(CGPoint(x:0, y:32)).zRotation(0.5).node()

Up to 10 widgets can be placed on a single Node.

Extension

Use Extension to place more than 10 widgets.

// case Display
letnode=Display().place{Button(.init("Select")).modifiable
.position(CGPoint(x:0, y:32))Button(.init("Cancel")).modifiable
.position(CGPoint(x:0, y:-32))Button(.init("Select_B")).modifiable
.position(CGPoint(x:0, y:64))Button(.init("Cancel_B")).modifiable
.position(CGPoint(x:0, y:-64))HorizontalSingleBarChart(name:.init("Bar"))
//...
Extension{Button(.init("Select")).modifiable
.position(CGPoint(x:0, y:32))Button(.init("Cancel")).modifiable
.position(CGPoint(x:0, y:-32))Button(.init("Select_B")).modifiable
.position(CGPoint(x:0, y:64))Button(.init("Cancel_B")).modifiable
.position(CGPoint(x:0, y:-64))HorizontalSingleBarChart(name:.init("Bar"))}}.node()

Extension is a special widget that cannot generate SKNode.

letnode=Extension{Button(.init("Select")).modifiable
.position(CGPoint(x:0, y:32))Button(.init("Cancel")).modifiable
.position(CGPoint(x:0, y:-32))Button(.init("Select_B")).modifiable
.position(CGPoint(x:0, y:64))Button(.init("Cancel_B")).modifiable
.position(CGPoint(x:0, y:-64))HorizontalSingleBarChart(name:.init("Bar"))}.node() // fatalError

Supported widgets

Button(beta)

letnode=Button(.init("Button")).node()

Bar chart(beta)

letnode=HorizontalSingleBarChart(name:.init("Bar")).node()

Planning to make follows

Controller (joy stick)

About

A simple UI layout tools for SpriteKit

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages