-
Notifications
You must be signed in to change notification settings - Fork 258
Add Champ outro animation prompt and script #1806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Play this branch at https://play.threadbare.game/branches/endlessm/champ-outro-animation. (This launches the game from the start, not directly at the change(s) in this pull request.) |
| "frames": [{ | ||
| "duration": 1.0, | ||
| "texture": ExtResource("7_276wt") | ||
| }, { | ||
| "duration": 1.0, | ||
| "texture": ExtResource("7_276wt") | ||
| }, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func _physics_process(_delta: float) -> void: | ||
| # Make sure Champ doesn't swim out of the water! | ||
| # If he gets too close, turn him around and start swimming the other direction | ||
| if position.x > 400 or position.x < 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is a CharacterBody2D, you could also do this by having invisible walls that it collides with, and handling move_and_slide() returning true (i.e. a collision occurred) by flipping the velocity.
(Not saying you have to change this, just an idea.)
| champ_animation.scale.x *= -1 | ||
| velocity.x *= -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way you might spell this is:
| champ_animation.scale.x *= -1 | |
| velocity.x *= -1 | |
| velocity.x *= -1 | |
| champ_animation.flip_h = velocity.x < 0 |
I think the difference is that flip_h only applies to the texture itself, whereas setting scale.x = -1 would also flip any child nodes. In this particular case they are equivalent. Just leaving a note about what we do elsewhere in the project, e.g
threadbare/scenes/game_elements/characters/player/components/player_sprite.gd
Lines 13 to 14 in ecf740c
| if not is_zero_approx(player.velocity.x): | |
| flip_h = player.velocity.x < 0 |
|
|
||
| @onready var champ_animation: AnimatedSprite2D = $AnimatedSprite2D | ||
|
|
||
| var swim_speed: int = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var swim_speed: int = 100 | |
| @export var swim_speed: int = 100 |
Perhaps?

This modifies the outro to change the champ sprite to an AnimatedSprite2D; and to add basic movement with CharacterBody2D, along with hints on other ways the movement could be changed.