ZEVS.animation: | Functions | Types | Modinfo | Source |
If you animate local variables, please make SURE (!), that the animations will not be updated, when the variable is unallocated. There are three ways to do this (see UpdateAnimations).
First, you can call CancelAnimation at the end of the function. Secound, you can use Types and save the animation as a Field and call CancelAnimation within Delete-Method. Third, you can use Types and save the Object, which's Field is animated, as Data-Field of the animation-Object.
It is not possible to say, what happens, if the program "updates" invalid pointers. Although the code is GPL, I say again: NO WARRANTY FOR ANYTHING.
I hope, you understood it now.
AnimateByte | animates a byte pointer. |
AnimateByteByStep | animates a byte pointer. |
AnimateDouble | animates a double pointer. |
AnimateDoubleByStep | animates a double pointer. |
AnimateFloat | animates a float pointer. |
AnimateFloatByStep | animates a double pointer. |
AnimateInt | animates an int pointer. |
AnimateIntByStep | animates an int pointer. |
AnimateLong | animates a long pointer. |
AnimateLongByStep | animates a long pointer. |
AnimateShort | animates a short pointer. |
AnimateShortByStep | animates a short pointer. |
ByteAnimationTrigger | Creates a trigger for Byte animations. |
CancelAnimation | cancels the animation. |
ClearAnimations | clears all animations. |
DoubleAnimationTrigger | Creates a trigger for Double animations. |
EndAnimation | ends the animation. |
FloatAnimationTrigger | Creates a trigger for Float animations. |
IntAnimationTrigger | Creates a trigger for Int animations. |
LongAnimationTrigger | Creates a trigger for Long animations. |
PauseAnimation | pauses the animation. |
ResumeAnimation | resumes the animation. |
SetAnimationStep | sets an animation-step. |
SetAnimationTrigger | Sets a trigger for animation completition. |
SetAnimationVoidTrigger | Sets a void trigger for animation completition. |
ShortAnimationTrigger | Creates a trigger for Short animations. |
UpdateAnimations | updates all animations. |
TAnimation | The animation-type. |
TAnimationTrigger | The Type storing animation triggers. |
Function AnimateByte:TAnimation(value:Byte Ptr, aim:Byte, time%, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a byte pointer. |
Information | The first argument (value) is a byte-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the time (in ms), until the animation reaches the aim. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Byte = 0 AnimatByte Varptr x, 200, 1000 Repeat Cls UpdateAnimations DrawRect x*3%, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) |
Function AnimateByteByStep:TAnimation(value:Byte Ptr, aim:Byte, stp:Byte, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a byte pointer. |
Information | The first argument (value) is a byte-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the step, how much the value will change in one ms. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer to become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Byte = 0 AnimateByteByStep Varptr x, 200, 1 Repeat Cls UpdateAnimations DrawRect x*3%, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) |
Function AnimateDouble:TAnimation(value:Double Ptr, aim:Double, time%, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a double pointer. |
Information | The first argument (value) is a double-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the time (in ms), until the animation reaches the aim. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global sx:Double = 1 AnimateDouble Varptr sx, 20, 1000 Repeat Cls UpdateAnimations SetScale sx, 1 SetHandle TextWidth("wow")/2, TextHeight("wow")/2 DrawText "wow", 400, 300 Flip Until KeyHit(KEY_ESCAPE) |
Function AnimateDoubleByStep:TAnimation(value:Double Ptr, aim:Double, stp:Double, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a double pointer. |
Information | The first argument (value) is a double-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the step, how much the value will change in one ms. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer to become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global sx:Double = 1 AnimateDoubleByStep Varptr sx, 20, .1 Repeat Cls UpdateAnimations SetScale sx, 1 SetHandle TextWidth("wow")/2, TextHeight("wow")/2 DrawText "wow", 400, 300 Flip Until KeyHit(KEY_ESCAPE) |
Function AnimateFloat:TAnimation(value:Float Ptr, aim:Float, time%, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a float pointer. |
Information | The first argument (value) is a float-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the time (in ms), until the animation reaches the aim. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global sx:Float = 1 AnimateFloat Varptr sx, 20, 1000 Repeat Cls UpdateAnimations SetScale sx, 1 SetHandle TextWidth("wow")/2, TextHeight("wow")/2 DrawText "wow", 400, 300 Flip Until KeyHit(KEY_ESCAPE) |
Function AnimateFloatByStep:TAnimation(value:Float Ptr, aim:Float, stp:Float, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a double pointer. |
Information | The first argument (value) is a double-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the step, how much the value will change in one ms. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer to become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global sx:Float = 1 AnimateFloatByStep Varptr sx, 20, .1 Repeat Cls UpdateAnimations SetScale sx, 1 SetHandle TextWidth("wow")/2, TextHeight("wow")/2 DrawText "wow", 400, 300 Flip Until KeyHit(KEY_ESCAPE) |
Function AnimateInt:TAnimation(value:Int Ptr, aim:Int, time%, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates an int pointer. |
Information | The first argument (value) is an int-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the time (in ms), until the animation reaches the aim. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global x% = 0 AnimateInt Varptr x, 700, 1000 Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) |
Function AnimateIntByStep:TAnimation(value:Int Ptr, aim:Int, stp:Int, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates an int pointer. |
Information | The first argument (value) is an int-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the step, how much the value will change in one ms. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer to become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Int = 0 AnimateIntByStep Varptr x, 700, 1 Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) |
Function AnimateLong:TAnimation(value:Long Ptr, aim:Long, time%, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a long pointer. |
Information | The first argument (value) is a long-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the time (in ms), until the animation reaches the aim. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer become invalid. NOTE: You cannot animate in the whole long-space. That's why animation-steps are performed as doubles, which have not the same space. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Long = 0 AnimateLong Varptr x, 700, 1000 Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) Rem doesn't work: x = 1234567891011 ' > max. Double AnimateLong x, 0, 1000 'will do ANYthing End Rem |
Function AnimateLongByStep:TAnimation(value:Long Ptr, aim:Long, stp:Long, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a long pointer. |
Information | The first argument (value) is a long-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the step, how much the value will change in one ms. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer to become invalid. NOTE: You cannot animate in the whole long-space. That's why animation-steps are performed as doubles, which have not the same space. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Long = 0 AnimateLongByStep Varptr x, 700, 1 Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) Rem doesn't work: x = 1234567891011 ' > max. Double AnimateLongByStep x, 0, 100 'will do ANYthing End Rem |
Function AnimateShort:TAnimation(value:Short Ptr, aim:Short, time%, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a short pointer. |
Information | The first argument (value) is a short-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the time (in ms), until the animation reaches the aim. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Short = 0 AnimateShort Varptr x, 700, 1000 Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) |
Function AnimateShortByStep:TAnimation(value:Short Ptr, aim:Short, stp:Short, data:Object = Null) | |
Returns | The animation-Object. |
Description | animates a short pointer. |
Information | The first argument (value) is a short-pointer (See VarPtr). The secound argument is the animation's aim. The third argument is the step, how much the value will change in one ms. The fourth argument is optional. It can be an object, associated with the animation to avoid the value be unset and the pointer to become invalid. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Short = 0 AnimateShortByStep Varptr x, 700, 1 Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) |
Function ByteAnimationTrigger:TAnimationTrigger(trigger(value:Byte Ptr)) | |
Returns | The created trigger. |
Description | Creates a trigger for Byte animations. |
Information | Combine this Function with SetAnimationTrigger. The Function will be called with the animated pointer. Use SetAnimationVoidTrigger, If you want no arguments. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Byte, animation:TAnimation goToEnd Varptr x Repeat UpdateAnimations Cls DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) End Function goToEnd(pointer:Byte Ptr) animation = AnimateByte(pointer, 700, 1000) SetAnimationTrigger animation, ByteAnimationTrigger(goToStart) End Function Function goToStart(pointer:Byte Ptr) animation = AnimateByte(pointer, 0, 1000) SetAnimationTrigger animation, ByteAnimationTrigger(goToEnd) End Function |
Function CancelAnimation(animation:TAnimation) | |
Returns | void. |
Description | cancels the animation. |
Information | Removes the animation from the update-list. The value will NOT be changed. |
Example | Import ZEVS.animation Graphics 800, 600 Global x% = 0 Local animation:TAnimation = AnimateInt(Varptr x, 700, 10000) Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 DrawText "Press [Space] to stop", 0, 210 If KeyHit(KEY_SPACE) Then CancelAnimation animation Flip Until KeyHit(KEY_ESCAPE) |
Function ClearAnimations() | |
Returns | void. |
Description | clears all animations. |
Information | Use this to remove all animations from the update-list. |
Example | Import ZEVS.animation Graphics 800, 600 Global x% = 0 AnimateInt Varptr x, 700, 10000 Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 DrawText "Press [Space] to stop", 0, 210 If KeyHit(KEY_SPACE) Then ClearAnimations Flip Until KeyHit(KEY_ESCAPE) |
Function DoubleAnimationTrigger:TAnimationTrigger(trigger(value:Double Ptr)) | |
Returns | The created trigger. |
Description | Creates a trigger for Double animations. |
Information | Combine this Function with SetAnimationTrigger. The Function will be called with the animated pointer. Use SetAnimationVoidTrigger, If you want no arguments. |
Example | Import ZEVS.animation Graphics 800, 600 Global sx:Double, animation:TAnimation goToEnd Varptr sx Repeat UpdateAnimations Cls SetScale sx, 1 SetHandle TextWidth("wow")/2, TextHeight("wow")/2 DrawText "wow", 400, 300 Flip Until KeyHit(KEY_ESCAPE) End Function goToEnd(pointer:Double Ptr) animation = AnimateDouble(pointer, 20, 1000) SetAnimationTrigger animation, DoubleAnimationTrigger(goToStart) End Function Function goToStart(pointer:Double Ptr) animation = AnimateDouble(pointer, 1, 1000) SetAnimationTrigger animation, DoubleAnimationTrigger(goToEnd) End Function |
Function EndAnimation(animation:TAnimation) | |
Returns | void. |
Description | ends the animation. |
Information | Sets the value to the aim and removes the animation from the update-list. |
Example | Import ZEVS.animation Graphics 800, 600 Global x% = 0 Local animation:TAnimation = AnimateInt(Varptr x, 700, 10000) Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 DrawText "Press [Space] to end", 0, 210 If KeyHit(KEY_SPACE) Then EndAnimation animation Flip Until KeyHit(KEY_ESCAPE) |
Function FloatAnimationTrigger:TAnimationTrigger(trigger(value:Float Ptr)) | |
Returns | The created trigger. |
Description | Creates a trigger for Float animations. |
Information | Combine this Function with SetAnimationTrigger. The Function will be called with the animated pointer. Use SetAnimationVoidTrigger, If you want no arguments. |
Example | Import ZEVS.animation Graphics 800, 600 Global sx:Float, animation:TAnimation goToEnd Varptr sx Repeat UpdateAnimations Cls SetScale sx, 1 SetHandle TextWidth("wow")/2, TextHeight("wow")/2 DrawText "wow", 400, 300 Flip Until KeyHit(KEY_ESCAPE) End Function goToEnd(pointer:Float Ptr) animation = AnimateFloat(pointer, 20, 1000) SetAnimationTrigger animation, FloatAnimationTrigger(goToStart) End Function Function goToStart(pointer:Float Ptr) animation = AnimateFloat(pointer, 1, 1000) SetAnimationTrigger animation, FloatAnimationTrigger(goToEnd) End Function |
Function IntAnimationTrigger:TAnimationTrigger(trigger(value:Int Ptr)) | |
Returns | The created trigger. |
Description | Creates a trigger for Int animations. |
Information | Combine this function with SetAnimationTrigger. The function will be called with the animated pointer. Use SetAnimationVoidTrigger, if you want no arguments. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Int, animation:TAnimation goToEnd Varptr x Repeat UpdateAnimations Cls DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) End Function goToEnd(pointer:Int Ptr) animation = AnimateInt(pointer, 700, 1000) SetAnimationTrigger animation, IntAnimationTrigger(goToStart) End Function Function goToStart(pointer:Int Ptr) animation = AnimateInt(pointer, 0, 1000) SetAnimationTrigger animation, IntAnimationTrigger(goToEnd) End Function |
Function LongAnimationTrigger:TAnimationTrigger(trigger(value:Long Ptr)) | |
Returns | The created trigger. |
Description | Creates a trigger for Long animations. |
Information | Combine this function with SetAnimationTrigger. The function will be called with the animated pointer. Use SetAnimationVoidTrigger, if you want no arguments. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Long, animation:TAnimation goToEnd Varptr x Repeat UpdateAnimations Cls DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) End Function goToEnd(pointer:Long Ptr) animation = AnimateLong(pointer, 700, 1000) SetAnimationTrigger animation, LongAnimationTrigger(goToStart) End Function Function goToStart(pointer:Long Ptr) animation = AnimateLong(pointer, 0, 1000) SetAnimationTrigger animation, LongAnimationTrigger(goToEnd) End Function |
Function PauseAnimation(animation:TAnimation) | |
Returns | void. |
Description | pauses the animation. |
Information | Removes the animation from the update-list. |
Example | Import ZEVS.animation Graphics 800, 600 Global x% = 0 Local animation:TAnimation = AnimateInt(Varptr x, 700, 10000) Local pause% = False Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 If pause Then DrawText "Press [P] to resume", 0, 210 If KeyHit(KEY_P) Then ResumeAnimation animation pause = False EndIf Else DrawText "Press [P] to pause", 0, 210 If KeyHit(KEY_P) Then PauseAnimation animation pause = True EndIf EndIf Flip Until KeyHit(KEY_ESCAPE) |
Function ResumeAnimation(animation:TAnimation) | |
Returns | void. |
Description | resumes the animation. |
Information | Re-adds the animation to the update-list. |
Example | Import ZEVS.animation Graphics 800, 600 Global x% = 0 Local animation:TAnimation = AnimateInt(Varptr x, 700, 10000) Local pause% = False Repeat Cls UpdateAnimations DrawRect x, 0, 100, 100 If pause Then DrawText "Press [P] to resume", 0, 210 If KeyHit(KEY_P) Then ResumeAnimation animation pause = False EndIf Else DrawText "Press [P] to pause", 0, 210 If KeyHit(KEY_P) Then PauseAnimation animation pause = True EndIf EndIf Flip Until KeyHit(KEY_ESCAPE) |
Function SetAnimationStep(animation:TAnimation, stp!) | |
Returns | void. |
Description | sets an animation-step. |
Information | Sets the value to the step associated with stp (Double between 1 and 0). 0 means, the value will be set to the start and 1 means, the value will be set to the end. It doesn't affect any updates - the next update will overwrite the step. To avoid updates, use PauseAnimation. |
Example | Import ZEVS.animation Graphics 800, 600 Global x% = 0 Local animation:TAnimation = AnimateInt(Varptr x, 700, 1000) Repeat Cls UpdateAnimations SetAnimationStep animation, .5 'undo every update DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) |
Function SetAnimationTrigger(animation:TAnimation, trigger:TAnimationTrigger) | |
Returns | void. |
Description | Sets a trigger for animation completition. |
Information | Sets a trigger, which will be called when the animation finishes. It will delete any trigger set before. If your function has no arguments, use SetAnimationVoidTrigger. The function will be called with the variable-pointer. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Int, animation:TAnimation goToEnd Varptr x Repeat UpdateAnimations Cls DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) End Function goToEnd(pointer:Int Ptr) animation = AnimateInt(pointer, 700, 1000) SetAnimationTrigger animation, IntAnimationTrigger(goToStart) End Function Function goToStart(pointer:Int Ptr) animation = AnimateInt(pointer, 0, 1000) SetAnimationTrigger animation, IntAnimationTrigger(goToEnd) End Function |
Function SetAnimationVoidTrigger(animation:TAnimation, trigger()) | |
Returns | void. |
Description | Sets a void trigger for animation completition. |
Information | Same to SetAnimationTrigger, but here is a function-pointer directly given. Use this, if your function expects no arguments. |
Example | Import ZEVS.animation Graphics 800, 600 Global x%, animation:TAnimation goToEnd Repeat UpdateAnimations Cls DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) End Function goToEnd() animation = AnimateInt(Varptr x, 700, 1000) SetAnimationVoidTrigger animation, goToStart End Function Function goToStart() animation = AnimateInt(Varptr x, 0, 1000) SetAnimationVoidTrigger animation, goToEnd End Function |
Function ShortAnimationTrigger:TAnimationTrigger(trigger(value:Short Ptr)) | |
Returns | The created trigger. |
Description | Creates a trigger for Short animations. |
Information | Combine this Function with SetAnimationTrigger. The Function will be called with the animated pointer. Use SetAnimationVoidTrigger, If you want no arguments. |
Example | Import ZEVS.animation Graphics 800, 600 Global x:Short, animation:TAnimation goToEnd Varptr x Repeat UpdateAnimations Cls DrawRect x, 0, 100, 100 Flip Until KeyHit(KEY_ESCAPE) End Function goToEnd(pointer:Short Ptr) animation = AnimateShort(pointer, 700, 1000) SetAnimationTrigger animation, ShortAnimationTrigger(goToStart) End Function Function goToStart(pointer:Short Ptr) animation = AnimateShort(pointer, 0, 1000) SetAnimationTrigger animation, ShortAnimationTrigger(goToEnd) End Function |
Function UpdateAnimations() | |
Returns | void. |
Description | updates all animations. |
Information | Updates all the animations of the update-list. |
Example | Import ZEVS.animation Function test1() Local x% Local animation:TAnimation = AnimateInt(Varptr x, 1000, 10000) CancelAnimation animation End Function Type myType Field x%, animation:TAnimation Method Delete() If Self.animation Then CancelAnimation Self.animation End Method End Type Function test2() Local x:myType = New myType Local animation:TAnimation = AnimateInt(Varptr x.x, 1000, 10000) x.animation = animation End Function Function test3() Local x:myType = New myType Local animation:TAnimation = AnimateInt(Varptr x.x, 1000, 10000, x) 'or animation.data = x End Function Function test4() Local x% Local animation:TAnimation = AnimateInt(Varptr x, 1000, 10000) End Function Print "test1:" test1 UpdateAnimations Print "OK" Print "test2:" test2 UpdateAnimations Print "OK" Print "test3:" test3 UpdateAnimations Print "OK" Input "Press [Return] if you really want to start test4 (shows what happens if an animation-pointer"+.. " becomes invalid)" Print "test4:" test4 UpdateAnimations 'Will "update" an unreserved part of RAM Print "END (see yourself, what happens - I hope nothing for you)" |
Type TAnimation | |
Description | The animation-type. |
Type TAnimationTrigger | |
Description | The Type storing animation triggers. |
Author | Felix Schremmer alias ZEVS@www.blitzforum.de |
---|---|
Copyright | Felix Schremmer 2011 |
Liscense | General Public Liscense (http://www.gnu.org/copyleft/gpl.html) |
Version | 1.0b |
Else | If you use this module, it would be nice to write it in your credits |