Rolldice.js 910 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //const dragonBones = require('dragonBones');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. dice: [cc.Node]
  6. },
  7. // LIFE-CYCLE CALLBACKS:
  8. onLoad () {
  9. },
  10. start () {
  11. },
  12. update (dt) {
  13. },
  14. rollDice(dice) {
  15. for (let i = 0; i < this.dice.length; i++) {
  16. let diceNode = this.dice[i];
  17. let spine = diceNode.getComponent(dragonBones.ArmatureDisplay);
  18. let randomNumber = dice[i];
  19. spine.animationName = "newAnimation"
  20. let animationName = "dice" + randomNumber;
  21. spine.armatureName = animationName;
  22. spine.timeScale = Math.floor(Math.random() * 2) + 1 ;
  23. spine.playTimes = 1;
  24. console.log(spine.armatureName)
  25. }
  26. }
  27. });