Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Math 防止penner松弛中的越界值_Math_Graphics2d_Easing Functions - Fatal编程技术网

Math 防止penner松弛中的越界值

Math 防止penner松弛中的越界值,math,graphics2d,easing-functions,Math,Graphics2d,Easing Functions,我正在进行一个项目,该项目使用以下缓和功能移动屏幕上的对象: function easeinoutquart(t,b,c,d) as float 't=time, b=startvalue, c=change in value, d=duration d=d/2 t=t/d if (t < 1) then return c/2*t*t*t*t + b end if t=t-2 return -c/2 * (t*t*t

我正在进行一个项目,该项目使用以下缓和功能移动屏幕上的对象:

function easeinoutquart(t,b,c,d) as float
    't=time, b=startvalue, c=change in value, d=duration
    d=d/2
    t=t/d
    if (t < 1) then 
        return c/2*t*t*t*t + b
    end if
    t=t-2
    return -c/2 * (t*t*t*t - 2) + b
end function
在添加图像下载/交换(实际的交换只是更改指针)代码之前,预加载图像和临时图像的一切都非常好。现在我首先加载临时映像并交换,我认为循环在超过1/30秒的时间内执行,这可能导致计时器值变得奇怪


所以从本质上说,我想知道是否有某种“治理器”钳子,我可以放在一些值上,以防止放松函数生成疯狂的值,这些值会迅速失控。例如,在一次迭代中移动的总距离不应超过250像素,事实上,移动距离应始终仅为距离目标值的几像素。

虽然我确定我没有很好地问这个问题,但我终于找到了答案。我遇到的问题是时间的价值大于持续时间的价值

在上面的函数中,您不需要输入目标值,只需要输入当前值以及起始值和目标值之间的差值。我提出的解决方案是:如果调用easing函数之间的执行时间超过了允许完成easing的最大持续时间值,那么只需将start值设置为等于destination值

time是自启动缓解功能以来的毫秒数:

change=destination-currentposition
currentposition=inoutquart(time,currentposition,change,duration)
if time > duration then startarray[i]=destarray[i]
这样,如果时间超过持续时间,我们将输出值钳制到目标位置

change=destination-currentposition
currentposition=inoutquart(time,currentposition,change,duration)
if time > duration then startarray[i]=destarray[i]