Pan.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. knife: cc.Prefab,
  5. knifeArr: {//飞刀Node存储队列
  6. default: []
  7. },
  8. knifeContainer: cc.Node,
  9. kIndex: 0
  10. },
  11. init () {
  12. },
  13. start () {
  14. this.getComponent(cc.Animation).play('rotatePan')
  15. // var repeatRotate = cc.repeatForever(cc.rotateBy(3, 360));
  16. // this.node.runAction(repeatRotate)
  17. },
  18. onCollisionEnter (other, self) {
  19. // console.log(other, self);
  20. if(other.tag == 777 && self.tag == 666) {
  21. this.kIndex += 1
  22. //addchild
  23. let rotation = self.node.rotation.toFixed(1)
  24. let knife = cc.instantiate(this.knife)
  25. this.knifeContainer.addChild(knife)
  26. // let h = rotation / 360;
  27. // h = h * 188;
  28. knife.setPosition(0, -188)
  29. knife.setRotation(-rotation)
  30. this.getComponent(cc.Animation).stop()
  31. console.log(rotation);
  32. }
  33. },
  34. onCollisionStay (other, self) {
  35. // console.log('on collision Stay');
  36. },
  37. onCollisionExit (other, self) {
  38. // console.log('on collision Exit');
  39. }
  40. // update (dt) {},
  41. });