Skip to content

Commit

Permalink
Update to newer API
Browse files Browse the repository at this point in the history
  • Loading branch information
migueldeicaza committed Oct 7, 2023
1 parent c975fe4 commit 3574361
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
.executable(name: "TrivialSample", targets: ["TrivialSample"])
],
dependencies: [
.package(url: "https://github.com/migueldeicaza/SwiftGodot", revision: "0bdd4fe1336c552f991291a04d2c93fb5730cd5a")
.package(url: "https://github.com/migueldeicaza/SwiftGodot", revision: "162a1fbe3e84c1d65df9a88cb7b953a72b10fee7")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion Sources/Dodge/Hud.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Hud: CanvasLayer {

public func on_StartButton_pressed () {
startButton.hide()
emitSignal (signal: "StartGame")
emitSignal ("StartGame")
}

public func on_MessageTimer_timeout () {
Expand Down
13 changes: 5 additions & 8 deletions Sources/Dodge/Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,24 @@ class Player: Area2D {
func on_player_body_entered (body: PhysicsBody2D) {
// player dissapears after being hit
super.hide ()
super.emitSignal(signal: "hit")
super.emitSignal("hit")
// Must be deferred as we can't change physics properties on a physics callback.
collissionShape2D.setDeferred(property: StringName ("disabled"), value: Variant (true))
}

override func _process(delta: Double) {
var velocity = Vector2(x: 0, y: 0)

// Note: exact=false by default, in Rust we have to provide it explicitly
let input = Input.shared

if input.isActionPressed(action: "ui_right", exactMatch: false) {
if Input.isActionPressed(action: "ui_right", exactMatch: false) {
velocity = velocity + Vector2 (x: 0, y: 0)
}
if input.isActionPressed(action: "ui_left", exactMatch: false) {
if Input.isActionPressed(action: "ui_left", exactMatch: false) {
velocity = velocity + Vector2.left
}
if input.isActionPressed(action: "ui_down", exactMatch: false) {
if Input.isActionPressed(action: "ui_down", exactMatch: false) {
velocity = velocity + Vector2.down
}
if input.isActionPressed(action: "ui_up", exactMatch: false) {
if Input.isActionPressed(action: "ui_up", exactMatch: false) {
velocity = velocity + Vector2.up
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/TrivialSample/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SpinningCube: Node3D {
className: "SpinningCube",
hint: .flags,
hintStr: "Text",
usage: .propertyUsageDefault)
usage: .default)
]

let x = Vector2(x: 10, y: 10)
Expand Down
6 changes: 3 additions & 3 deletions Sources/UglySample/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func loadScene (scene: SceneTree) {
}

print ("ClassList:")
let r = ClassDB.shared.getClassList()
let r = ClassDB.getClassList()
for x in r {
print (" classItem: \(x)")
}
Expand Down Expand Up @@ -94,7 +94,7 @@ class SpinningCube: Node3D {
className: "SpinningCube",
hint: .flags,
hintStr: "Text",
usage: .propertyUsageDefault)
usage: .default)
]

let x = Vector2(x: 10, y: 10)
Expand Down Expand Up @@ -129,7 +129,7 @@ class SpinningCube: Node3D {
print (connect(signal: SpinningCube.myFirstSignal, callable: Callable(object: self, method: StringName ("MyCallback"))))
print (connect(signal: SpinningCube.printerSignal, callable: Callable(object: self, method: StringName ("MyPrinter"))))
print (connect(signal: StringName ("ready"), callable: Callable (object: self, method: StringName ("readyCallback"))))
let r = ready.connect {
let _ = ready.connect {
print ("READY INVOKED")
}
}
Expand Down

0 comments on commit 3574361

Please sign in to comment.