当前位置: 首页>>代码示例>>C++>>正文


C++ Animation::Tell方法代码示例

本文整理汇总了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;
}
开发者ID:untgames,项目名称:funner,代码行数:58,代码来源:animation2.cpp

示例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;
  }
}
开发者ID:untgames,项目名称:funner,代码行数:13,代码来源:animation2.cpp


注:本文中的Animation::Tell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。