Author Topic: How to deal with focus lost when playing tween?  (Read 1923 times)

Zux

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
How to deal with focus lost when playing tween?
« on: August 26, 2014, 06:42:13 AM »
I am testing my demo built under windows, and I found when tweens playing, if I switch to windows, then return back, the tweens onfinish event will be passed, that makes the whole game error.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to deal with focus lost when playing tween?
« Reply #1 on: August 27, 2014, 03:49:51 AM »
Tween OnFinish event will be triggered when the tween finishes playing. What's the error?

Zux

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: How to deal with focus lost when playing tween?
« Reply #2 on: August 27, 2014, 07:34:10 AM »
Tween OnFinish event will be triggered when the tween finishes playing. What's the error?
It won't be triggered when you are not focused on the game window.  The game thread seems to be stopped when focus is lost to other window. It looks like the tweens are also stopped, but I don't know whether it is realy stopped or just the graphic drawing stopped, however, when focus return, the tween is complete but no onFinish process responded.
It's under PC platform, I haven't tried on mobile device yet.

Zux

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: How to deal with focus lost when playing tween?
« Reply #3 on: August 27, 2014, 07:57:36 AM »
Oh, I retested my demo directly in unity3d, and now I guess this is the same problem for UIPlayTween component as I mentioned in last problem
http://www.tasharen.com/forum/index.php?topic=10851.0
In my demo, the first UIPlayTween component acts normally when user act and start first tween group, it responded to onfinished event when lost focus. But the second UIPlayTween component will lost event respond when user switched to other window. I set  duration of tweens to 2s and add debug log to confirm where logic breaked.
It seems this problem is realy a bad logic breaker in my ways.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to deal with focus lost when playing tween?
« Reply #4 on: August 28, 2014, 08:24:40 PM »
It's a little hard for me to understand the issue from your description. Can you create a repro case for me to look at? You can PM me the download link here.