AdamRedwoods Animation Tween Module

Monkey Forums/Monkey Code/AdamRedwoods Animation Tween Module

AdamRedwoods(Posted 2011) [#1]
Here's a tween module for people to use. It's robust, but requires some setup on the programmers part. I didn't make an elegant class package (for various reasons), but it's not hard to do.

Features:
- layerable to create custom effects
- reversable, hold on last state
- written with performance in mind
- Added SetAlphaINOUT(handle, step, duration in ms ) for easy fadein/out of images

Todo:
- color tweens
- wrap another class around this to make tweens automatic

Usage:
- tweens are in format Command(unique handle, step, start, end, starty, endy)
- layer tweens in order: Translate, Scale, Rotate
- default setting is EaseOut, optional EaseIn available
- you need to make global handles for each tween (a simple process), it's nice to keep them in a class as a global

Example:
''Do this however you want, but you need to provide unique integers per tween set
Class Tweennum
	Global tweenForImage1:int = 1
	Global othertween:int = 2
End

'' (in Main Routine)
''create a trigger and begin the tween

If someTrigger
	Tween.Begin(Tweennum.tweenForImage1)
	Tween.EaseIn(Tweennum.tweenForImage1)
	someTrigger =0
EndIf

If Tween.IsActive(Tweennum.tweenForImage1)
	''if you need x,y position set that before rotation
	Translate(x,y)

	Tween.Rotate(Tweennum.tweenForImage1, 0.1, 0, 360)
	
	''will fade in as well
	Tween.SetAlpha(Tweennum.tweenForImage1, 0.1, 0.0, 1.0)
	
	DrawImage image1,0,0
	
	''restore will wipe out any previous matrix commands, colors, and alphas, and return to normal drawing operations
	Tween.Restore()
	
	''to chain tweens, add another trigger:
	If Not Tween.IsActive(Tweennum.tweenForImage1)
		Tween.Begin(Tweennum.othertween)
	endif

Else
	''hold image when finished use this:
	Translate(x,y)
	UseFinalState(Tweennum.tweenForImage1)
	DrawImage image1,0,0
	Tween.Restore()

EndIf






Martian Watts(Posted 2012) [#2]
It's really helpfull! I will to use it..