Cocos2dx3.0 帧事件的使用

  • Post author:
  • Post category:其他



HelloWorld.cpp






init()函数


[cpp]


init()

{
//——————————————————————


  1. Armature *armature = Armature::create( “Hero”);

  2. armature->setPosition(ccp(visibleSize.width * 0.5, visibleSize.height * 0.3));

  3. armature->getAnimation()->playWithIndex(1);

  4. this->addChild(armature);



  5. armature->getBone(“head”)->getDisplayRenderNode()->setColor(Color3B::RED);





  6. armature->getAnimation()->setFrameEventCallFunc(this,frameEvent_selector(HelloWorld::onFrameEvent));




  7. armature->getAnimation()->play(“attack”);



  8. }



  9. void HelloWorld::onFrameEvent(Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex)

  10. {


  11. //





    evt.c_str() 系 帧事件的名称


  12. log(“—– %s, — %d





    %d” ,evt.c_str(),originFrameIndex,currentFrameIndex);

  13. }

http://blog.sina.com.cn/s/blog_6d193c030101hbya.html