User interface widgets for SpriteKit.
import GameWidget
import SpriteKit
let node = Display()
.place {
Button(.init("Select"))
.modifiable
.position(CGPoint(x: 0, y: 32))
Button(.init("Cancel"))
.modifiable
.position(CGPoint(x: 0, y: -32))
}
.node()
Display multiple widgets in one SKNode.
let node = 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
widget is modifiable with the values used for SKNode parameters.
let node = 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
.
Use Extension
to place more than 10 widgets.
// case Display
let node = 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.
let node = 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
let node = Button(.init("Button"))
.node()
let node = HorizontalSingleBarChart(name: .init("Bar"))
.node()