Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pilas/pytweener.py
blob: ff66a62c3b0b74cb613893c410320f2040f99921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
# pyTweener
#
# Tweening functions for python
#
# Heavily based on caurina Tweener: http://code.google.com/p/tweener/
#
# Released under M.I.T License - see above url
# Python version by Ben Harling 2009 
import math

class Tweener(object):
    def __init__(self, duration = 0.5, tween = None):
        """Tweener
        This class manages all active tweens, and provides a factory for
        creating and spawning tween motions."""
        self.currentTweens = []
        self.defaultTweenType = tween or Easing.Linear.easeNone
        self.defaultDuration = duration or 1.0
 
    def hasTweens(self):
        return len(self.currentTweens) > 0
 
    def addTweenNoArgs(self, obj, function, initial_value, value, **kwargs):
        "Similar a addTween, solo que se especifica la funcion y el valor de forma explicita."
        args = {function: value, 'initial_value': initial_value}

        if "tweenTime" in kwargs:
            t_time = kwargs.pop("tweenTime")
        else: t_time = self.defaultDuration
 
        if "tweenType" in kwargs:
            t_type = kwargs.pop("tweenType")
        else: t_type = self.defaultTweenType
 
        if "onCompleteFunction" in kwargs:
            t_completeFunc = kwargs.pop("onCompleteFunction")
        else: t_completeFunc = None
 
        if "onUpdateFunction" in kwargs:
            t_updateFunc = kwargs.pop("onUpdateFunction")
        else: t_updateFunc = None
 
        if "tweenDelay" in kwargs:
            t_delay = kwargs.pop("tweenDelay")
        else: t_delay = 0

        if kwargs:
            raise ValueError("No puede llamar a esta funcion con argumentos nombrados, use addTween en su lugar.")

        tw = Tween(obj, t_time, t_type, t_completeFunc, t_updateFunc, t_delay, **args)
        if tw:    
            self.currentTweens.append( tw )
        return tw

    def addTween(self, obj, **kwargs):
        """ addTween( object, **kwargs) -> tweenObject or False
 
            Example:
            tweener.addTween( myRocket, throttle=50, setThrust=400, tweenTime=5.0, tweenType=tweener.OUT_QUAD )
 
            You must first specify an object, and at least one property or function with a corresponding
            change value. The tween will throw an error if you specify an attribute the object does
            not possess. Also the data types of the change and the initial value of the tweened item
            must match. If you specify a 'set' -type function, the tweener will attempt to get the
            starting value by call the corresponding 'get' function on the object. If you specify a 
            property, the tweener will read the current state as the starting value. You add both 
            functions and property changes to the same tween.
 
            in addition to any properties you specify on the object, these keywords do additional
            setup of the tween.
 
            tweenTime = the duration of the motion
            tweenType = one of the predefined tweening equations or your own function
            onCompleteFunction = specify a function to call on completion of the tween
            onUpdateFunction = specify a function to call every time the tween updates
            tweenDelay = specify a delay before starting.
            """
        if "tweenTime" in kwargs:
            t_time = kwargs.pop("tweenTime")
        else: t_time = self.defaultDuration
 
        if "tweenType" in kwargs:
            t_type = kwargs.pop("tweenType")
        else: t_type = self.defaultTweenType
 
        if "onCompleteFunction" in kwargs:
            t_completeFunc = kwargs.pop("onCompleteFunction")
        else: t_completeFunc = None
 
        if "onUpdateFunction" in kwargs:
            t_updateFunc = kwargs.pop("onUpdateFunction")
        else: t_updateFunc = None
 
        if "tweenDelay" in kwargs:
            t_delay = kwargs.pop("tweenDelay")
        else: t_delay = 0
 
        tw = Tween( obj, t_time, t_type, t_completeFunc, t_updateFunc, t_delay, **kwargs )
        if tw:    
            self.currentTweens.append( tw )
        return tw
 
    def removeTween(self, tweenObj):
        if tweenObj in self.currentTweens:
            tweenObj.complete = True
            #self.currentTweens.remove( tweenObj )
 
    def getTweensAffectingObject(self, obj):
        """Get a list of all tweens acting on the specified object
        Useful for manipulating tweens on the fly"""
        tweens = []
        for t in self.currentTweens:
            if t.target is obj:
                tweens.append(t)
        return tweens
 
    def removeTweeningFrom(self, obj):
        """Stop tweening an object, without completing the motion
        or firing the completeFunction"""
        for t in self.currentTweens:
            if t.target is obj:
                t.complete = True
 
    def finish(self):
        #go to last frame for all tweens
        for t in self.currentTweens:
            t.update(t.duration)
        self.currentTweens = []
 
    def update(self, timeSinceLastFrame):
        removable = []
        for t in self.currentTweens:
            t.update(timeSinceLastFrame)

            if t.complete:
                removable.append(t)
                
        for t in removable:
            self.currentTweens.remove(t)
            
 
