Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 117 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,128 @@ import GameWidget
import SpriteKit

let node = Display()
.place {
Button(.init("Select"))
.position(CGPoint(x: 0, y: 32))
Button(.init("Cancel"))
.position(CGPoint(x: 0, y: -32))
}
.node()
.place {
Button(.init("Select"))
.position(CGPoint(x: 0, y: 32))
Button(.init("Cancel"))
.position(CGPoint(x: 0, y: -32))
}
.node()

```

## Layout widgets

### Display

Display multiple widgets in one SKNode.

```swift
let node = Display()
.place {
Button(.init("Select"))
.position(CGPoint(x: 0, y: 32))
Button(.init("Cancel"))
.position(CGPoint(x: 0, y: -32))
}
.place {
Button(.init("Select_B"))
.position(CGPoint(x: 0, y: 64))
Button(.init("Cancel_B"))
.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.

```swift
let node = Node {
Button(.init("Select"))
.position(CGPoint(x: 0, y: 32))
Button(.init("Cancel"))
.position(CGPoint(x: 0, y: -32))
}
.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.

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

Extension is a special widget that cannot generate SKNode.

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

## Supported widgets

- Button(beta)
- Bar chart(beta)
### Button(beta)

```swift
let node = Button(.init("Button"))
.node()
```

### Bar chart(beta)

```swift
let node = HorizontalSingleBarChart(name: .init("Bar"))
.node()
```

## Planning to make follows

- Controller stick
### Controller (joy stick)