Hello Guest

Author Topic: Button Event Lag?  (Read 5569 times)

wubak

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Button Event Lag?
« 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Button Event Lag?
« Reply #1 on: May 26, 2013, 10:59:22 pm »
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"

wubak

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Button Event Lag?
« Reply #2 on: May 27, 2013, 05:12:16 am »
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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Button Event Lag?
« Reply #3 on: May 27, 2013, 11:48:58 am »
Yup you can certainly do that.
In tk2dButton.coHandleButtonPress,
Move button down event to before the StartCoroutine block.

wubak

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Button Event Lag?
« Reply #4 on: May 27, 2013, 07:54:13 pm »
Ah, cool. Is there any downside to making it execute that way?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Button Event Lag?
« Reply #5 on: May 27, 2013, 08:26:26 pm »
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 :)

wubak

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Button Event Lag?
« Reply #6 on: May 27, 2013, 08:39:49 pm »
 :)