class Tween(object):
    def __init__(self, obj, tduration, tweenType, completeFunction, updateFunction, delay, **kwargs):
        """Tween object:
            Can be created directly, but much more easily using Tweener.addTween( ... )
            """
        #print obj, tduration, kwargs
        self.duration = tduration
        self.delay = delay
        self.target = obj
        self.tween = tweenType
        self.tweenables = kwargs
        self.delta = 0
        self.completeFunction = completeFunction
        self.updateFunction = updateFunction
        self.complete = False
        self.tProps = []
        self.tFuncs = []
        self.paused = self.delay > 0
        self.decodeArguments()
 
    def decodeArguments(self):
        """Internal setup procedure to create tweenables and work out
           how to deal with each"""
 
        if len(self.tweenables) == 0:
            # nothing to do 
            print "TWEEN ERROR: No Tweenable properties or functions defined"
            self.complete = True
            return

        assert(len(self.tweenables) == 2)

        initial_value = self.tweenables.pop('initial_value')


        for k, v in self.tweenables.items():
 
        # check that its compatible
            if not hasattr( self.target, k):
                print "TWEEN ERROR: " + str(self.target) + " has no function " + k
                self.complete = True
                break
 
            prop = func = False
            startVal = 0
            newVal = v
 
            try:
                startVal = self.target.__dict__[k]
                prop = k
                propName = k
 
            except:
                func = getattr( self.target, k)
                funcName = k
 
            if func:
                try:
                    getFunc = getattr(self.target, funcName.replace("set", "get") )
                    startVal = getFunc()
                    print getfunc
                except:
                    # no start value, assume its 0
                    # but make sure the start and change
                    # dataTypes match :)
                    startVal = newVal * 0

                startVal = initial_value
                tweenable = Tweenable( startVal, newVal - startVal)    
                newFunc = [ k, func, tweenable]
 
                #setattr(self, funcName, newFunc[2])
                self.tFuncs.append( newFunc )
 
 
            if prop:
                tweenable = Tweenable( startVal, newVal - startVal)    
                newProp = [ k, prop, tweenable]
                self.tProps.append( newProp )  
 
        """
        for k, v in self.tweenables.items():
 
        # check that its compatible
            if not hasattr( self.target, k):
                print "TWEEN ERROR: " + str(self.target) + " has no function " + k
                self.complete = True
                break
 
            prop = func = False
            startVal = 0
            newVal = v
 
            try:
                startVal = self.target.__dict__[k]
                prop = k
                propName = k
 
            except:
                func = getattr( self.target, k)
                funcName = k
 
            if func:
                try:
                    getFunc = getattr(self.target, funcName.replace("set", "get") )
                    startVal = getFunc()
                    print getfunc
                except:
                    # no start value, assume its 0
                    # but make sure the start and change
                    # dataTypes match :)
                    startVal = newVal * 0
                tweenable = Tweenable( startVal, newVal - startVal)    
                newFunc = [ k, func, tweenable]
 
                #setattr(self, funcName, newFunc[2])
                self.tFuncs.append( newFunc )
 
 
            if prop:
                tweenable = Tweenable( startVal, newVal - startVal)    
                newProp = [ k, prop, tweenable]
                self.tProps.append( newProp )  
        """ 

 
    def pause( self, numSeconds=-1 ):
        """Pause this tween
            do tween.pause( 2 ) to pause for a specific time
            or tween.pause() which pauses indefinitely."""
        self.paused = True
        self.delay = numSeconds
 
    def resume( self ):
        """Resume from pause"""
        if self.paused:
            self.paused=False
 
    def update(self, ptime):
        """Update this tween with the time since the last frame
            if there is an update function, it is always called
            whether the tween is running or paused"""
            
        if self.complete:
            return
        
        if self.paused:
            if self.delay > 0:
                self.delay = max( 0, self.delay - ptime )
                if self.delay == 0:
                    self.paused = False
                    self.delay = -1
                if self.updateFunction:
                    self.updateFunction()
            return
 
        self.delta = min(self.delta + ptime, self.duration)
 

        for propName, prop, tweenable in self.tProps:
            self.target.__dict__[prop] = self.tween( self.delta, tweenable.startValue, tweenable.change, self.duration )
        for funcName, func, tweenable in self.tFuncs:
            func( self.tween( self.delta, tweenable.startValue, tweenable.change, self.duration ) )
 
 
        if self.delta == self.duration:
            self.complete = True
            if self.completeFunction:
                self.completeFunction()
 
        if self.updateFunction:
            self.updateFunction()
 
 
 
    def getTweenable(self, name):
        """Return the tweenable values corresponding to the name of the original
        tweening function or property. 
 
        Allows the parameters of tweens to be changed at runtime. The parameters
        can even be tweened themselves!
 
        eg:
 
        # the rocket needs to escape!! - we're already moving, but must go faster!
        twn = tweener.getTweensAffectingObject( myRocket )[0]
        tweenable = twn.getTweenable( "thrusterPower" )
        tweener.addTween( tweenable, change=1000.0, tweenTime=0.4, tweenType=tweener.IN_QUAD )
 
        """
        ret = None
        for n, f, t in self.tFuncs:
            if n == name:
                ret = t
                return ret
        for n, p, t in self.tProps:
            if n == name:
                ret = t
                return ret
        return ret
 
    def Remove(self):
        """Disables and removes this tween
            without calling the complete function"""
        self.complete = True

 
