zoukankan      html  css  js  c++  java
  • (转)cocos2d-x 每帧动画的播放设置一个监听函数的做法

     
     
     1  local cache = cc.AnimationCache:getInstance()
     2     cache:addAnimations("animations-2.plist")
     3     local animation = cache:getAnimation("dance_1")
     4     animation:setDelayPerUnit(0.25)
     5     animation:setRestoreOriginalFrame(true)
     6     local aniamte = cc.Animate:create(animation)
     7     sprite:runAction(cc.RepeatForever:create(aniamte))
     8 
     9      local listener  = cc.EventListenerCustom:create(cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION,
    10                      function (event, aa,bb,cc )
    11                         local name = event:getEventName()
    12                            print(name)
    13                      end
    14         )
    15      
    16     cc.Director:getInstance():getEventDispatcher():addEventListenerWithFixedPriority(listener, -1);
    17    

    PS:这是一种非常好的做法,当我们需要做每帧的播放做处理时,就能用到它,userdata获取的接口,没有提供,我们可以自己仿照getEventName那样, 写一个获取getUserData的方法。或者是其他脚本接口函数

  • 相关阅读:
    CUDA[2] Hello,World
    mysql操作
    virsh 连接虚拟机 (vnc 或 控制台)
    ssh访问流程
    使用ceph-deploy进行ceph安装
    openstack 的horizon的结构
    django 后台格式化数据库查询出的日期
    web 应用的部署
    工具
    python性能优化
  • 原文地址:https://www.cnblogs.com/dudu580231/p/4978751.html
Copyright © 2011-2022 走看看