Skip to content

Commit

Permalink
✨ Add character switcher
Browse files Browse the repository at this point in the history
Also renames the Character.sky case to Character.obel.
  • Loading branch information
alicerunsonfedora committed Aug 21, 2023
1 parent 0c8d22f commit 264264e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ extension AnthroCharacterBody2D {
func setCharacter(args: [Variant]) -> Variant? {
ClassInfo.withCheckedProperty(named: "character", in: args) { arg in
character = Character(rawValue: Int(arg) ?? 0) ?? .chelsea
changeSprites()
}
}

Expand Down
11 changes: 10 additions & 1 deletion AnthroBase/Sources/AnthroBase/AnthroCharacterBody2D.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class AnthroCharacterBody2D: CharacterBody2D {
@PickerNameProvider
public enum Character: Int {
case chelsea
case sky
case obel
}

@SceneTree(path: "Sprite")
Expand Down Expand Up @@ -75,6 +75,15 @@ public class AnthroCharacterBody2D: CharacterBody2D {
super._physicsProcess(delta: delta)
}

func changeSprites() {
switch character {
case .chelsea:
sprite?.texture = #texture2DLiteral("res://resources/sprt_chelsea.png")
case .obel:
sprite?.texture = #texture2DLiteral("res://resources/sprt_obel.png")
}
}

private func updateBlendingProperties(with vector: Vector2) {
guard let animationTree else {
GD.pushError("Animation tree is missing.")
Expand Down

0 comments on commit 264264e

Please sign in to comment.