2D Toolkit Forum
2D Toolkit => Support => Topic started by: wubak on May 26, 2013, 10:12:15 pm
-
I seem to be experiencing some lag with the tk2d button event delegate.
I've tried using this event vs. just detecting straight input in my main game loop, and the game loop reacts immediately, whereas the button event presents a very short delay. Unfortunately, this delay is still enough to throw things off, as I'm detecting a collision at the time of the button event.
Any suggestions? I have been using the buttonDown event, but this seems to present as much lag as buttonPressed.
Thanks for any help.
-
Its the scale animation that causes the delay. If you turn off the animation, there won't be any latency at all.
You can set this by setting "scale time"
-
Thanks, I'll try that. This just sent me on a long adventure of learning about coRoutines and yield.
So, is there no way to run the scaling in parallel, or what if I just call the event first?
-
Yup you can certainly do that.
In tk2dButton.coHandleButtonPress,
Move button down event to before the StartCoroutine block.
-
Ah, cool. Is there any downside to making it execute that way?
-
Nope. It was just how it was written in the first place - didn't need instant feedback then. Thats why the source is there - go crazy customizing it :)
-
:)