mathf这个库十分强大,基本上封装了 游戏数学方面的函数,
先介绍一个Mathf.pingpong
官方api
Mathf.PingPong 乒乓
static function PingPong (t : float, length : float) : float
Description描述
PingPongs the value t, so that it is never larger than length and never smaller than 0.
让数值t在 0到length之间往返。t值永远不会大于length的值,也永远不会小于0。
The returned value will move back and forth between 0 and length.
返回值将在0和length之间来回移动。