在涉及角度的地方实施宽松政策,如何实施?

时间:2016-09-23 10:42:43

标签: javascript html5 easing

我正在尝试添加一些' juice'我正在使用Javascript进行的游戏。我查找了一些缓动函数并按以下方式应用它们。

//this.x += (this.speed * this.game.clockTick) * Math.sin(this.angle);
        //this.y += (this.speed * this.game.clockTick) * Math.cos(this.angle);

        this.x = Easing.easeInCubic(this.time, this.startX, this.targetX, 2); //* Math.sin(this.angle);
        this.y = Easing.easeInCubic(this.time, this.startY, this.targetY, 2); //* Math.sin(this.angle);

我在顶部评论的代码是我最初的工作方式,但我现在想要应用这个缓动功能,让我的导弹看起来更漂亮! :)

有人可以帮助我吗?

我想如果我还包括缓动函数本身可能会有所帮助:

easeInCubic: function(time,start,end,duration) {
        return end*(time/=duration)*time*time+start;
    }

好吧,所以我没有将缓和应用于开始和结束位置,而是通过将弹片应用于弹丸的速度来获得更接近我想要达到的效果。

this.x += Easing.easeInCubic(this.time, 0, this.speed, 3) * Math.sin(this.angle); 
        this.y += Easing.easeInCubic(this.time, 0, this.speed, 3) * Math.cos(this.angle); 

0 个答案:

没有答案