Author Topic: Specifying tween that triggers event  (Read 6847 times)

ozRocker

  • Guest
Specifying tween that triggers event
« on: May 02, 2012, 12:50:17 PM »
I am using Tween Scale for buttons to grow into view when window opens and shrink out of view right before the window closes.  I'm using the "event receiver" and "call when finished" to trigger the window close after the last button shrinks.  The problem is the function also gets triggered with every other tween such as the ones placed on hover and click.  Is there a way to specify which tween should trigger the event?  Also, when I manually call the tween before the window closes using Play(false) it will play the last tween that was run (sometimes hover and sometimes click), when I want it to play the scale tween.  How do I specify which tween to Play when there are multiple?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Specifying tween that triggers event
« Reply #1 on: May 02, 2012, 12:57:54 PM »
Tweens have a group parameter. You can use it to separate them.

ozRocker

  • Guest
Re: Specifying tween that triggers event
« Reply #2 on: May 02, 2012, 09:12:30 PM »
I saw the group parameter but I'm not sure how to use it.  The only reference to group I can find is property "tweenGroup".  How do I use that to get a specific tween?

I know I can say "if <tween>.tweenGroup == 9", but the problem is when the triggered function is called there is no reference to the tween that called it. 
« Last Edit: May 02, 2012, 10:53:26 PM by ozRocker »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Specifying tween that triggers event
« Reply #3 on: May 03, 2012, 08:29:20 AM »
Sure there is. The tween is passed as the parameter.

ozRocker

  • Guest
Re: Specifying tween that triggers event
« Reply #4 on: May 03, 2012, 09:24:03 AM »
ok cool, the tween does indeed get passed.  However now I find that UIButtonScale will return the same tween group as TweenScale.  If I set tween group in TweenScale to 8, then I hover over the button which triggers UIButtonScale, my function gets triggered and when I check tween group it says 8.

Also, is there a way to Play a tween from a specific tween group or specific tweening script?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Specifying tween that triggers event
« Reply #5 on: May 03, 2012, 09:41:08 AM »
UIButtonTween is what specifies a tween group, and is designed to work with any pre-existing tween you've created that has a matching group. UIButtonScale has no such property.

Joe @ ByDesign Games

  • Guest
Re: Specifying tween that triggers event
« Reply #6 on: March 09, 2013, 03:33:33 PM »
Seeing a similar issue, not sure how to resolve it.

Basically have a UITexture, that has TweenScale, UIForwardEvents and UIButtonScale.

Want the UITexture to scale slightly when mouse hover (using UIButtonScale). Separately want the UITexture to scale up when clicked (using UIForwardEvents to pass a method that, among other things, ends up sending message of Play back on the UITexture.

Problem is whenever mouse hover, TweenScale values are updated by UIButtonScale. I wish to prevent this so that TweenScale values do not update on hover.

What _precisely_ should be done to enable the desired behavior here?

As is, feels like UIButtonScale is overriding TweenScale values, and it makes no sense to us why.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Specifying tween that triggers event
« Reply #7 on: March 10, 2013, 04:56:27 AM »
Because UIButtonScale uses or adds a tween scale.

In layman's terms you have two scripts modifying the same value.

You can achieve the behaviour you want by placing tweens on different game objects. For example:

Button
- Tween 1
-- Tween 2
--- Whatever else

Joe @ ByDesign Games

  • Guest
Re: Specifying tween that triggers event
« Reply #8 on: March 17, 2013, 03:59:57 AM »
What _precisely_ should be done to enable the desired behavior here?

Hi Mike,

We're still not seeing how this is supposed to work to have both Scale on Hover (UIButtonScale) & an arbitrary Tween Scale (e.g. for highlighting the button to the user, as in during a tutorial).

In our example, we have:

- UIButton with a UIButtonScale and a TweenScale (yes, this is the obvious conflict).
-- Button Background

To fix this, precisely where to put the UIButtonScale & where to put the TweenScale to achieve the desired result?

And if they are on children, as i think you suggested, how is the button root (UIButton) supposed to receive the tween info? Do we need to add a event forwarder or...? And an additional collider too?

Unlike UIButtonScale, TweenScale doesn't have a tweenTarget property. And of course UIButtonScale doesn't t have a Tween Group property.

So, it feels like it's all over the place / inconsistent.

Basically, can you be more specific please, using precise class names, etc.?

Thanks.
« Last Edit: March 17, 2013, 04:17:01 AM by Joe @ ByDesign Games »

Joe @ ByDesign Games

  • Guest
Re: Specifying tween that triggers event
« Reply #9 on: March 17, 2013, 04:31:23 AM »
Ok, think we have something that works:

- UIButton with a UIButtonScale and a TweenScale.
-- DummyTransform that the above UIButtonScale TweenTarget property references.
--- Button Background

Can you confirm this is most optimal? Feels very strange, but it seems to work.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Specifying tween that triggers event
« Reply #10 on: March 17, 2013, 09:19:04 AM »
That's fine.