This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi. I have a very simple question.
I have a Sprite (RefreshButton) that I want to rotate 360 degrees after it has been pressed. I'm detecting whether it's been clicked like so:
func _input(event):
if event is InputEventMouseButton:
if $RefreshButton.hovered:
if event.button_index == BUTTON_LEFT:
if not event.pressed: # button up
$RefreshButton.spin()
Now, the problem is, the only way I know how to make that animation play, is to have a _process(delta) method constantly check whether it needs to be played. Like so:
var spinning: bool = false
var rotation_speed: int = 1000
func spin():
spinning = true
func _process(delta):
print(spinning)
if spinning:
rotation_degrees = delta * rotation_speed
if rotation_degrees > 359:
rotation_degrees = 0
spinning = false
This seems very unoptimal (requires a function that constantly checks whether the animation should be played, even though we know exactly at which point it should start), and what's worse, with more animations, it makes _process(delta) method extremely bloated.
What is the proper way of achieveing this, without having a method that's constantly running in the background?
Subreddit
Post Details
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/godot/comme...