IrrAddCallbackAnimator

section index

## NAME

IrrAddCallbackAnimator - add a callback animator to a node

## SYNOPSIS

*animator.l = IrrAddCallbackAnimator(*irr_node.l, *callback.l, *userdata.l)

## INPUTS

*irr_node.l | - | refers to a node you have added to the scene.
*userdata.l | - | refers to a Userdefined Data, to store with this Animator.

## FUNCTION

The Callback-Animator gives you a very powerfull, and also very flexible point to change move or animate a node. This Animator-Callback is called befor the Node is drawn. So you can change e.g. the Size or position. But keep in Mind, that this Animator is called very often. So make sure to put no timexpensive calculation in the callback.

## EXAMPLE

       ;; Here is a simple Structure to keep some Userdatas for the Node
       Structure CBDataStruct
           name.s
       EndStructure

       ; Here is the Callback-Function. Please make sure, that you allways
       ; get Two parameters. The First is the most important. It is that SceneNode where
       ; you attached the CallBack-Animator. The Second Parameter is usefull to keep some
       ; Information with the Animator/SceneNode.

       ProcedureC.l AnimatorCallback(*scene_node.l, *userdata.CBDataStruct)
           ; here we get the actual Rotation of that node.
           IrrGetNodeRotation(*scene_node,@x.f,@y.f,@z.f)
           y+0.2        ; We let it rotate against the Y-Axis.
           If y >= 360  ;Okay, more the 360 degrees are not possible....
               y=0
           EndIf

           ;And now we set the new Rotation for that Node
           IrrSetNodeRotation(*scene_node,x,y,z)

           ;For example, we Debug out the Name of that Node
           Debug("Userdata="+*userdata\name)

           ;We Also can Debug out the Name of the Node !
           Debug("Animator-Callback from " + PeekS(IrrGetNodeName(*scene_node)))

           ;We should try to return allways #True. If you return #False, the
           ;Animator will destroyed.
           ProcedureReturn #True;
       EndProcedure

       ;define the Userdata
       mydata.CBDataStruct

       ;set a Value to my Userdata
       mydata\name = "Hi, i'm a Callback !"

       ;Attach a Callback animator to a node
       *animator.l = IrrAddCallbackAnimator(*node, @AnimatorCallback(), @

## RESULT

pointer to a Irrlicht-Animator.