MotionStreak

1. 创建

this._streak = cc.MotionStreak.create(2, 3, 32, cc.color.GREEN, s_streak);
        this.addChild(this._streak);
  var winSize = cc.director.getWinSize();
        // create the streak object and add it to the scene
        this._streak = cc.MotionStreak.create(3, 3, 64, cc.color.WHITE, s_streak);
        this.addChild(this._streak);
        this._streak.x = winSize.width / 2;
        this._streak.y = winSize.height / 2;


2. 加入action

 var colorAction = cc.RepeatForever.create(cc.Sequence.create(
            cc.TintTo.create(0.2, 255, 0, 0),
            cc.TintTo.create(0.2, 0, 255, 0),
            cc.TintTo.create(0.2, 0, 0, 255),
            cc.TintTo.create(0.2, 0, 255, 255),
            cc.TintTo.create(0.2, 255, 255, 0),
            cc.TintTo.create(0.2, 255, 0, 255),
            cc.TintTo.create(0.2, 255, 255, 255)));

        this._streak.runAction(colorAction);

3.更新

onUpdate:function (delta) {
	    var pos = this._target.convertToWorldSpace(cc.p(this._target.width/2, 0));
        this._streak.x = pos.x;
        this._streak.y = pos.y;
    },
 cc.eventManager.addListener({
            event: cc.EventListener.TOUCH_ALL_AT_ONCE,
            onTouchesMoved:function (touches, event) {
                if (touches.length == 0)
                    return;

                var touch = touches[0];
                var touchLocation = touch.getLocation();
                var streak = event.getCurrentTarget()._streak;
                streak.x = touchLocation.x;
                streak.y = touchLocation.y;
            }
        }, this);
 update:function (dt) {
        this._angle += 1.0;
        this._streak.x = this._center.x + Math.cos(this._angle / 180 * Math.PI) * this._radius;
        this._streak.y = this._center.y + Math.sin(this._angle / 180 * Math.PI) * this._radius;
    }



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值