class Tweenable:
    def __init__(self, start, change):
        """Tweenable:
            Holds values for anything that can be tweened
            these are normally only created by Tweens"""
        self.startValue = start
        self.change = change


"""Robert Penner's easing classes ported over from actionscript by Toms Baugis (at gmail com).
There certainly is room for improvement, but wanted to keep the readability to some extent.

================================================================================
 Easing Equations
 (c) 2003 Robert Penner, all rights reserved. 
 This work is subject to the terms in
 http://www.robertpenner.com/easing_terms_of_use.html.
================================================================================

TERMS OF USE - EASING EQUATIONS

Open source under the BSD License.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of the author nor the names of contributors may be used
      to endorse or promote products derived from this software without specific
      prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
class Easing:
    class Back:
        @staticmethod
        def easeIn(t, b, c, d, s = 1.70158):
            t = t / d
            return c * t**2 * ((s+1) * t - s) + b

        @staticmethod
        def easeOut (t, b, c, d, s = 1.70158):
            t = t / d - 1
            return c * (t**2 * ((s + 1) * t + s) + 1) + b

        @staticmethod
        def easeInOut (t, b, c, d, s = 1.70158):
            t = t / (d * 0.5)
            s = s * 1.525
            
            if t < 1:
                return c * 0.5 * (t**2 * ((s + 1) * t - s)) + b

            t = t - 2
            return c / 2 * (t**2 * ((s + 1) * t + s) + 2) + b

    class Bounce:
        @staticmethod
        def easeOut (t, b, c, d):
            t = t / d
            if t < 1 / 2.75:
                return c * (7.5625 * t**2) + b
            elif t < 2 / 2.75:
                t = t - 1.5 / 2.75
                return c * (7.5625 * t**2 + 0.75) + b
            elif t < 2.5 / 2.75:
                t = t - 2.25 / 2.75
                return c * (7.5625 * t**2 + .9375) + b
            else:
                t = t - 2.625 / 2.75
                return c * (7.5625 * t**2 + 0.984375) + b

        @staticmethod
        def easeIn (t, b, c, d):
            return c - Easing.Bounce.easeOut(d-t, 0, c, d) + b

        @staticmethod
        def easeInOut (t, b, c, d):
            if t < d * 0.5:
                return Easing.Bounce.easeIn (t * 2, 0, c, d) * .5 + b

            return Easing.Bounce.easeOut (t * 2 -d, 0, c, d) * .5 + c*.5 + b


        
    class Circ:
        @staticmethod
        def easeIn (t, b, c, d):
            t = t / d
            return -c * (math.sqrt(1 - t**2) - 1) + b

        @staticmethod
        def easeOut (t, b, c, d):
            t = t / d - 1
            return c * math.sqrt(1 - t**2) + b

        @staticmethod
        def easeInOut (t, b, c, d):
            t = t / (d * 0.5)
            if t < 1:
                return -c * 0.5 * (math.sqrt(1 - t**2) - 1) + b
            
            t = t - 2
            return c*0.5 * (math.sqrt(1 - t**2) + 1) + b


    class Cubic:
        @staticmethod
        def easeIn (t, b, c, d):
            t = t / d
            return c * t**3 + b

        @staticmethod
        def easeOut (t, b, c, d):
            t = t / d - 1
            return c * (t**3 + 1) + b

        @staticmethod
        def easeInOut (t, b, c, d):
            t = t / (d * 0.5)
            if t < 1:
                return c * 0.5 * t**3 + b
            
            t = t - 2
            return c * 0.5 * (t**3 + 2) + b


    class Elastic:
        @staticmethod
        def easeIn (t, b, c, d, a = 0, p = 0):
            if t==0: return b

            t = t / d            
            if t == 1: return b+c
            
            if not p: p = d * .3;

            if not a or a < abs(c):
                a = c
                s = p / 4
            else:
                s = p / (2 * math.pi) * math.asin(c / a)
            
            t = t - 1            
            return - (a * math.pow(2, 10 * t) * math.sin((t*d-s) * (2 * math.pi) / p)) + b


        @staticmethod
        def easeOut (t, b, c, d, a = 0, p = 0):
            if t == 0: return b
            
            t = t / d
            if (t == 1): return b + c
            
            if not p: p = d * .3;

            if not a or a < abs(c):
                a = c
                s = p / 4
            else:
                s = p / (2 * math.pi) * math.asin(c / a)
                
            return a * math.pow(2,-10 * t) * math.sin((t * d - s) * (2 * math.pi) / p) + c + b


        @staticmethod
        def easeInOut (t, b, c, d, a = 0, p = 0):
            if t == 0: return b
            
            t = t / (d * 0.5)
            if t == 2: return b + c
            
            if not p: p = d * (.3 * 1.5)

            if not a or a < abs(c):
                a = c
                s = p / 4
            else:
                s = p / (2 * math.pi) * math.asin(c / a)
                
            if (t < 1):
                t = t - 1
                return -.5 * (a * math.pow(2, 10 * t) * math.sin((t * d - s) * (2 * math.pi) / p)) + b
                
            t = t - 1
            return a * math.pow(2, -10 * t) * math.sin((t * d - s) * (2 * math.pi) / p) * .5 + c + b


    class Expo:
        @staticmethod
        def easeIn(t, b, c, d):
            if t == 0:
                return b
            else:
                return c * math.pow(2, 10 * (t / d - 1)) + b - c * 0.001

        @staticmethod
        def easeOut(t, b, c, d):
            if t == d:
                return b + c
            else:
                return c * (-math.pow(2, -10 * t / d) + 1) + b

        @staticmethod
        def easeInOut(t, b, c, d):
            if t==0:
                return b
            elif t==d:
                return b+c

            t = t / (d * 0.5)
            
            if t < 1:
                return c * 0.5 * math.pow(2, 10 * (t - 1)) + b
            
            return c * 0.5 * (-math.pow(2, -10 * (t - 1)) + 2) + b


    class Linear:
        @staticmethod
        def easeNone(t, b, c, d):
            return c * t / d + b

        @staticmethod
        def easeIn(t, b, c, d):
            return c * t / d + b

        @staticmethod
        def easeOut(t, b, c, d):
            return c * t / d + b

        @staticmethod
        def easeInOut(t, b, c, d):
            return c * t / d + b


    class Quad:
        @staticmethod
        def easeIn (t, b, c, d):
            t = t / d
            return c * t**2 + b

        @staticmethod
        def easeOut (t, b, c, d):
            t = t / d
            return -c * t * (t-2) + b

        @staticmethod
        def easeInOut (t, b, c, d):
            t = t / (d * 0.5)
            if t < 1:
                return c * 0.5 * t**2 + b
            
            t = t - 1
            return -c * 0.5 * (t * (t - 2) - 1) + b


    class Quart:
        @staticmethod
        def easeIn (t, b, c, d):
            t = t / d
            return c * t**4 + b

        @staticmethod
        def easeOut (t, b, c, d):
            t = t / d - 1
            return -c * (t**4 - 1) + b

        @staticmethod
        def easeInOut (t, b, c, d):
            t = t / (d * 0.5)
            if t < 1:
                return c * 0.5 * t**4 + b
            
            t = t - 2
            return -c * 0.5 * (t**4 - 2) + b

    
    class Quint:
        @staticmethod
        def easeIn (t, b, c, d):
            t = t / d
            return c * t**5 + b

        @staticmethod
        def easeOut (t, b, c, d):
            t = t / d - 1
            return c * (t**5 + 1) + b

        @staticmethod
        def easeInOut (t, b, c, d):
            t = t / (d * 0.5)
            if t < 1:
                return c * 0.5 * t**5 + b
            
            t = t - 2
            return c * 0.5 * (t**5 + 2) + b

    class Sine:
        @staticmethod
        def easeIn (t, b, c, d):
            return -c * math.cos(t / d * (math.pi / 2)) + c + b

        @staticmethod
        def easeOut (t, b, c, d):
            return c * math.sin(t / d * (math.pi / 2)) + b

        @staticmethod
        def easeInOut (t, b, c, d):
            return -c * 0.5 * (math.cos(math.pi * t / d) - 1) + b


    class Strong:
        @staticmethod
        def easeIn(t, b, c, d):
            return c * (t/d)**5 + b

        @staticmethod
        def easeOut(t, b, c, d):
            return c * ((t / d - 1)**5 + 1) + b

        @staticmethod
        def easeInOut(t, b, c, d):
            t = t / (d * 0.5)
            
            if t < 1:
                return c * 0.5 * t**5 + b
            
            t = t - 2
            return c * 0.5 * (t**5 + 2) + b



class TweenTestObject:
    def __init__(self):
        self.pos = 20
        self.rot = 50
 
    def update(self):
        print self.pos, self.rot
 
    def setRotation(self, rot):
        self.rot = rot
 
    def getRotation(self):
        return self.rot
 
    def complete(self):
        print "I'm done tweening now mommy!"
 
 
if __name__=="__main__":
    import time
    T = Tweener()
    tst = TweenTestObject()
    mt = T.addTween( tst, setRotation=500.0, tweenTime=2.5, tweenType=T.OUT_QUAD, 
                      pos=-200, tweenDelay=0.4, onCompleteFunction=tst.complete, 
                      onUpdateFunction=tst.update )
    s = time.clock()
    changed = False
    while T.hasTweens():
        tm = time.clock()
        d = tm - s
        s = tm
        T.update( d )
        if mt.delta > 1.0 and not changed:
 
            tweenable = mt.getTweenable( "setRotation" )
 
            T.addTween( tweenable, change=-1000, tweenTime=0.7 )
            T.addTween( mt, duration=-0.2, tweenTime=0.2 )
            changed = True
        #print mt.duration,
        print tst.getRotation(), tst.pos
        time.sleep(0.06)
    print tst.getRotation(), tst.pos