您的位置:首页 > 移动开发 > Cocos引擎

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

2016-09-19 19:18 323 查看
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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: