0 votes

I'm using custom drawings for almost everything in one project I'm working on. Until now I have used linear velocity etc. But now I need to create some kind of small animations that disappear after some time. For example an small animation when the player touch the screen (longer than the actual touch).

I don't know what is the best method to do this, and I would like to know if it is a better method that the ones I can think of:

  • Add child to that exact animation with a timer. I should "deactivate" the child after the times consume (or other conditional). I'm not sure how to do this exactly, but seems to be the best approach.
  • Create a conditional inside a _draw():. I don't like that much this approache because I maybe I need more than one animation at a time, and should check that condition every frame.
in Engine by (105 points)

Note that _draw is called not every frame, but only after (but not immediately after) update() is called.

Yes I know, I simplified because since I'm using already a lot of custom drawing I need to use a new _draw(): function or the ones I'm already using.

1 Answer

0 votes

I think the best way to do this is create an instance of an scene and add it as a child:

For example:

    anim = preload("res://winanim.scn").instance()

And in the node free that node when necessary, for example with a timer

    var timer = Timer.new()
timer.set_wait_time(3) # time in secondn
timer.connect("timeout",self,"queue_free")
add_child(timer)
timer.start()

There are probably other better solutions, but this one seems not that bad. You can also quit that scene with

queue_free() 

at any point.

reddit source

by (105 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.