Godot: Add overloaded Timer.start() that accepts wait_time

Created on 10 Apr 2018  路  5Comments  路  Source: godotengine/godot

Godot version:

3.0.2

OS/device including version:

All

Enhancement Suggestion:
Add an overload of Timer.start() that accepts a float and automatically assigns it to wait_time.
it would basically roll two lines of code into one when desired.

$Timer.set_wait_time(1)
$Timer.start()
#vs
$Timer.start(1)

Steps to reproduce:

Minimal reproduction project:

feature proposal core

Most helpful comment

Or there could be a default parameter for start.. For example

$Timer.start() # default is -1 and this constant means the user should define it in set_wait_time
$Timer.start(-1) # same as above
$Timer.start(1) # start with custom wait time

All 5 comments

Sadly Godot doesn't support method overloading. We could add a new method for this though.

Or there could be a default parameter for start.. For example

$Timer.start() # default is -1 and this constant means the user should define it in set_wait_time
$Timer.start(-1) # same as above
$Timer.start(1) # start with custom wait time

Maybe I am using the wrong term, but Godot claims it supports this type of "overloading" for AnimatedSprite.

void play( String anim="" )
Play the animation set in parameter. If no parameter is provided, the current animation is played.

Chaosus's method seems doable. I can get on this if it has to be done.

Here is how it it done in AnimationPlayer.cpp

void AnimatedSprite::play(const StringName &p_animation) {

    if (p_animation)
        set_animation(p_animation);
    _set_playing(true);
}
Was this page helpful?
0 / 5 - 0 ratings