本文整理汇总了C++中Animation::Tell方法的典型用法代码示例。如果您正苦于以下问题:C++ Animation::Tell方法的具体用法?C++ Animation::Tell怎么用?C++ Animation::Tell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Animation
的用法示例。
在下文中一共展示了Animation::Tell方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ()
{
printf ("Results of animation2_test:\n");
try
{
AnimationManager manager;
manager.LoadResource ("data/test.xanim");
Node::Pointer node = Node::Create (), target1 = Node::Create (), target2 = Node::Create ();
target1->SetName ("target1");
target2->SetName ("target2");
target1->BindToParent (*node);
target2->BindToParent (*node);
Animation animation = manager.PlayAnimation ("animation1", *node, &event_handler);
animation.RegisterEventHandler (AnimationEvent_OnPlay, &event_handler);
animation.RegisterEventHandler (AnimationEvent_OnPause, &event_handler);
animation.RegisterEventHandler (AnimationEvent_OnStop, &event_handler);
animation.RegisterEventHandler (AnimationEvent_OnUpdate, &event_handler);
animation.RegisterEventHandler (AnimationEvent_OnDestroy, &event_handler);
printf ("animation duration: %.2f\n", animation.Duration ());
node->Update (TimeValue (2, 1));
node->Update (TimeValue (3, 1));
animation.Pause ();
animation.Pause ();
node->Update (TimeValue (4, 1));
printf ("animation offset %.2f\n", animation.Tell ());
animation.Play ();
animation.Play ();
node->Update (TimeValue (5, 1));
printf ("animation offset %.2f\n", animation.Tell ());
animation.Stop ();
node->Update (TimeValue (6, 1));
printf ("animation offset %.2f\n", animation.Tell ());
}
catch (std::exception& e)
{
printf ("%s\n", e.what ());
}
return 0;
}
示例2: event_handler
void event_handler (AnimationEvent event, Animation& animation)
{
switch (event)
{
case AnimationEvent_OnPlay: printf ("play animation '%s'\n", animation.Name ()); break;
case AnimationEvent_OnStop: printf ("stop animation '%s'\n", animation.Name ()); break;
case AnimationEvent_OnPause: printf ("pause animation '%s'\n", animation.Name ()); break;
case AnimationEvent_OnFinish: printf ("finish animation '%s'\n", animation.Name ()); break;
case AnimationEvent_OnUpdate: printf ("update animation '%s' (offset=%.2f)\n", animation.Name (), animation.Tell ()); break;
case AnimationEvent_OnDestroy: printf ("destroy animation '%s'\n", animation.Name ()); break;
default: break;
}
}