var jian = new cc.Sprite("#images/gongjianshou/jian.png");
jian.attr({
x: this.x,
y: this.y + 100,
scaleY: this.scaleY,
scaleX: -Math.abs(this.scaleX)
});
jian.setName('jian');
this.parent.addChild(jian, 30);
//抛物线飞行
var sx = jian.x; //开始位置x
var sy = jian.y; //开始位置y
var ex = target.x + 40; //结束位置x
var ey = target.y + 150; //结束位置y
var startA = this.scaleX > 0 ? 130 : 40; //起始角度
var endA = this.scaleX > 0 ? 220 : -40; //终止角度
var dirTime = 1; //起始位置到中止位置的所需时间
//设置精灵的起始角度
jian.setRotation(startA);
var bezier = [
cc.p(sx, sy),
cc.p(sx + (ex - sx) * 0.5, sy + (ey - sy) * 0.5 + 500),
cc.p(ex, ey)
];
//移动
var actionMove = new cc.BezierTo(dirTime, bezier);
//旋转角度
var actionRotate = new cc.RotateTo(dirTime, endA);
//合并动作
var actions = new cc.Spawn([actionMove, actionRotate]);
var seq = cc.sequence(actions,
cc.callFunc(function () {
jian.removeFromParent();
})
);
jian.runAction(seq);