dragonBonesManager.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. // foo: {
  14. // // ATTRIBUTES:
  15. // default: null, // The default value will be used only when the component attaching
  16. // // to a node for the first time
  17. // type: cc.SpriteFrame, // optional, default is typeof default
  18. // serializable: true, // optional, default is true
  19. // },
  20. // bar: {
  21. // get () {
  22. // return this._bar;
  23. // },
  24. // set (value) {
  25. // this._bar = value;
  26. // }
  27. // },
  28. },
  29. // LIFE-CYCLE CALLBACKS:
  30. // onLoad () {},
  31. start () {
  32. this.animationDisplay = this.getComponent(dragonBones.ArmatureDisplay);
  33. // this.animationDisplay.getAnimationNames()
  34. // var ArmatureName = this.animationDisplay.getArmatureNames()
  35. // Log.info("所有动画1",this.getArmatureNames(this.animationDisplay))
  36. //
  37. // var AnimationNames = this.getAnimationNames(this.animationDisplay,this.getArmatureNames(this.animationDisplay))
  38. //
  39. // Log.info("所有动画2",AnimationNames)
  40. // this.Play(this.animationDisplay,AnimationNames[0],function (type, listener, target) {
  41. // Log.info("播放完毕 type",type)
  42. // // Log.info("播放完毕 listener",listener)
  43. // // Log.info("播放完毕 target",target)
  44. // }.bind(this),1)
  45. },
  46. _init(){
  47. return this.getAnimationNames(this.animationDisplay,this.getArmatureNames(this.animationDisplay))
  48. },
  49. getAnimationNames(animationDisplay,name){
  50. return animationDisplay.getAnimationNames(name)
  51. },
  52. getArmatureNames(animationDisplay){
  53. return animationDisplay.getArmatureNames()
  54. },
  55. play( newAnimation, completeCallback, playTimes) { //动态加载龙骨
  56. this.animationDisplay.playAnimation(newAnimation, playTimes);
  57. // this.node.scale = new cc.Vec2(scaleX, 1);
  58. this.animationDisplay.addEventListener(dragonBones.EventObject.COMPLETE, completeCallback, this.animationDisplay);//.apply(this));
  59. },
  60. timeScale( timeScale) { //动态加载龙骨
  61. this.animationDisplay.timeScale = timeScale;
  62. },
  63. playNotEvent( newAnimation, completeCallback, playTimes) { //动态加载龙骨
  64. this.animationDisplay.playAnimation(newAnimation, playTimes);
  65. },
  66. removeEvent(completeCallback) { //动态加载龙骨
  67. this.animationDisplay.removeEventListener(dragonBones.EventObject.COMPLETE, completeCallback, this.animationDisplay);//.apply(this));
  68. },
  69. //帧回调
  70. frame(completeCallback) { //动态加载龙骨
  71. this.animationDisplay.addEventListener(dragonBones.EventObject.FRAME_EVENT, completeCallback, this.animationDisplay);//.apply(this));
  72. },
  73. // update (dt) {},
  74. });