Author Topic: Calling a method after tweening throgh script  (Read 2959 times)

dendenny01

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 4
    • View Profile
Calling a method after tweening throgh script
« on: January 17, 2015, 12:37:30 AM »
I trying to create a Transition Effect Like a seen in Slide show
where I have 3 Slides to be Precise Sprites(slide)
There is  a method on slide 2 that i want to call when Slide 1 finishes it Tweening
Calling a method By adding it to onFinish in the inspector of slide 1 is not give the correct transition that i want to achieve
Is there any way to do the same through scripting Like adding the method through Event Delegate...?
this is the sample snippet that i am using but could not find out what is going wrong

  1. private bool isReversedFinished = false;
  2. private bool death = false;
  3. public TweenPosition overlayScreen;
  4. public TweenPosition LevelStats;
  5.  
  6. void update(){
  7.    if (contact.normal.y < 0.9f){
  8.         death = true;
  9.         deathImminant();
  10.    }
  11. }
  12.  
  13. void  deathImminant(){
  14.   Overlay.delay = 3f;
  15.   EventDelegate.Set(Overlay.onFinished, TweenStats);
  16.   Overlay.PlayReverse();  
  17. }
  18.  
  19. public void TweenStats(){
  20.         LevelStats.Play();
  21. }
  22.  
« Last Edit: January 17, 2015, 01:12:32 AM by dendenny01 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Calling a method after tweening throgh script
« Reply #1 on: January 18, 2015, 04:25:37 AM »
First Play, then set a delay and onFinished callback. I don't quite understand the last part of your question. Is there any way to do what through scripting? You're already setting a delegate through a script. If you want to append instead of setting, use EventDelegate.Add.

dendenny01

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Calling a method after tweening throgh script
« Reply #2 on: January 18, 2015, 05:22:06 AM »
Thanks a Lot...!!!It finally worked
And sorry for the last part. Actually wanted to know is there a better a way to the code running
But i think for now its working fine
Once again thank you.. (:D)