cc.Class({ extends: cc.Component, properties: { knife: cc.Prefab, knifeArr: {//飞刀Node存储队列 default: [] }, knifeContainer: cc.Node, kIndex: 0 }, init () { }, start () { this.getComponent(cc.Animation).play('rotatePan') // var repeatRotate = cc.repeatForever(cc.rotateBy(3, 360)); // this.node.runAction(repeatRotate) }, onCollisionEnter (other, self) { // console.log(other, self); if(other.tag == 777 && self.tag == 666) { this.kIndex += 1 //addchild let rotation = self.node.rotation.toFixed(1) let knife = cc.instantiate(this.knife) this.knifeContainer.addChild(knife) // let h = rotation / 360; // h = h * 188; knife.setPosition(0, -188) knife.setRotation(-rotation) this.getComponent(cc.Animation).stop() console.log(rotation); } }, onCollisionStay (other, self) { // console.log('on collision Stay'); }, onCollisionExit (other, self) { // console.log('on collision Exit'); } // update (dt) {}, });