• (转)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的方法。或者是其他脚本接口函数

  • 相关阅读:
    天网管理系统
    NSCTF web200
    程序逻辑问题
    Once More
    Guess Next Session
    上传绕过
    加了料的报错注入
    C++ GET UTF-8网页编码转换
    Android学习笔记函数
    C++ 模拟虚拟键盘按键表
  • 原文地址:https://www.cnblogs.com/dudu580231/p/4978751.html
Copyright © 2020-2023  润新知