cocosCreate 黄金矿工绳索摆动,以及钩子的扔出和回收

    xiaoxiao2023-03-16  6

    this.startPos = this.rope.position; //记录起始位置 //绳子摇摆动作 this.shakeAction = cc.repeatForever(cc.sequence(cc.rotateTo(3,60),cc.rotateTo(3,-60))); // 回收钩子 //绳子收回动作,绳子收回后执行摇摆动作 this.returnAction = cc.sequence(cc.moveTo(3,this.startPos),cc.callFunc(function() { self.rope.getComponent(cc.Animation).resume('shake'); // 继续摇摆 }, this)); //绳子左右摇摆 this.rope.runAction(this.shakeAction); var self = this; this.node.on('touchstart',function(){ self.rope.getComponent(cc.Animation).pause('shake'); // 将摆动暂停 self.rope.stopAllActions(); //绳子伸长动作,根据角度动态计算 // var move1 = cc.moveBy(3,cc.p(-200*Math.tan(Math.PI/180*this.rope.rotation),-200)) // self.rope.runAction(cc.sequence(move1, cc.callFunc(this._callFun, this))); self.rope.runAction(cc.moveBy(2,-300*Math.tan(Math.PI/180*this.rope.rotation),-300)); //钩子扔出 },this); this.node.on('touchend',function(){ self.rope.runAction(self.returnAction); },this);
    转载请注明原文地址: https://ju.6miu.com/read-1152713.html
    最新回复(0)