{"id":185,"date":"2020-02-14T21:26:10","date_gmt":"2020-02-14T13:26:10","guid":{"rendered":"https:\/\/blog.indeex.club\/?p=185"},"modified":"2020-06-20T23:29:42","modified_gmt":"2020-06-20T15:29:42","slug":"%e5%8a%a8%e6%95%88","status":"publish","type":"post","link":"https:\/\/blog.indeex.club\/index.php\/2020\/02\/14\/%e5%8a%a8%e6%95%88\/","title":{"rendered":"\u52a8\u6548"},"content":{"rendered":"<hr \/>\n<p><img src=\"https:\/\/hungking.cc\/assets\/imgs\/indeex.cc\/tween1.jpg\" alt=\"\u52a8\u6548\" \/><\/p>\n<p>\u9879\u76ee\u9700\u8981\u7528\u5230\u5f88\u591a\u52a8\u6548\uff0c\u4f46\u662f\u5f88\u591a\u5f00\u6e90\u52a8\u753b\u6548\u679c\u6ca1\u6709\u5f88\u597d\u7684\u79fb\u690d\u8fc7\u6765\uff0c\u8fd9\u91cc\u505a\u4e2a\u8bb0\u5f55\uff0c\u4f7f\u7528Typescript\uff0c\u5176\u4ed6ECMAScript\u5b9e\u73b0\u90fd\u4e00\u6837\uff0c\u6e38\u620f\u5f15\u64ceLayabox\u3001Egret\u3001Cocos\u7b49\u4e5f\u90fd\u4e00\u6837\u3002<\/p>\n<h3>\u52a8\u753b\u7c7b\u578b<\/h3>\n<p>\u57fa\u672c\u5305\u542b\u4e86\u5e38\u7528\u7684\u52a8\u753b\u7c7b\u578b\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">var arr: Array = [\n    \"Linear\",\n    \"QuadEaseOut\", \"QuadEaseIn\", \"QuadEaseInOut\", \"QuadEaseOutIn\",\n    \"ExpoEaseOut\", \"ExpoEaseIn\", \"ExpoEaseInOut\", \"ExpoEaseOutIn\",\n    \"CubicEaseOut\", \"CubicEaseIn\", \"CubicEaseInOut\", \"CubicEaseOutIn\",\n    \"QuartEaseOut\", \"QuartEaseIn\", \"QuartEaseInOut\", \"QuartEaseOutIn\",\n    \"QuintEaseOut\", \"QuintEaseIn\", \"QuintEaseInOut\", \"QuintEaseOutIn\",\n    \"CircEaseOut\", \"CircEaseIn\", \"CircEaseInOut\", \"CircEaseOutIn\",\n    \"SineEaseOut\", \"SineEaseIn\", \"SineEaseInOut\", \"SineEaseOutIn\",\n    \"ElasticEaseOut\", \"ElasticEaseIn\", \"ElasticEaseInOut\", \"ElasticEaseOutIn\",\n    \"BounceEaseOut\", \"BounceEaseIn\", \"BounceEaseInOut\", \"BounceEaseOutIn\",\n    \"BackEaseOut\", \"BackEaseIn\", \"BackEaseInOut\", \"BackEaseOutIn\"\n];\n<\/code><\/pre>\n<p>\u7136\u540e\u5c31\u662f\u5b9e\u73b0\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">enum ITweenType\n{\n    Linear,\n    QuadEaseOut, QuadEaseIn, QuadEaseInOut, QuadEaseOutIn,     \n    ExpoEaseOut, ExpoEaseIn, ExpoEaseInOut, ExpoEaseOutIn,\n    CubicEaseOut, CubicEaseIn, CubicEaseInOut, CubicEaseOutIn,\n    QuartEaseOut, QuartEaseIn, QuartEaseInOut, QuartEaseOutIn,\n    QuintEaseOut, QuintEaseIn, QuintEaseInOut, QuintEaseOutIn,\n    CircEaseOut, CircEaseIn, CircEaseInOut, CircEaseOutIn,\n    SineEaseOut, SineEaseIn, SineEaseInOut, SineEaseOutIn,\n    ElasticEaseOut, ElasticEaseIn, ElasticEaseInOut, ElasticEaseOutIn,\n    BounceEaseOut, BounceEaseIn, BounceEaseInOut, BounceEaseOutIn,\n    BackEaseOut, BackEaseIn, BackEaseInOut, BackEaseOutIn\n}\n\nclass ITweener\n{\n    public stepBackups = [];\n    public step = [];\n    public target : any;\n    public loop : number;\n    public index : number = 0;\n\n    public get(target : any, loop : number = 0)\n    {\n        this.target = target;\n        this.loop = loop;\n        return this;\n    }\n\n    public to(params : any, time : number, ease : ITweenType = ITweenType.Linear)\n    {\n        var obj : any = {};\n        obj.type = \"to\";\n        obj.startVals = Utils.Copy(params);\n        obj.endVals = params;\n        obj.endT = time;\n        obj.curT = 0;\n        obj.ease = ease;\n        obj.index = this.index++;\n        if(obj.index == 0)\n        {\n            for(var key in obj.startVals)\n            {\n                obj.startVals[key] = this.target[key];\n            }\n        }\n        this.step.push(obj);\n        if(this.loop != 0 &amp;&amp; this.loop != 1)\n            this.stepBackups.push(Utils.Copy(obj));\n        return this;\n    }\n\n    public call(func)\n    {\n        var obj : any = {};\n        obj.type = \"call\";\n        obj.func = func;\n        this.step.push(obj);\n        if(this.loop != 0 &amp;&amp; this.loop != 1)\n            this.stepBackups.push(Utils.Copy(obj));\n        return this;\n    }\n\n    public wait(time : number)\n    {\n        var obj : any = {};\n        obj.type = \"wait\";\n        obj.endT = time;\n        obj.curT = 0;\n        this.step.push(obj);\n        if(this.loop != 0 &amp;&amp; this.loop != 1)\n            this.stepBackups.push(Utils.Copy(obj));\n        return this;\n    } \n}\n\nclass ITween\n{ \n    private static tweenTable : Array&lt;ITweener&gt; = new Array();\n\n    public static Init()\n    {\n        egret.startTick(this.Update,this);\n    }\n\n    public static Play(wTweener : ITweener)\n    {\n        this.tweenTable.push(wTweener);\n        return  wTweener;\n    }\n\n    public static Stop(wTweener : ITweener) \n    {\n        var index = -1;\n        for(var i = 0; i &lt; this.tweenTable.length; i++)\n        {\n            if(this.tweenTable[i] == wTweener)\n            {\n                index = i;\n                break;\n            }\n        }\n        if(index != -1)\n            this.tweenTable.splice(index, 1);\n    }\n\n    private static timeOnEnterFrame:number = 0;\n    private static Update(timeStamp:number)\n    {        \n        var now = timeStamp;\n        var time = this.timeOnEnterFrame;\n        var pass = now - time;\n        this.timeOnEnterFrame = now;\n\n        for(var i = 0; i &lt; this.tweenTable.length; i++)\n        {\n            switch(this.tweenTable[i].step[0][\"type\"])\n            {\n                case \"to\":              \n                    if(this.tweenTable[i].step[0][\"curT\"] == 0)\n                    {\n                        if(this.tweenTable[i].step[0][\"index\"] != 0)\n                        {\n                            for(var key in this.tweenTable[i].step[0][\"startVals\"])\n                            {  \n                                this.tweenTable[i].step[0][\"startVals\"][key] = this.tweenTable[i].target[key];\n                                this.tweenTable[i].stepBackups.forEach((value,index,array)=&gt;{\n                                if(value[\"index\"] != null &amp;&amp; value[\"index\"] == this.tweenTable[i].step[0][\"index\"])\n                                    this.tweenTable[i].stepBackups[index][\"startVals\"][key] = this.tweenTable[i].target[key];\n                                })\n                            }\n                        }\n                    }  \n                    if(this.tweenTable[i].step[0][\"curT\"] + pass &lt; this.tweenTable[i].step[0][\"endT\"])\n                    {\n                        this.tweenTable[i].step[0][\"curT\"] += pass;\n                        this.RunTween(this.tweenTable[i].target, this.tweenTable[i].step[0])\n                    }\n                    else\n                    { \n                        for(var key in this.tweenTable[i].step[0][\"endVals\"])\n                            this.tweenTable[i].target[key] = this.tweenTable[i].step[0][\"endVals\"][key];\n                        this.tweenTable[i].step.shift();\n                    }\n                break;\n                case \"call\":\n                    if(this.tweenTable[i].step[0][\"func\"] != null)\n                        this.tweenTable[i].step[0][\"func\"].call();\n                    this.tweenTable[i].step.shift();\n                break;\n                case \"wait\":\n                    if(this.tweenTable[i].step[0][\"curT\"] &lt; this.tweenTable[i].step[0][\"endT\"])\n                        this.tweenTable[i].step[0][\"curT\"] += pass;\n                    else\n                        this.tweenTable[i].step.shift();\n                break;\n            }\n            if(this.tweenTable[i].step.length == 0)\n            {\n                if(this.tweenTable[i].loop &gt; 1 || this.tweenTable[i].loop == -1)\n                {\n                    if(this.tweenTable[i].loop &gt; 1)\n                        this.tweenTable[i].loop--;\n                    this.tweenTable[i].step = Utils.Copy(this.tweenTable[i].stepBackups);\n                    for(var j = 0; j &lt; this.tweenTable[i].stepBackups.length; j++)\n                    {\n                        if(this.tweenTable[i].stepBackups[j][\"type\"] == \"to\")\n                        {\n                            for(var key in this.tweenTable[i].stepBackups[j][\"startVals\"])\n                            {\n                                this.tweenTable[i].target[key] = this.tweenTable[i].stepBackups[j][\"startVals\"][key];\n                            }\n                            break;\n                        }\n                    }\n                }\n                else\n                    this.Stop(this.tweenTable[i]);\n            }\n        }\n        return true;\n    }\n\n    private static RunTween(target : any, obj : any)\n    {\n        for(var key in obj[\"endVals\"])\n        {\n            var currentValue = 0;\n            switch(obj[\"ease\"])\n            {\n                case ITweenType.Linear:\n                    currentValue = this.Linear(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.BackEaseIn:\n                    currentValue = this.BackEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.BackEaseInOut:\n                    currentValue = this.BackEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.BackEaseOut:\n                    currentValue = this.BackEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.BackEaseOutIn:\n                    currentValue = this.BackEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.BounceEaseIn:\n                    currentValue = this.BounceEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.BounceEaseInOut:\n                    currentValue = this.BounceEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.BounceEaseOut:\n                    currentValue = this.BounceEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.BounceEaseOutIn:\n                    currentValue = this.BounceEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.CircEaseIn:\n                    currentValue = this.CircEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.CircEaseInOut:\n                    currentValue = this.CircEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.CircEaseOut:\n                    currentValue = this.CircEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.CircEaseOutIn:\n                    currentValue = this.CircEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.CubicEaseIn:\n                    currentValue = this.CubicEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.CubicEaseInOut:\n                    currentValue = this.CubicEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.CubicEaseOut:\n                    currentValue = this.CubicEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.CubicEaseOutIn:\n                    currentValue = this.CubicEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.ElasticEaseIn:\n                    currentValue = this.ElasticEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.ElasticEaseInOut:\n                    currentValue = this.ElasticEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.ElasticEaseOut:\n                    currentValue = this.ElasticEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.ElasticEaseOutIn:\n                    currentValue = this.ElasticEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.ExpoEaseIn:\n                    currentValue = this.ExpoEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.ExpoEaseInOut:\n                    currentValue = this.ExpoEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.ExpoEaseOut:\n                    currentValue = this.ExpoEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.ExpoEaseOutIn:\n                    currentValue = this.ExpoEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuadEaseIn:\n                    currentValue = this.QuadEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuadEaseInOut:\n                    currentValue = this.QuadEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuadEaseOut:\n                    currentValue = this.QuadEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuadEaseOutIn:\n                    currentValue = this.QuadEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuartEaseIn:\n                    currentValue = this.QuartEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuartEaseInOut:\n                    currentValue = this.QuartEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuartEaseOut:\n                    currentValue = this.QuartEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuartEaseOutIn:\n                    currentValue = this.QuartEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuintEaseIn:\n                    currentValue = this.QuintEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuintEaseInOut:\n                    currentValue = this.QuintEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuintEaseOut:\n                    currentValue = this.QuintEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.QuintEaseOutIn:\n                    currentValue = this.QuintEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.SineEaseIn:\n                    currentValue = this.SineEaseIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.SineEaseInOut:\n                    currentValue = this.SineEaseInOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.SineEaseOut:\n                    currentValue = this.SineEaseOut(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                case ITweenType.SineEaseOutIn:\n                    currentValue = this.SineEaseOutIn(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n                default:\n                    currentValue = this.Linear(obj[\"curT\"], 0, obj[\"endVals\"][key] - obj[\"startVals\"][key], obj[\"endT\"]);\n                    break;\n            }\n            target[key] = currentValue + obj[\"startVals\"][key];\n        }\n    }\n\n    public static Linear(t : number, b : number, c : number, d : number)\n    {\n        return c * t \/ d + b;\n    }\n\n    public static ExpoEaseOut(t : number, b : number, c : number, d : number)\n    {\n        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t \/ d) + 1) + b;\n    }\n\n    public static ExpoEaseIn(t : number, b : number, c : number, d : number)\n    {\n        return (t == 0) ? b : c * Math.pow(2, 10 * (t \/ d - 1)) + b;\n    }\n\n    public static ExpoEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        if (t == 0)\n            return b;\n\n        if (t == d)\n            return b + c;\n\n        if ((t \/= d \/ 2) &lt; 1)\n            return c \/ 2 * Math.pow(2, 10 * (t - 1)) + b;\n\n        return c \/ 2 * (-Math.pow(2, -10 * --t) + 2) + b;\n    }\n\n    public static ExpoEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.ExpoEaseOut(t * 2, b, c \/ 2, d);\n\n        return this.ExpoEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    }\n\n    public static CircEaseOut(t : number, b : number, c : number, d : number)\n    {\n        return c * Math.sqrt(1 - (t = t \/ d - 1) * t) + b;\n    }\n\n    public static CircEaseIn(t : number, b : number, c : number, d : number)\n    {\n        return -c * (Math.sqrt(1 - (t \/= d) * t) - 1) + b;\n    }\n\n    public static CircEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d \/ 2) &lt; 1)\n            return -c \/ 2 * (Math.sqrt(1 - t * t) - 1) + b;\n\n        return c \/ 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;\n    }\n\n    public static CircEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.CircEaseOut(t * 2, b, c \/ 2, d);\n\n        return this.CircEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    }\n\n    public static QuadEaseOut(t : number, b : number, c : number, d : number)\n    {\n        return -c * (t \/= d) * (t - 2) + b;\n    }\n\n    public static QuadEaseIn(t : number, b : number, c : number, d : number)\n    {\n        return c * (t \/= d) * t + b;\n    }\n\n    public static QuadEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d \/ 2) &lt; 1)\n            return c \/ 2 * t * t + b;\n\n        return -c \/ 2 * ((--t) * (t - 2) - 1) + b;\n    }\n\n    public static QuadEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.QuadEaseOut(t * 2, b, c \/ 2, d);\n\n        return this.QuadEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    }\n\n    public static SineEaseOut(t : number, b : number, c : number, d : number)\n    {\n        return c * Math.sin(t \/ d * (Math.PI \/ 2)) + b;\n    }\n\n    public static SineEaseIn(t : number, b : number, c : number, d : number)\n    {\n        return -c * Math.cos(t \/ d * (Math.PI \/ 2)) + c + b;\n    }\n\n    public static SineEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d \/ 2) &lt; 1)\n            return c \/ 2 * (Math.sin(Math.PI * t \/ 2)) + b;\n\n        return -c \/ 2 * (Math.cos(Math.PI * --t \/ 2) - 2) + b;\n    }\n\n    public static SineEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.SineEaseOut(t * 2, b, c \/ 2, d);\n\n        return this.SineEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    }\n\n    public static CubicEaseOut(t : number, b : number, c : number, d : number)\n    {\n        return c * ((t = t \/ d - 1) * t * t + 1) + b;\n    }\n\n    public static CubicEaseIn(t : number, b : number, c : number, d : number)\n    {\n        return c * (t \/= d) * t * t + b;\n    }\n\n    public static CubicEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d \/ 2) &lt; 1)\n            return c \/ 2 * t * t * t + b;\n\n        return c \/ 2 * ((t -= 2) * t * t + 2) + b;\n    }\n\n    public static CubicEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.CubicEaseOut(t * 2, b, c \/ 2, d);\n\n        return this.CubicEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    }\n\n    public static QuartEaseOut(t : number, b : number, c : number, d : number)\n    {\n        return -c * ((t = t \/ d - 1) * t * t * t - 1) + b;\n    }\n\n    public static QuartEaseIn(t : number, b : number, c : number, d : number)\n    {\n        return c * (t \/= d) * t * t * t + b;\n    }\n\n    public static QuartEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d \/ 2) &lt; 1)\n            return c \/ 2 * t * t * t * t + b;\n\n        return -c \/ 2 * ((t -= 2) * t * t * t - 2) + b;\n    }\n\n    public static QuartEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.QuartEaseOut(t * 2, b, c \/ 2, d);\n\n        return this.QuartEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    } \n\n    public static QuintEaseOut(t : number, b : number, c : number, d : number)\n    {\n        return c * ((t = t \/ d - 1) * t * t * t * t + 1) + b;\n    }\n\n    public static QuintEaseIn(t : number, b : number, c : number, d : number)\n    {\n        return c * (t \/= d) * t * t * t * t + b;\n    }\n\n    public static QuintEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d \/ 2) &lt; 1)\n            return c \/ 2 * t * t * t * t * t + b;\n        return c \/ 2 * ((t -= 2) * t * t * t * t + 2) + b;\n    }\n\n    public static QuintEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.QuintEaseOut(t * 2, b, c \/ 2, d);\n        return this.QuintEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    } \n\n    public static ElasticEaseOut(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d) == 1)\n            return b + c;\n\n        var p = d * 0.3;\n        var s = p \/ 4;\n\n        return (c * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) \/ p) + c + b);\n    }\n\n    public static ElasticEaseIn(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d) == 1)\n            return b + c;\n\n        var p = d * 0.3;\n        var s = p \/ 4;\n\n        return -(c * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) \/ p)) + b;\n    }\n\n    public static ElasticEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d \/ 2) == 2)\n            return b + c;\n\n        var p = d * (0.3 * 1.5);\n        var s = p \/ 4;\n\n        if (t &lt; 1)\n            return -0.5 * (c * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) \/ p)) + b;\n        return c * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) \/ p) * 0.5 + c + b;\n    }\n\n    public static ElasticEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.ElasticEaseOut(t * 2, b, c \/ 2, d);\n        return this.ElasticEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    } \n\n    public static BounceEaseOut(t : number, b : number, c : number, d : number)\n    {\n        if ((t \/= d) &lt; (1 \/ 2.75))\n            return c * (7.5625 * t * t) + b;\n        else if (t &lt; (2 \/ 2.75))\n            return c * (7.5625 * (t -= (1.5 \/ 2.75)) * t + 0.75) + b;\n        else if (t &lt; (2.5 \/ 2.75))\n            return c * (7.5625 * (t -= (2.25 \/ 2.75)) * t + 0.9375) + b;\n        else\n            return c * (7.5625 * (t -= (2.625 \/ 2.75)) * t + .984375) + b;\n    }\n\n    public static BounceEaseIn(t : number, b : number, c : number, d : number)\n    {\n        return c - this.BounceEaseOut(d - t, 0, c, d) + b;\n    }\n\n    public static BounceEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;\n        else\n            return this.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n    }\n\n    public static BounceEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.BounceEaseOut(t * 2, b, c \/ 2, d);\n        return this.BounceEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    }\n\n    public static BackEaseOut(t : number, b : number, c : number, d : number)\n    {\n        return c * ((t = t \/ d - 1) * t * ((1.70158 + 1) * t + 1.70158) + 1) + b;\n    }\n\n    public static BackEaseIn(t : number, b : number, c : number, d : number)\n    {\n        return c * (t \/= d) * t * ((1.70158 + 1) * t - 1.70158) + b;\n    }\n\n    public static BackEaseInOut(t : number, b : number, c : number, d : number)\n    {\n        var s = 1.70158;\n        if ((t \/= d \/ 2) &lt; 1)\n            return c \/ 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;\n        return c \/ 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;\n    }\n\n    public static BackEaseOutIn(t : number, b : number, c : number, d : number)\n    {\n        if (t &lt; d \/ 2)\n            return this.BackEaseOut(t * 2, b, c \/ 2, d);\n        return this.BackEaseIn((t * 2) - d, b + c \/ 2, c \/ 2, d);\n    }\n}\n<\/code><\/pre>\n<p>\u7136\u540e\u662futils\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">class Utils{\n    public static Copy (o) {\n        if (o instanceof Array) \n        {\n            var a = [];\n            for (var i = 0; i &lt; o.length; ++i) {\n                a[i] = Utils.Copy(o[i]);\n            }\n            return a;\n\n        } \n        else if (o instanceof Function) \n        {\n            var b = o;\n            return b;\n        }  \n        else if (o instanceof Object) \n        {\n            var c = {}\n            for (var j in o) {\n                c[j] = Utils.Copy(o[j]);\n            }\n            return c;\n        }\n        else \n        {\n            return o;\n        }\n    }\n}\n<\/code><\/pre>\n<p>\u6d4b\u8bd5\uff0c\u4ee5Egret\u5f15\u64ce\u4e3a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">class Main extends eui.UILayer {\n    protected createChildren(): void {\n        super.createChildren();\n        WTween.Init();\n    }\n\n    \/\/...\n\n    protected gameScene(): void {\n        for(var i = 0; i &lt; 3; i++)\n        {\n            let icon: egret.Bitmap = this.createBitmapByName(\"test_png\");\n            this.addChild(icon);\n            icon.x = 0 + i * 120;\n            icon.y = 0;\n            ITween.Play(new WTweener()\n            .get(icon, -1)\n            .to({y:400, alpha:0.5}, 3000, ITweenType.Linear)\n            .call(()=&gt;{\n            })\n            .wait(1500)\n            .call(()=&gt;{\n            }));\n        }\n    }\n}\n<\/code><\/pre>\n<p>\u5c31\u8fd9\u6837\u5427\u3002<\/p>\n<p>code enjoy!\ud83e\udd29\ud83e\udd29\ud83e\udd29<\/p>\n<p>\u4f5c\u8005\uff1aindeex<\/p>\n<p>\u94fe\u63a5\uff1a<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/indeex.cc\/\">https:\/\/indeex.cc<\/a><\/p>\n<p>\u8457\u4f5c\u6743\u5f52\u4f5c\u8005\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u83b7\u5f97\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u9879\u76ee\u9700\u8981\u7528\u5230\u5f88\u591a\u52a8\u6548\uff0c\u4f46\u662f\u5f88\u591a\u5f00\u6e90\u52a8\u753b\u6548\u679c\u6ca1\u6709\u5f88\u597d\u7684\u79fb\u690d\u8fc7\u6765\uff0c\u8fd9\u91cc\u505a\u4e2a\u8bb0\u5f55\uff0c\u4f7f\u7528Typescript<a href=\"https:\/\/blog.indeex.club\/index.php\/2020\/02\/14\/%e5%8a%a8%e6%95%88\/\" class=\"read-more\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[4],"_links":{"self":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/185"}],"collection":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":1,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":190,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/185\/revisions\/190"}],"wp:attachment":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}