Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Swift

on:
pull_request:
branches: ["main", "develop"]

jobs:
build:

runs-on: macos-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: swift build -v
- name: Run tests
run: swift test -v
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.6
// swift-tools-version: 5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
14 changes: 14 additions & 0 deletions Sources/GameWidget/BarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ public struct HorizontalSingleBarChart {
}
}

public init(name: ID) {
self.name = name
}

var name: ID
var position = CGPoint.zero
var width = CGFloat(10)
var length = CGFloat(100)
var alignment = HorizontalBarChartAlignmentMode.right
var color = SKColor.systemGreen
var backgroundColor = SKColor.gray

@discardableResult public func width(_ value: CGFloat) -> Self {
Expand All @@ -59,6 +64,12 @@ public struct HorizontalSingleBarChart {
return result
}

@discardableResult public func color(_ value: SKColor) -> Self {
var result = self
result.color = value
return result
}

@discardableResult public func backgroundColor(_ value: SKColor) -> Self {
var result = self
result.backgroundColor = value
Expand All @@ -71,8 +82,11 @@ extension HorizontalSingleBarChart: Widget {

public func node() -> SKNode {
let result = SKSpriteNode(color: self.backgroundColor, size: CGSize(width: self.length, height: self.width))
let bar = SKSpriteNode(color: self.color, size: CGSize(width: self.length, height: self.width))
result.anchorPoint = self.alignment.anchorPoint()
bar.anchorPoint = self.alignment.anchorPoint()
result.position = self.position
result.addChild(bar)
return result
}
}
54 changes: 0 additions & 54 deletions Sources/GameWidget/Example.swift

This file was deleted.