skn3 Tween demo - missing function?

Monkey Forums/Monkey Programming/skn3 Tween demo - missing function?

Supertino(Posted 2014) [#1]
Hey

I have been using skn3's Tween code in my games for a while but I noticed an issue today when I wanted to pause and resume a tween, it looks like that functionality was never fully implemented, there is a commented line in the Resume Method about updating the start timer but no actual code.

I wanted to scroll a screen using a tween and pause\resume if the screen was touched so I used tween.stop and tween.resume but noticed that it doesn't actual stop the tween timers updating so when it resumes it's whizzed forward or even finished. I assume there needs to be some code within the Resume Method to recover or offset the timer(s).

The code in question is bundled with Monkey Sample docs "Jonathan Pittock" Tween demo.

You can add these two lines to the Update method of the tweendemo.monkey to get a better understanding;
If KeyHit(KEY_S) tween.Stop() 'Pause game
If KeyHit(KEY_C) tween.Resume() ' Resume game

Imagine you have a pause button that pauses your game, the desired behavior is that the oval stops and resumes from the same spot to finish the movement when un-paused.

I have spent about an hour fudging about but I cannot quite get it to work. If any one is a little bored and wants to take a look i'd appreciate it.


Sammy(Posted 2014) [#2]
There is a pausable Millisecs() compatible routine in the Monkey Code forum that may help :-

http://www.monkey-x.com/Community/posts.php?topic=5830

Just substitute this for the Mojo.Millisecs() one SKN3 is using and then stop and start it with your own pause methods.

I have not test this though but I dont see a reason it would not work.


Skn3(Posted 2014) [#3]
Does this help?

tween.monkey


tweendemo.monkey



Supertino(Posted 2014) [#4]
Thanks Skn3 those additions work a treat. I actually went ahead and created my own but I lacked the fancy equations and easing etc. but now I'll switch back to yours =D

@Sammy thanks for the info on that millisecs() routine, I am sure I can make use of that.

My simple linear tween class in case anyone is interested (pssssst! use Skn3 code)


Basic usage;
Global myTween:SimpleTween = New SimpleTween(0,200,2000) ' 2 second tween
myTween.Start ' call once to start Tween
myTween.Update ' call somewhere in OnUpdate
DrawOval myTween.Value,200,32 ' call somewhere in OnRender