1 /**************************************************************************** 2 Copyright (c) 2008-2010 Ricardo Quesada 3 Copyright (c) 2011-2012 cocos2d-x.org 4 Copyright (c) 2013-2014 Chukong Technologies Inc. 5 6 http://www.cocos2d-x.org 7 8 Permission is hereby granted, free of charge, to any person obtaining a copy 9 of this software and associated documentation files (the "Software"), to deal 10 in the Software without restriction, including without limitation the rights 11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 copies of the Software, and to permit persons to whom the Software is 13 furnished to do so, subject to the following conditions: 14 15 The above copyright notice and this permission notice shall be included in 16 all copies or substantial portions of the Software. 17 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 THE SOFTWARE. 25 ****************************************************************************/ 26 27 /** 28 * Base class for Easing actions 29 * @class 30 * @extends cc.ActionInterval 31 * @param {cc.ActionInterval} action 32 * 33 * @deprecated since v3.0 Does not recommend the use of the base object. 34 * 35 * @example 36 * var moveEase = new cc.ActionEase(action); 37 */ 38 cc.ActionEase = cc.ActionInterval.extend(/** @lends cc.ActionEase# */{ 39 _inner:null, 40 41 /** 42 * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br /> 43 * creates the action of ActionEase. 44 * @param {cc.ActionInterval} action 45 */ 46 ctor: function (action) { 47 cc.ActionInterval.prototype.ctor.call(this); 48 action && this.initWithAction(action); 49 }, 50 51 /** 52 * initializes the action 53 * 54 * @param {cc.ActionInterval} action 55 * @return {Boolean} 56 */ 57 initWithAction:function (action) { 58 if(!action) 59 throw new Error("cc.ActionEase.initWithAction(): action must be non nil"); 60 61 if (this.initWithDuration(action.getDuration())) { 62 this._inner = action; 63 return true; 64 } 65 return false; 66 }, 67 68 /** 69 * to copy object with deep copy. 70 * returns a clone of action. 71 * 72 * @returns {cc.ActionEase} 73 */ 74 clone:function(){ 75 var action = new cc.ActionEase(); 76 action.initWithAction(this._inner.clone()); 77 return action; 78 }, 79 80 /** 81 * called before the action start. It will also set the target. 82 * 83 * @param {cc.Node} target 84 */ 85 startWithTarget:function (target) { 86 cc.ActionInterval.prototype.startWithTarget.call(this, target); 87 this._inner.startWithTarget(this.target); 88 }, 89 90 /** 91 * Stop the action. 92 */ 93 stop:function () { 94 this._inner.stop(); 95 cc.ActionInterval.prototype.stop.call(this); 96 }, 97 98 /** 99 * Called once per frame. Time is the number of seconds of a frame interval. 100 * 101 * @param {Number} dt 102 */ 103 update:function (dt) { 104 this._inner.update(dt); 105 }, 106 107 /** 108 * Create new action to original operation effect opposite. <br /> 109 * For example: <br /> 110 * - The action will be x coordinates of 0 move to 100. <br /> 111 * - The reversed action will be x of 100 move to 0. 112 * - Will be rewritten 113 * @return {cc.ActionEase} 114 */ 115 reverse:function () { 116 return new cc.ActionEase(this._inner.reverse()); 117 }, 118 119 /** 120 * Get inner Action. 121 * 122 * @return {cc.ActionInterval} 123 */ 124 getInnerAction:function(){ 125 return this._inner; 126 } 127 }); 128 129 /** 130 * creates the action of ActionEase 131 * 132 * @param {cc.ActionInterval} action 133 * @return {cc.ActionEase} 134 * @example 135 * // example 136 * var moveEase = cc.actionEase(action); 137 */ 138 cc.actionEase = function (action) { 139 return new cc.ActionEase(action); 140 }; 141 142 /** 143 * Please use cc.actionEase instead 144 * creates the action of ActionEase 145 * 146 * @param {cc.ActionInterval} action 147 * @return {cc.ActionEase} 148 * @static 149 * @deprecated since v3.0 please use cc.actionEase(action) instead. 150 */ 151 cc.ActionEase.create = cc.actionEase; 152 153 /** 154 * Base class for Easing actions with rate parameters 155 * 156 * @class 157 * @extends cc.ActionEase 158 * @param {cc.ActionInterval} action 159 * @param {Number} rate 160 * 161 * @deprecated since v3.0 please cc.easeRateAction(action, 3.0); 162 * 163 * @example 164 * //The old usage 165 * cc.EaseRateAction.create(action, 3.0); 166 * //The new usage 167 * var moveEaseRateAction = cc.easeRateAction(action, 3.0); 168 */ 169 cc.EaseRateAction = cc.ActionEase.extend(/** @lends cc.EaseRateAction# */{ 170 _rate:0, 171 172 /** 173 * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br /> 174 * Creates the action with the inner action and the rate parameter. 175 * @param {cc.ActionInterval} action 176 * @param {Number} rate 177 */ 178 ctor: function(action, rate){ 179 cc.ActionEase.prototype.ctor.call(this); 180 181 rate !== undefined && this.initWithAction(action, rate); 182 }, 183 184 /** 185 * set rate value for the actions 186 * @param {Number} rate 187 */ 188 setRate:function (rate) { 189 this._rate = rate; 190 }, 191 192 /** get rate value for the actions 193 * @return {Number} 194 */ 195 getRate:function () { 196 return this._rate; 197 }, 198 199 /** 200 * Initializes the action with the inner action and the rate parameter 201 * @param {cc.ActionInterval} action 202 * @param {Number} rate 203 * @return {Boolean} 204 */ 205 initWithAction:function (action, rate) { 206 if (cc.ActionEase.prototype.initWithAction.call(this, action)) { 207 this._rate = rate; 208 return true; 209 } 210 return false; 211 }, 212 213 /** 214 * to copy object with deep copy. 215 * returns a clone of action. 216 * 217 * @returns {cc.EaseRateAction} 218 */ 219 clone:function(){ 220 var action = new cc.EaseRateAction(); 221 action.initWithAction(this._inner.clone(), this._rate); 222 return action; 223 }, 224 225 /** 226 * Create new action to original operation effect opposite. <br /> 227 * For example: <br /> 228 * - The action will be x coordinates of 0 move to 100. <br /> 229 * - The reversed action will be x of 100 move to 0. 230 * - Will be rewritten 231 * @return {cc.EaseRateAction} 232 */ 233 reverse:function () { 234 return new cc.EaseRateAction(this._inner.reverse(), 1 / this._rate); 235 } 236 }); 237 238 /** 239 * Creates the action with the inner action and the rate parameter. 240 * 241 * @param {cc.ActionInterval} action 242 * @param {Number} rate 243 * @return {cc.EaseRateAction} 244 * @example 245 * // example 246 * var moveEaseRateAction = cc.easeRateAction(action, 3.0); 247 */ 248 cc.easeRateAction = function (action, rate) { 249 return new cc.EaseRateAction(action, rate); 250 }; 251 252 /** 253 * Please use cc.easeRateAction instead. <br /> 254 * Creates the action with the inner action and the rate parameter. 255 * 256 * @param {cc.ActionInterval} action 257 * @param {Number} rate 258 * @return {cc.EaseRateAction} 259 * @static 260 * @deprecated since v3.0 please use cc.easeRateAction(action, rate) 261 * @example 262 * //The old usage 263 * cc.EaseRateAction.create(action, 3.0); 264 * //The new usage 265 * var moveEaseRateAction = cc.easeRateAction(action, 3.0); 266 */ 267 cc.EaseRateAction.create = cc.easeRateAction; 268 269 /** 270 * cc.EaseIn action with a rate. From slow to fast. 271 * 272 * @class 273 * @extends cc.EaseRateAction 274 * 275 * @deprecated since v3.0 please use action.easing(cc.easeIn(3)); 276 * 277 * @example 278 * //The old usage 279 * cc.EaseIn.create(action, 3); 280 * //The new usage 281 * action.easing(cc.easeIn(3.0)); 282 */ 283 cc.EaseIn = cc.EaseRateAction.extend(/** @lends cc.EaseIn# */{ 284 285 /** 286 * Called once per frame. Time is the number of seconds of a frame interval. 287 * 288 * @param {Number} dt 289 */ 290 update:function (dt) { 291 this._inner.update(Math.pow(dt, this._rate)); 292 }, 293 294 /** 295 * Create a cc.easeIn action. Opposite with the original motion trajectory. 296 * @return {cc.EaseIn} 297 */ 298 reverse:function () { 299 return new cc.EaseIn(this._inner.reverse(), 1 / this._rate); 300 }, 301 302 /** 303 * to copy object with deep copy. 304 * returns a clone of action. 305 * 306 * @returns {cc.EaseIn} 307 */ 308 clone:function(){ 309 var action = new cc.EaseIn(); 310 action.initWithAction(this._inner.clone(), this._rate); 311 return action; 312 } 313 }); 314 315 /** 316 * Creates the action with the inner action and the rate parameter. <br /> 317 * From slow to fast. 318 * 319 * @static 320 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeIn(3)) 321 * 322 * @example 323 * //The old usage 324 * cc.EaseIn.create(action, 3); 325 * //The new usage 326 * action.easing(cc.easeIn(3.0)); 327 * 328 * @param {cc.ActionInterval} action 329 * @param {Number} rate 330 * @return {cc.EaseIn} 331 */ 332 cc.EaseIn.create = function (action, rate) { 333 return new cc.EaseIn(action, rate); 334 }; 335 336 /** 337 * Creates the action easing object with the rate parameter. <br /> 338 * From slow to fast. 339 * 340 * @function 341 * @param {Number} rate 342 * @return {Object} 343 * @example 344 * // example 345 * action.easing(cc.easeIn(3.0)); 346 */ 347 cc.easeIn = function (rate) { 348 return { 349 _rate: rate, 350 easing: function (dt) { 351 return Math.pow(dt, this._rate); 352 }, 353 reverse: function(){ 354 return cc.easeIn(1 / this._rate); 355 } 356 }; 357 }; 358 359 /** 360 * cc.EaseOut action with a rate. From fast to slow. 361 * 362 * @class 363 * @extends cc.EaseRateAction 364 * 365 * @deprecated since v3.0 please use action.easing(cc.easeOut(3)) 366 * 367 * @example 368 * //The old usage 369 * cc.EaseOut.create(action, 3); 370 * //The new usage 371 * action.easing(cc.easeOut(3.0)); 372 */ 373 cc.EaseOut = cc.EaseRateAction.extend(/** @lends cc.EaseOut# */{ 374 /** 375 * Called once per frame. Time is the number of seconds of a frame interval. 376 * 377 * @param {Number} dt 378 */ 379 update:function (dt) { 380 this._inner.update(Math.pow(dt, 1 / this._rate)); 381 }, 382 383 /** 384 * Create a cc.easeIn action. Opposite with the original motion trajectory. 385 * @return {cc.EaseOut} 386 */ 387 reverse:function () { 388 return new cc.EaseOut(this._inner.reverse(), 1 / this._rate); 389 }, 390 391 /** 392 * to copy object with deep copy. 393 * returns a clone of action. 394 * 395 * @returns {cc.EaseOut} 396 */ 397 clone:function(){ 398 var action = new cc.EaseOut(); 399 action.initWithAction(this._inner.clone(),this._rate); 400 return action; 401 } 402 }); 403 404 /** 405 * Creates the action with the inner action and the rate parameter. <br /> 406 * From fast to slow. 407 * 408 * @static 409 * @deprecated since v3.0 <br /> Please use cc.easeOut instead. 410 * 411 * @example 412 * //The old usage 413 * cc.EaseOut.create(action, 3); 414 * //The new usage 415 * action.easing(cc.easeOut(3.0)); 416 * 417 * @param {cc.ActionInterval} action 418 * @param {Number} rate 419 * @return {cc.EaseOut} 420 */ 421 cc.EaseOut.create = function (action, rate) { 422 return new cc.EaseOut(action, rate); 423 }; 424 425 /** 426 * Creates the action easing object with the rate parameter. <br /> 427 * From fast to slow. 428 * 429 * @function 430 * @param {Number} rate 431 * @return {Object} 432 * @example 433 * // example 434 * action.easing(cc.easeOut(3.0)); 435 */ 436 cc.easeOut = function (rate) { 437 return { 438 _rate: rate, 439 easing: function (dt) { 440 return Math.pow(dt, 1 / this._rate); 441 }, 442 reverse: function(){ 443 return cc.easeOut(1 / this._rate) 444 } 445 }; 446 }; 447 448 /** 449 * cc.EaseInOut action with a rate. <br /> 450 * Slow to fast then to slow. 451 * @class 452 * @extends cc.EaseRateAction 453 * 454 * @deprecated since v3.0 please use action.easing(cc.easeInOut(3.0)) 455 * 456 * @example 457 * //The old usage 458 * cc.EaseInOut.create(action, 3); 459 * //The new usage 460 * action.easing(cc.easeInOut(3.0)); 461 */ 462 cc.EaseInOut = cc.EaseRateAction.extend(/** @lends cc.EaseInOut# */{ 463 /** 464 * Called once per frame. Time is the number of seconds of a frame interval. 465 * 466 * @param {Number} dt 467 */ 468 update:function (dt) { 469 dt *= 2; 470 if (dt < 1) 471 this._inner.update(0.5 * Math.pow(dt, this._rate)); 472 else 473 this._inner.update(1.0 - 0.5 * Math.pow(2 - dt, this._rate)); 474 }, 475 476 /** 477 * to copy object with deep copy. 478 * returns a clone of action. 479 * 480 * @returns {cc.EaseInOut} 481 */ 482 clone:function(){ 483 var action = new cc.EaseInOut(); 484 action.initWithAction(this._inner.clone(), this._rate); 485 return action; 486 }, 487 488 /** 489 * Create a cc.EaseInOut action. Opposite with the original motion trajectory. 490 * @return {cc.EaseInOut} 491 */ 492 reverse:function () { 493 return new cc.EaseInOut(this._inner.reverse(), this._rate); 494 } 495 }); 496 497 /** 498 * Creates the action with the inner action and the rate parameter. 499 * Slow to fast then to slow. 500 * @static 501 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeInOut(3.0)) 502 * 503 * @example 504 * //The old usage 505 * cc.EaseInOut.create(action, 3); 506 * //The new usage 507 * action.easing(cc.easeInOut(3.0)); 508 * 509 * @param {cc.ActionInterval} action 510 * @param {Number} rate 511 * @return {cc.EaseInOut} 512 */ 513 cc.EaseInOut.create = function (action, rate) { 514 return new cc.EaseInOut(action, rate); 515 }; 516 517 /** 518 * Creates the action easing object with the rate parameter. <br /> 519 * Slow to fast then to slow. 520 * @function 521 * @param {Number} rate 522 * @return {Object} 523 * 524 * @example 525 * //The new usage 526 * action.easing(cc.easeInOut(3.0)); 527 */ 528 cc.easeInOut = function (rate) { 529 return { 530 _rate: rate, 531 easing: function (dt) { 532 dt *= 2; 533 if (dt < 1) 534 return 0.5 * Math.pow(dt, this._rate); 535 else 536 return 1.0 - 0.5 * Math.pow(2 - dt, this._rate); 537 }, 538 reverse: function(){ 539 return cc.easeInOut(this._rate); 540 } 541 }; 542 }; 543 544 /** 545 * cc.Ease Exponential In. Slow to Fast. <br /> 546 * Reference easeInExpo: <br /> 547 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 548 * @class 549 * @extends cc.ActionEase 550 * 551 * @deprecated since v3.0 please action.easing(cc.easeExponentialIn()) 552 * 553 * @example 554 * //The old usage 555 * cc.EaseExponentialIn.create(action); 556 * //The new usage 557 * action.easing(cc.easeExponentialIn()); 558 */ 559 cc.EaseExponentialIn = cc.ActionEase.extend(/** @lends cc.EaseExponentialIn# */{ 560 /** 561 * Called once per frame. Time is the number of seconds of a frame interval. 562 * 563 * @param {Number} dt 564 */ 565 update:function (dt) { 566 this._inner.update(dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1))); 567 }, 568 569 /** 570 * Create a cc.EaseExponentialOut action. Opposite with the original motion trajectory. 571 * @return {cc.EaseExponentialOut} 572 */ 573 reverse:function () { 574 return new cc.EaseExponentialOut(this._inner.reverse()); 575 }, 576 577 /** 578 * to copy object with deep copy. 579 * returns a clone of action. 580 * 581 * @returns {cc.EaseExponentialIn} 582 */ 583 clone:function(){ 584 var action = new cc.EaseExponentialIn(); 585 action.initWithAction(this._inner.clone()); 586 return action; 587 } 588 }); 589 590 /** 591 * Creates the action easing object with the rate parameter. <br /> 592 * Reference easeInExpo: <br /> 593 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 594 * @static 595 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeExponentialIn()) 596 * @param {cc.ActionInterval} action 597 * @return {cc.EaseExponentialIn} 598 * 599 * @example 600 * //The old usage 601 * cc.EaseExponentialIn.create(action); 602 * //The new usage 603 * action.easing(cc.easeExponentialIn()); 604 */ 605 cc.EaseExponentialIn.create = function (action) { 606 return new cc.EaseExponentialIn(action); 607 }; 608 609 cc._easeExponentialInObj = { 610 easing: function(dt){ 611 return dt === 0 ? 0 : Math.pow(2, 10 * (dt - 1)); 612 }, 613 reverse: function(){ 614 return cc._easeExponentialOutObj; 615 } 616 }; 617 618 /** 619 * Creates the action easing object with the rate parameter. <br /> 620 * Reference easeInExpo: <br /> 621 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 622 * @function 623 * @return {Object} 624 * @example 625 * // example 626 * action.easing(cc.easeExponentialIn()); 627 */ 628 cc.easeExponentialIn = function(){ 629 return cc._easeExponentialInObj; 630 }; 631 632 /** 633 * Ease Exponential Out. <br /> 634 * Reference easeOutExpo: <br /> 635 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 636 * @class 637 * @extends cc.ActionEase 638 * 639 * @deprecated since v3.0 please use action.easing(cc.easeExponentialOut()) 640 * 641 * @example 642 * //The old usage 643 * cc.EaseExponentialOut.create(action); 644 * //The new usage 645 * action.easing(cc.easeExponentialOut()); 646 */ 647 cc.EaseExponentialOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialOut# */{ 648 /** 649 * Called once per frame. Time is the number of seconds of a frame interval. 650 * 651 * @param {Number} dt 652 */ 653 update:function (dt) { 654 this._inner.update(dt === 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1)); 655 }, 656 657 /** 658 * Create a cc.EaseExponentialIn action. Opposite with the original motion trajectory. 659 * @return {cc.EaseExponentialIn} 660 */ 661 reverse:function () { 662 return new cc.EaseExponentialIn(this._inner.reverse()); 663 }, 664 665 /** 666 * to copy object with deep copy. 667 * returns a clone of action. 668 * 669 * @returns {cc.EaseExponentialOut} 670 */ 671 clone:function(){ 672 var action = new cc.EaseExponentialOut(); 673 action.initWithAction(this._inner.clone()); 674 return action; 675 } 676 }); 677 678 /** 679 * Creates the action easing object with the rate parameter. <br /> 680 * Reference easeOutExpo: <br /> 681 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 682 * @static 683 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeExponentialOut()) 684 * @param {cc.ActionInterval} action 685 * @return {Object} 686 * 687 * @example 688 * //The old usage 689 * cc.EaseExponentialOut.create(action); 690 * //The new usage 691 * action.easing(cc.easeExponentialOut()); 692 */ 693 cc.EaseExponentialOut.create = function (action) { 694 return new cc.EaseExponentialOut(action); 695 }; 696 697 cc._easeExponentialOutObj = { 698 easing: function(dt){ 699 return dt === 1 ? 1 : (-(Math.pow(2, -10 * dt)) + 1); 700 }, 701 reverse: function(){ 702 return cc._easeExponentialInObj; 703 } 704 }; 705 706 /** 707 * creates the action easing object. <br /> 708 * Reference easeOutExpo: <br /> 709 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 710 * 711 * @return {Object} 712 * @example 713 * // example 714 * action.easing(cc.easeExponentialOut()); 715 */ 716 cc.easeExponentialOut = function(){ 717 return cc._easeExponentialOutObj; 718 }; 719 720 /** 721 * Ease Exponential InOut. <br /> 722 * Reference easeInOutExpo: <br /> 723 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 724 * 725 * @class 726 * @extends cc.ActionEase 727 * 728 * @deprecated since v3.0 please use action.easing(cc.easeExponentialInOut) 729 * 730 * @example 731 * //The old usage 732 * cc.EaseExponentialInOut.create(action); 733 * //The new usage 734 * action.easing(cc.easeExponentialInOut()); 735 */ 736 cc.EaseExponentialInOut = cc.ActionEase.extend(/** @lends cc.EaseExponentialInOut# */{ 737 /** 738 * Called once per frame. Time is the number of seconds of a frame interval. 739 * 740 * @param {Number} dt 741 */ 742 update:function (dt) { 743 if( dt !== 1 && dt !== 0) { 744 dt *= 2; 745 if (dt < 1) 746 dt = 0.5 * Math.pow(2, 10 * (dt - 1)); 747 else 748 dt = 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2); 749 } 750 this._inner.update(dt); 751 }, 752 753 /** 754 * Create a cc.EaseExponentialInOut action. Opposite with the original motion trajectory. 755 * @return {cc.EaseExponentialInOut} 756 */ 757 reverse:function () { 758 return new cc.EaseExponentialInOut(this._inner.reverse()); 759 }, 760 761 /** 762 * to copy object with deep copy. 763 * returns a clone of action. 764 * 765 * @returns {cc.EaseExponentialInOut} 766 */ 767 clone:function(){ 768 var action = new cc.EaseExponentialInOut(); 769 action.initWithAction(this._inner.clone()); 770 return action; 771 } 772 }); 773 774 /** 775 * creates an EaseExponentialInOut action. <br /> 776 * Reference easeInOutExpo: <br /> 777 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 778 * @static 779 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeExponentialInOut) 780 * @param {cc.ActionInterval} action 781 * @return {cc.EaseExponentialInOut} 782 * 783 * @example 784 * //The old usage 785 * cc.EaseExponentialInOut.create(action); 786 * //The new usage 787 * action.easing(cc.easeExponentialInOut()); 788 */ 789 cc.EaseExponentialInOut.create = function (action) { 790 return new cc.EaseExponentialInOut(action); 791 }; 792 793 cc._easeExponentialInOutObj = { 794 easing: function(dt){ 795 if( dt !== 1 && dt !== 0) { 796 dt *= 2; 797 if (dt < 1) 798 return 0.5 * Math.pow(2, 10 * (dt - 1)); 799 else 800 return 0.5 * (-Math.pow(2, -10 * (dt - 1)) + 2); 801 } 802 return dt; 803 }, 804 reverse: function(){ 805 return cc._easeExponentialInOutObj; 806 } 807 }; 808 809 /** 810 * creates an EaseExponentialInOut action easing object. <br /> 811 * Reference easeInOutExpo: <br /> 812 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 813 * @function 814 * @return {Object} 815 * @example 816 * // example 817 * action.easing(cc.easeExponentialInOut()); 818 */ 819 cc.easeExponentialInOut = function(){ 820 return cc._easeExponentialInOutObj; 821 }; 822 823 /** 824 * Ease Sine In. <br /> 825 * Reference easeInSine: <br /> 826 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 827 * @class 828 * @extends cc.ActionEase 829 * 830 * @deprecated since v3.0 please use action.easing(cc.easeSineIn()) 831 * 832 * @example 833 * //The old usage 834 * cc.EaseSineIn.create(action); 835 * //The new usage 836 * action.easing(cc.easeSineIn()); 837 */ 838 cc.EaseSineIn = cc.ActionEase.extend(/** @lends cc.EaseSineIn# */{ 839 /** 840 * Called once per frame. Time is the number of seconds of a frame interval. 841 * 842 * @param {Number} dt 843 */ 844 update:function (dt) { 845 dt = dt===0 || dt===1 ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1; 846 this._inner.update(dt); 847 }, 848 849 /** 850 * Create a cc.EaseSineOut action. Opposite with the original motion trajectory. 851 * @return {cc.EaseSineOut} 852 */ 853 reverse:function () { 854 return new cc.EaseSineOut(this._inner.reverse()); 855 }, 856 857 /** 858 * to copy object with deep copy. 859 * returns a clone of action. 860 * 861 * @returns {cc.EaseSineIn} 862 */ 863 clone:function(){ 864 var action = new cc.EaseSineIn(); 865 action.initWithAction(this._inner.clone()); 866 return action; 867 } 868 }); 869 870 /** 871 * creates an EaseSineIn action. <br /> 872 * Reference easeInSine: <br /> 873 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 874 * @static 875 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeSineIn()) 876 * @param {cc.ActionInterval} action 877 * @return {cc.EaseSineIn} 878 * 879 * @example 880 * //The old usage 881 * cc.EaseSineIn.create(action); 882 * //The new usage 883 * action.easing(cc.easeSineIn()); 884 */ 885 cc.EaseSineIn.create = function (action) { 886 return new cc.EaseSineIn(action); 887 }; 888 889 cc._easeSineInObj = { 890 easing: function(dt){ 891 return (dt===0 || dt===1) ? dt : -1 * Math.cos(dt * Math.PI / 2) + 1; 892 }, 893 reverse: function(){ 894 return cc._easeSineOutObj; 895 } 896 }; 897 /** 898 * creates an EaseSineIn action. <br /> 899 * Reference easeInSine: <br /> 900 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 901 * @function 902 * @return {Object} 903 * @example 904 * // example 905 * action.easing(cc.easeSineIn()); 906 */ 907 cc.easeSineIn = function(){ 908 return cc._easeSineInObj; 909 }; 910 911 /** 912 * Ease Sine Out. <br /> 913 * Reference easeOutSine: <br /> 914 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 915 * @class 916 * @extends cc.ActionEase 917 * 918 * @deprecated since v3.0 please use action.easing(cc.easeSineOut()) 919 * 920 * @example 921 * //The old usage 922 * cc.EaseSineOut.create(action); 923 * //The new usage 924 * action.easing(cc.easeSineOut()); 925 */ 926 cc.EaseSineOut = cc.ActionEase.extend(/** @lends cc.EaseSineOut# */{ 927 /** 928 * Called once per frame. Time is the number of seconds of a frame interval. 929 * 930 * @param {Number} dt 931 */ 932 update:function (dt) { 933 dt = dt===0 || dt===1 ? dt : Math.sin(dt * Math.PI / 2); 934 this._inner.update(dt); 935 }, 936 937 /** 938 * Create a cc.EaseSineIn action. Opposite with the original motion trajectory. 939 * @return {cc.EaseSineIn} 940 */ 941 reverse:function () { 942 return new cc.EaseSineIn(this._inner.reverse()); 943 }, 944 945 /** 946 * to copy object with deep copy. 947 * returns a clone of action. 948 * 949 * @returns {cc.EaseSineOut} 950 */ 951 clone:function(){ 952 var action = new cc.EaseSineOut(); 953 action.initWithAction(this._inner.clone()); 954 return action; 955 } 956 }); 957 958 /** 959 * Creates an EaseSineOut action. <br /> 960 * Reference easeOutSine: <br /> 961 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 962 * @static 963 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeSineOut()) 964 * @param {cc.ActionInterval} action 965 * @return {cc.EaseSineOut} 966 * 967 * @example 968 * //The old usage 969 * cc.EaseSineOut.create(action); 970 * //The new usage 971 * action.easing(cc.easeSineOut()); 972 */ 973 cc.EaseSineOut.create = function (action) { 974 return new cc.EaseSineOut(action); 975 }; 976 977 cc._easeSineOutObj = { 978 easing: function(dt){ 979 return (dt===0 || dt===1) ? dt : Math.sin(dt * Math.PI / 2); 980 }, 981 reverse: function(){ 982 return cc._easeSineInObj; 983 } 984 }; 985 986 /** 987 * Creates an EaseSineOut action easing object. <br /> 988 * Reference easeOutSine: <br /> 989 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 990 * @function 991 * @return {Object} 992 * @example 993 * // example 994 * action.easing(cc.easeSineOut()); 995 */ 996 cc.easeSineOut = function(){ 997 return cc._easeSineOutObj; 998 }; 999 1000 /** 1001 * Ease Sine InOut. <br /> 1002 * Reference easeInOutSine: <br /> 1003 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1004 * @class 1005 * @extends cc.ActionEase 1006 * 1007 * @deprecated since v3.0 please use action.easing(cc.easeSineInOut()) 1008 * 1009 * @example 1010 * //The old usage 1011 * cc.EaseSineInOut.create(action); 1012 * //The new usage 1013 * action.easing(cc.easeSineInOut()); 1014 */ 1015 cc.EaseSineInOut = cc.ActionEase.extend(/** @lends cc.EaseSineInOut# */{ 1016 /** 1017 * Called once per frame. Time is the number of seconds of a frame interval. 1018 * 1019 * @param {Number} dt 1020 */ 1021 update:function (dt) { 1022 dt = dt===0 || dt===1 ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1); 1023 this._inner.update(dt); 1024 }, 1025 1026 /** 1027 * to copy object with deep copy. 1028 * returns a clone of action. 1029 * 1030 * @returns {cc.EaseSineInOut} 1031 */ 1032 clone:function(){ 1033 var action = new cc.EaseSineInOut(); 1034 action.initWithAction(this._inner.clone()); 1035 return action; 1036 }, 1037 1038 /** 1039 * Create a cc.EaseSineInOut action. Opposite with the original motion trajectory. 1040 * @return {cc.EaseSineInOut} 1041 */ 1042 reverse:function () { 1043 return new cc.EaseSineInOut(this._inner.reverse()); 1044 } 1045 }); 1046 1047 /** 1048 * Creates the action. <br /> 1049 * Reference easeInOutSine: <br /> 1050 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1051 * @static 1052 * @param {cc.ActionInterval} action 1053 * @return {cc.EaseSineInOut} 1054 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeSineInOut()) 1055 * 1056 * @example 1057 * //The old usage 1058 * cc.EaseSineInOut.create(action); 1059 * //The new usage 1060 * action.easing(cc.easeSineInOut()); 1061 */ 1062 cc.EaseSineInOut.create = function (action) { 1063 return new cc.EaseSineInOut(action); 1064 }; 1065 1066 cc._easeSineInOutObj = { 1067 easing: function(dt){ 1068 return (dt === 0 || dt === 1) ? dt : -0.5 * (Math.cos(Math.PI * dt) - 1); 1069 }, 1070 reverse: function(){ 1071 return cc._easeSineInOutObj; 1072 } 1073 }; 1074 1075 /** 1076 * creates the action easing object. <br /> 1077 * Reference easeInOutSine: <br /> 1078 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1079 * @return {Object} 1080 * @example 1081 * // example 1082 * action.easing(cc.easeSineInOut()); 1083 */ 1084 cc.easeSineInOut = function(){ 1085 return cc._easeSineInOutObj; 1086 }; 1087 1088 /** 1089 * Ease Elastic abstract class. 1090 * @class 1091 * @extends cc.ActionEase 1092 * @param {cc.ActionInterval} action 1093 * @param {Number} [period=0.3] 1094 * 1095 * @deprecated since v3.0 Does not recommend the use of the base object. 1096 */ 1097 cc.EaseElastic = cc.ActionEase.extend(/** @lends cc.EaseElastic# */{ 1098 _period: 0.3, 1099 1100 /** 1101 * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br /> 1102 * Creates the action with the inner action and the period in radians (default is 0.3). 1103 * @param {cc.ActionInterval} action 1104 * @param {Number} [period=0.3] 1105 */ 1106 ctor:function(action, period){ 1107 cc.ActionEase.prototype.ctor.call(this); 1108 1109 action && this.initWithAction(action, period); 1110 }, 1111 1112 /** 1113 * get period of the wave in radians. default is 0.3 1114 * @return {Number} 1115 */ 1116 getPeriod:function () { 1117 return this._period; 1118 }, 1119 1120 /** 1121 * set period of the wave in radians. 1122 * @param {Number} period 1123 */ 1124 setPeriod:function (period) { 1125 this._period = period; 1126 }, 1127 1128 /** 1129 * Initializes the action with the inner action and the period in radians (default is 0.3) 1130 * @param {cc.ActionInterval} action 1131 * @param {Number} [period=0.3] 1132 * @return {Boolean} 1133 */ 1134 initWithAction:function (action, period) { 1135 cc.ActionEase.prototype.initWithAction.call(this, action); 1136 this._period = (period == null) ? 0.3 : period; 1137 return true; 1138 }, 1139 1140 /** 1141 * Create a action. Opposite with the original motion trajectory. <br /> 1142 * Will be overwrite. 1143 * @return {null} 1144 */ 1145 reverse:function () { 1146 cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass."); 1147 return null; 1148 }, 1149 1150 /** 1151 * to copy object with deep copy. 1152 * returns a clone of action. 1153 * 1154 * @returns {cc.EaseElastic} 1155 */ 1156 clone:function(){ 1157 var action = new cc.EaseElastic(); 1158 action.initWithAction(this._inner.clone(), this._period); 1159 return action; 1160 } 1161 }); 1162 1163 /** 1164 * Creates the action with the inner action and the period in radians (default is 0.3). 1165 * @static 1166 * @deprecated since v3.0 Does not recommend the use of the base object. 1167 * @param {cc.ActionInterval} action 1168 * @param {Number} [period=0.3] 1169 * @return {cc.EaseElastic} 1170 */ 1171 cc.EaseElastic.create = function (action, period) { 1172 return new cc.EaseElastic(action, period); 1173 }; 1174 1175 /** 1176 * Ease Elastic In action. <br /> 1177 * Reference easeInElastic: <br /> 1178 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1179 * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. 1180 * @class 1181 * @extends cc.EaseElastic 1182 * 1183 * @deprecated since v3.0 please use action.easing(cc.easeElasticIn()) 1184 * 1185 * @example 1186 * //The old usage 1187 * cc.EaseElasticIn.create(action, period); 1188 * //The new usage 1189 * action.easing(cc.easeElasticIn(period)); 1190 */ 1191 cc.EaseElasticIn = cc.EaseElastic.extend(/** @lends cc.EaseElasticIn# */{ 1192 /** 1193 * Called once per frame. Time is the number of seconds of a frame interval. 1194 * 1195 * @param {Number} dt 1196 */ 1197 update:function (dt) { 1198 var newT = 0; 1199 if (dt === 0 || dt === 1) { 1200 newT = dt; 1201 } else { 1202 var s = this._period / 4; 1203 dt = dt - 1; 1204 newT = -Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / this._period); 1205 } 1206 this._inner.update(newT); 1207 }, 1208 1209 /** 1210 * Create a action. Opposite with the original motion trajectory. 1211 * @return {cc.EaseElasticOut} 1212 */ 1213 reverse:function () { 1214 return new cc.EaseElasticOut(this._inner.reverse(), this._period); 1215 }, 1216 1217 /** 1218 * to copy object with deep copy. 1219 * returns a clone of action. 1220 * 1221 * @returns {cc.EaseElasticIn} 1222 */ 1223 clone:function(){ 1224 var action = new cc.EaseElasticIn(); 1225 action.initWithAction(this._inner.clone(), this._period); 1226 return action; 1227 } 1228 }); 1229 1230 /** 1231 * Creates the action with the inner action and the period in radians (default is 0.3). <br /> 1232 * Reference easeInElastic: <br /> 1233 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1234 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeElasticIn(period)) 1235 * 1236 * @example 1237 * //The old usage 1238 * cc.EaseElasticIn.create(action, period); 1239 * //The new usage 1240 * action.easing(cc.easeElasticIn(period)); 1241 * 1242 * @param {cc.ActionInterval} action 1243 * @param {Number} [period=0.3] 1244 * @return {cc.EaseElasticIn} 1245 */ 1246 cc.EaseElasticIn.create = function (action, period) { 1247 return new cc.EaseElasticIn(action, period); 1248 }; 1249 1250 //default ease elastic in object (period = 0.3) 1251 cc._easeElasticInObj = { 1252 easing:function(dt){ 1253 if (dt === 0 || dt === 1) 1254 return dt; 1255 dt = dt - 1; 1256 return -Math.pow(2, 10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3); 1257 }, 1258 reverse:function(){ 1259 return cc._easeElasticOutObj; 1260 } 1261 }; 1262 1263 /** 1264 * Creates the action easing obejct with the period in radians (default is 0.3). <br /> 1265 * Reference easeInElastic: <br /> 1266 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1267 * @function 1268 * @param {Number} [period=0.3] 1269 * @return {Object} 1270 * @example 1271 * // example 1272 * action.easing(cc.easeElasticIn(3.0)); 1273 */ 1274 cc.easeElasticIn = function (period) { 1275 if(period && period !== 0.3){ 1276 return { 1277 _period: period, 1278 easing: function (dt) { 1279 if (dt === 0 || dt === 1) 1280 return dt; 1281 dt = dt - 1; 1282 return -Math.pow(2, 10 * dt) * Math.sin((dt - (this._period / 4)) * Math.PI * 2 / this._period); 1283 }, 1284 reverse:function () { 1285 return cc.easeElasticOut(this._period); 1286 } 1287 }; 1288 } 1289 return cc._easeElasticInObj; 1290 }; 1291 1292 /** 1293 * Ease Elastic Out action. <br /> 1294 * Reference easeOutElastic: <br /> 1295 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1296 * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. 1297 * @class 1298 * @extends cc.EaseElastic 1299 * 1300 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeElasticOut(period)) 1301 * 1302 * @example 1303 * //The old usage 1304 * cc.EaseElasticOut.create(action, period); 1305 * //The new usage 1306 * action.easing(cc.easeElasticOut(period)); 1307 */ 1308 cc.EaseElasticOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticOut# */{ 1309 /** 1310 * Called once per frame. Time is the number of seconds of a frame interval. 1311 * 1312 * @param {Number} dt 1313 */ 1314 update:function (dt) { 1315 var newT = 0; 1316 if (dt === 0 || dt === 1) { 1317 newT = dt; 1318 } else { 1319 var s = this._period / 4; 1320 newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / this._period) + 1; 1321 } 1322 1323 this._inner.update(newT); 1324 }, 1325 1326 /** 1327 * Create a action. Opposite with the original motion trajectory. 1328 * @return {cc.EaseElasticIn} 1329 */ 1330 reverse:function () { 1331 return new cc.EaseElasticIn(this._inner.reverse(), this._period); 1332 }, 1333 1334 /** 1335 * to copy object with deep copy. 1336 * returns a clone of action. 1337 * 1338 * @returns {cc.EaseElasticOut} 1339 */ 1340 clone:function(){ 1341 var action = new cc.EaseElasticOut(); 1342 action.initWithAction(this._inner.clone(), this._period); 1343 return action; 1344 } 1345 }); 1346 1347 /** 1348 * Creates the action with the inner action and the period in radians (default is 0.3). <br /> 1349 * Reference easeOutElastic: <br /> 1350 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1351 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeElasticOut(period)) 1352 * @param {cc.ActionInterval} action 1353 * @param {Number} [period=0.3] 1354 * @return {cc.EaseElasticOut} 1355 * 1356 * @example 1357 * //The old usage 1358 * cc.EaseElasticOut.create(action, period); 1359 * //The new usage 1360 * action.easing(cc.easeElasticOut(period)); 1361 */ 1362 cc.EaseElasticOut.create = function (action, period) { 1363 return new cc.EaseElasticOut(action, period); 1364 }; 1365 1366 //default ease elastic out object (period = 0.3) 1367 cc._easeElasticOutObj = { 1368 easing: function (dt) { 1369 return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (0.3 / 4)) * Math.PI * 2 / 0.3) + 1; 1370 }, 1371 reverse:function(){ 1372 return cc._easeElasticInObj; 1373 } 1374 }; 1375 /** 1376 * Creates the action easing object with the period in radians (default is 0.3). <br /> 1377 * Reference easeOutElastic: <br /> 1378 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1379 * @function 1380 * @param {Number} [period=0.3] 1381 * @return {Object} 1382 * @example 1383 * // example 1384 * action.easing(cc.easeElasticOut(3.0)); 1385 */ 1386 cc.easeElasticOut = function (period) { 1387 if(period && period !== 0.3){ 1388 return { 1389 _period: period, 1390 easing: function (dt) { 1391 return (dt === 0 || dt === 1) ? dt : Math.pow(2, -10 * dt) * Math.sin((dt - (this._period / 4)) * Math.PI * 2 / this._period) + 1; 1392 }, 1393 reverse:function(){ 1394 return cc.easeElasticIn(this._period); 1395 } 1396 }; 1397 } 1398 return cc._easeElasticOutObj; 1399 }; 1400 1401 /** 1402 * Ease Elastic InOut action. <br /> 1403 * Reference easeInOutElastic: <br /> 1404 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1405 * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. 1406 * @class 1407 * @extends cc.EaseElastic 1408 * 1409 * @deprecated since v3.0 please use action.easing(cc.easeElasticInOut()) 1410 * 1411 * @example 1412 * //The old usage 1413 * cc.EaseElasticInOut.create(action, period); 1414 * //The new usage 1415 * action.easing(cc.easeElasticInOut(period)); 1416 */ 1417 cc.EaseElasticInOut = cc.EaseElastic.extend(/** @lends cc.EaseElasticInOut# */{ 1418 /** 1419 * Called once per frame. Time is the number of seconds of a frame interval. 1420 * 1421 * @param {Number} dt 1422 */ 1423 update:function (dt) { 1424 var newT = 0; 1425 var locPeriod = this._period; 1426 if (dt === 0 || dt === 1) { 1427 newT = dt; 1428 } else { 1429 dt = dt * 2; 1430 if (!locPeriod) 1431 locPeriod = this._period = 0.3 * 1.5; 1432 1433 var s = locPeriod / 4; 1434 dt = dt - 1; 1435 if (dt < 0) 1436 newT = -0.5 * Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod); 1437 else 1438 newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * 0.5 + 1; 1439 } 1440 this._inner.update(newT); 1441 }, 1442 1443 /** 1444 * Create a action. Opposite with the original motion trajectory. 1445 * @return {cc.EaseElasticInOut} 1446 */ 1447 reverse:function () { 1448 return new cc.EaseElasticInOut(this._inner.reverse(), this._period); 1449 }, 1450 1451 /** 1452 * to copy object with deep copy. 1453 * returns a clone of action. 1454 * 1455 * @returns {cc.EaseElasticInOut} 1456 */ 1457 clone:function(){ 1458 var action = new cc.EaseElasticInOut(); 1459 action.initWithAction(this._inner.clone(), this._period); 1460 return action; 1461 } 1462 }); 1463 1464 /** 1465 * Creates the action with the inner action and the period in radians (default is 0.3). <br /> 1466 * Reference easeInOutElastic: <br /> 1467 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1468 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeElasticInOut(period)) 1469 * @param {cc.ActionInterval} action 1470 * @param {Number} [period=0.3] 1471 * @return {cc.EaseElasticInOut} 1472 * 1473 * @example 1474 * //The old usage 1475 * cc.EaseElasticInOut.create(action, period); 1476 * //The new usage 1477 * action.easing(cc.easeElasticInOut(period)); 1478 */ 1479 cc.EaseElasticInOut.create = function (action, period) { 1480 return new cc.EaseElasticInOut(action, period); 1481 }; 1482 1483 /** 1484 * Creates the action easing object with the period in radians (default is 0.3). <br /> 1485 * Reference easeInOutElastic: <br /> 1486 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 1487 * @function 1488 * @param {Number} [period=0.3] 1489 * @return {Object} 1490 * @example 1491 * // example 1492 * action.easing(cc.easeElasticInOut(3.0)); 1493 */ 1494 cc.easeElasticInOut = function (period) { 1495 period = period || 0.3; 1496 return { 1497 _period: period, 1498 easing: function (dt) { 1499 var newT = 0; 1500 var locPeriod = this._period; 1501 if (dt === 0 || dt === 1) { 1502 newT = dt; 1503 } else { 1504 dt = dt * 2; 1505 if (!locPeriod) 1506 locPeriod = this._period = 0.3 * 1.5; 1507 var s = locPeriod / 4; 1508 dt = dt - 1; 1509 if (dt < 0) 1510 newT = -0.5 * Math.pow(2, 10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod); 1511 else 1512 newT = Math.pow(2, -10 * dt) * Math.sin((dt - s) * Math.PI * 2 / locPeriod) * 0.5 + 1; 1513 } 1514 return newT; 1515 }, 1516 reverse: function(){ 1517 return cc.easeElasticInOut(this._period); 1518 } 1519 }; 1520 }; 1521 1522 /** 1523 * cc.EaseBounce abstract class. 1524 * 1525 * @deprecated since v3.0 Does not recommend the use of the base object. 1526 * 1527 * @class 1528 * @extends cc.ActionEase 1529 */ 1530 cc.EaseBounce = cc.ActionEase.extend(/** @lends cc.EaseBounce# */{ 1531 /** 1532 * @param {Number} time1 1533 * @return {Number} 1534 */ 1535 bounceTime:function (time1) { 1536 if (time1 < 1 / 2.75) { 1537 return 7.5625 * time1 * time1; 1538 } else if (time1 < 2 / 2.75) { 1539 time1 -= 1.5 / 2.75; 1540 return 7.5625 * time1 * time1 + 0.75; 1541 } else if (time1 < 2.5 / 2.75) { 1542 time1 -= 2.25 / 2.75; 1543 return 7.5625 * time1 * time1 + 0.9375; 1544 } 1545 1546 time1 -= 2.625 / 2.75; 1547 return 7.5625 * time1 * time1 + 0.984375; 1548 }, 1549 1550 /** 1551 * to copy object with deep copy. 1552 * returns a clone of action. 1553 * 1554 * @returns {cc.EaseBounce} 1555 */ 1556 clone:function(){ 1557 var action = new cc.EaseBounce(); 1558 action.initWithAction(this._inner.clone()); 1559 return action; 1560 }, 1561 1562 /** 1563 * Create a action. Opposite with the original motion trajectory. 1564 * @return {cc.EaseBounce} 1565 */ 1566 reverse:function () { 1567 return new cc.EaseBounce(this._inner.reverse()); 1568 } 1569 }); 1570 1571 /** 1572 * Creates an ease bounce action. 1573 * @static 1574 * @deprecated since v3.0 Does not recommend the use of the base object. 1575 * @param {cc.ActionInterval} action 1576 * @return {cc.EaseBounce} 1577 */ 1578 cc.EaseBounce.create = function (action) { 1579 return new cc.EaseBounce(action); 1580 }; 1581 1582 /** 1583 * cc.EaseBounceIn action. <br /> 1584 * Eased bounce effect at the beginning. 1585 * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. 1586 * @class 1587 * @extends cc.EaseBounce 1588 * 1589 * @deprecated since v3.0 please use action.easing(cc.easeBounceIn()) 1590 * 1591 * @example 1592 * //The old usage 1593 * cc.EaseBounceIn.create(action); 1594 * //The new usage 1595 * action.easing(cc.easeBounceIn()); 1596 */ 1597 cc.EaseBounceIn = cc.EaseBounce.extend(/** @lends cc.EaseBounceIn# */{ 1598 /** 1599 * Called once per frame. Time is the number of seconds of a frame interval. 1600 * 1601 * @param {Number} dt 1602 */ 1603 update:function (dt) { 1604 var newT = 1 - this.bounceTime(1 - dt); 1605 this._inner.update(newT); 1606 }, 1607 1608 /** 1609 * Create a action. Opposite with the original motion trajectory. 1610 * @return {cc.EaseBounceOut} 1611 */ 1612 reverse:function () { 1613 return new cc.EaseBounceOut(this._inner.reverse()); 1614 }, 1615 1616 /** 1617 * to copy object with deep copy. 1618 * returns a clone of action. 1619 * 1620 * @returns {cc.EaseBounceIn} 1621 */ 1622 clone:function(){ 1623 var action = new cc.EaseBounceIn(); 1624 action.initWithAction(this._inner.clone()); 1625 return action; 1626 } 1627 }); 1628 1629 /** 1630 * Creates the action. <br /> 1631 * Eased bounce effect at the beginning. 1632 * @static 1633 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBounceIn()) 1634 * @param {cc.ActionInterval} action 1635 * @return {cc.EaseBounceIn} 1636 * 1637 * @example 1638 * //The old usage 1639 * cc.EaseBounceIn.create(action); 1640 * //The new usage 1641 * action.easing(cc.easeBounceIn()); 1642 */ 1643 cc.EaseBounceIn.create = function (action) { 1644 return new cc.EaseBounceIn(action); 1645 }; 1646 1647 cc._bounceTime = function (time1) { 1648 if (time1 < 1 / 2.75) { 1649 return 7.5625 * time1 * time1; 1650 } else if (time1 < 2 / 2.75) { 1651 time1 -= 1.5 / 2.75; 1652 return 7.5625 * time1 * time1 + 0.75; 1653 } else if (time1 < 2.5 / 2.75) { 1654 time1 -= 2.25 / 2.75; 1655 return 7.5625 * time1 * time1 + 0.9375; 1656 } 1657 1658 time1 -= 2.625 / 2.75; 1659 return 7.5625 * time1 * time1 + 0.984375; 1660 }; 1661 1662 cc._easeBounceInObj = { 1663 easing: function(dt){ 1664 return 1 - cc._bounceTime(1 - dt); 1665 }, 1666 reverse: function(){ 1667 return cc._easeBounceOutObj; 1668 } 1669 }; 1670 1671 /** 1672 * Creates the action easing object. <br /> 1673 * Eased bounce effect at the beginning. 1674 * @function 1675 * @return {Object} 1676 * @example 1677 * // example 1678 * action.easing(cc.easeBounceIn()); 1679 */ 1680 cc.easeBounceIn = function(){ 1681 return cc._easeBounceInObj; 1682 }; 1683 1684 /** 1685 * cc.EaseBounceOut action. <br /> 1686 * Eased bounce effect at the ending. 1687 * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. 1688 * @class 1689 * @extends cc.EaseBounce 1690 * 1691 * @deprecated since v3.0 please use action.easing(cc.easeBounceOut()) 1692 * 1693 * @example 1694 * //The old usage 1695 * cc.EaseBounceOut.create(action); 1696 * //The new usage 1697 * action.easing(cc.easeBounceOut()); 1698 */ 1699 cc.EaseBounceOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceOut# */{ 1700 /** 1701 * Called once per frame. Time is the number of seconds of a frame interval. 1702 * 1703 * @param {Number} dt 1704 */ 1705 update:function (dt) { 1706 var newT = this.bounceTime(dt); 1707 this._inner.update(newT); 1708 }, 1709 1710 /** 1711 * Create a action. Opposite with the original motion trajectory. 1712 * @return {cc.EaseBounceIn} 1713 */ 1714 reverse:function () { 1715 return new cc.EaseBounceIn(this._inner.reverse()); 1716 }, 1717 1718 /** 1719 * to copy object with deep copy. 1720 * returns a clone of action. 1721 * 1722 * @returns {cc.EaseBounceOut} 1723 */ 1724 clone:function(){ 1725 var action = new cc.EaseBounceOut(); 1726 action.initWithAction(this._inner.clone()); 1727 return action; 1728 } 1729 }); 1730 1731 /** 1732 * Creates the action. <br /> 1733 * Eased bounce effect at the ending. 1734 * @static 1735 * @deprecated since v3.0 please use action.easing(cc.easeBounceOut()) 1736 * @param {cc.ActionInterval} action 1737 * @return {cc.EaseBounceOut} 1738 * 1739 * @example 1740 * //The old usage 1741 * cc.EaseBounceOut.create(action); 1742 * //The new usage 1743 * action.easing(cc.easeBounceOut()); 1744 */ 1745 cc.EaseBounceOut.create = function (action) { 1746 return new cc.EaseBounceOut(action); 1747 }; 1748 1749 cc._easeBounceOutObj = { 1750 easing: function(dt){ 1751 return cc._bounceTime(dt); 1752 }, 1753 reverse:function () { 1754 return cc._easeBounceInObj; 1755 } 1756 }; 1757 1758 /** 1759 * Creates the action easing object. <br /> 1760 * Eased bounce effect at the ending. 1761 * @function 1762 * @return {Object} 1763 * @example 1764 * // example 1765 * action.easing(cc.easeBounceOut()); 1766 */ 1767 cc.easeBounceOut = function(){ 1768 return cc._easeBounceOutObj; 1769 }; 1770 1771 /** 1772 * cc.EaseBounceInOut action. <br /> 1773 * Eased bounce effect at the begining and ending. 1774 * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. 1775 * @class 1776 * @extends cc.EaseBounce 1777 * 1778 * @deprecated since v3.0 <br /> Please use acton.easing(cc.easeBounceInOut()) 1779 * 1780 * @example 1781 * //The old usage 1782 * cc.EaseBounceInOut.create(action); 1783 * //The new usage 1784 * action.easing(cc.easeBounceInOut()); 1785 */ 1786 cc.EaseBounceInOut = cc.EaseBounce.extend(/** @lends cc.EaseBounceInOut# */{ 1787 /** 1788 * Called once per frame. Time is the number of seconds of a frame interval. 1789 * 1790 * @param {Number} dt 1791 */ 1792 update:function (dt) { 1793 var newT = 0; 1794 if (dt < 0.5) { 1795 dt = dt * 2; 1796 newT = (1 - this.bounceTime(1 - dt)) * 0.5; 1797 } else { 1798 newT = this.bounceTime(dt * 2 - 1) * 0.5 + 0.5; 1799 } 1800 this._inner.update(newT); 1801 }, 1802 1803 /** 1804 * to copy object with deep copy. 1805 * returns a clone of action. 1806 * 1807 * @returns {cc.EaseBounceInOut} 1808 */ 1809 clone:function(){ 1810 var action = new cc.EaseBounceInOut(); 1811 action.initWithAction(this._inner.clone()); 1812 return action; 1813 }, 1814 1815 /** 1816 * Create a action. Opposite with the original motion trajectory. 1817 * @return {cc.EaseBounceInOut} 1818 */ 1819 reverse:function () { 1820 return new cc.EaseBounceInOut(this._inner.reverse()); 1821 } 1822 }); 1823 1824 /** 1825 * Creates the action. <br /> 1826 * Eased bounce effect at the begining and ending. 1827 * @static 1828 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBounceInOut()) 1829 * @param {cc.ActionInterval} action 1830 * @return {cc.EaseBounceInOut} 1831 * 1832 * @example 1833 * //The old usage 1834 * cc.EaseBounceInOut.create(action); 1835 * //The new usage 1836 * action.easing(cc.easeBounceInOut()); 1837 */ 1838 cc.EaseBounceInOut.create = function (action) { 1839 return new cc.EaseBounceInOut(action); 1840 }; 1841 1842 cc._easeBounceInOutObj = { 1843 easing: function (time1) { 1844 var newT; 1845 if (time1 < 0.5) { 1846 time1 = time1 * 2; 1847 newT = (1 - cc._bounceTime(1 - time1)) * 0.5; 1848 } else { 1849 newT = cc._bounceTime(time1 * 2 - 1) * 0.5 + 0.5; 1850 } 1851 return newT; 1852 }, 1853 reverse: function(){ 1854 return cc._easeBounceInOutObj; 1855 } 1856 }; 1857 1858 /** 1859 * Creates the action easing object. <br /> 1860 * Eased bounce effect at the begining and ending. 1861 * @function 1862 * @return {Object} 1863 * @example 1864 * // example 1865 * action.easing(cc.easeBounceInOut()); 1866 */ 1867 cc.easeBounceInOut = function(){ 1868 return cc._easeBounceInOutObj; 1869 }; 1870 1871 /** 1872 * cc.EaseBackIn action. <br /> 1873 * In the opposite direction to move slowly, and then accelerated to the right direction. 1874 * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. 1875 * @class 1876 * @extends cc.ActionEase 1877 * 1878 * @deprecated since v3.0 please use action.easing(cc.easeBackIn()) 1879 * 1880 * @example 1881 * //The old usage 1882 * cc.EaseBackIn.create(action); 1883 * //The new usage 1884 * action.easing(cc.easeBackIn()); 1885 */ 1886 cc.EaseBackIn = cc.ActionEase.extend(/** @lends cc.EaseBackIn# */{ 1887 /** 1888 * Called once per frame. Time is the number of seconds of a frame interval. 1889 * 1890 * @param {Number} dt 1891 */ 1892 update:function (dt) { 1893 var overshoot = 1.70158; 1894 dt = dt===0 || dt===1 ? dt : dt * dt * ((overshoot + 1) * dt - overshoot); 1895 this._inner.update(dt); 1896 }, 1897 1898 /** 1899 * Create a action. Opposite with the original motion trajectory. 1900 * @return {cc.EaseBackOut} 1901 */ 1902 reverse:function () { 1903 return new cc.EaseBackOut(this._inner.reverse()); 1904 }, 1905 1906 /** 1907 * to copy object with deep copy. 1908 * returns a clone of action. 1909 * 1910 * @returns {cc.EaseBackIn} 1911 */ 1912 clone:function(){ 1913 var action = new cc.EaseBackIn(); 1914 action.initWithAction(this._inner.clone()); 1915 return action; 1916 } 1917 }); 1918 1919 1920 /** 1921 * Creates the cc.EaseBackIn. <br /> 1922 * In the opposite direction to move slowly, and then accelerated to the right direction. 1923 * @static 1924 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBackIn()) 1925 * @param {cc.ActionInterval} action 1926 * @return {cc.EaseBackIn} 1927 * 1928 * @example 1929 * //The old usage 1930 * cc.EaseBackIn.create(action); 1931 * //The new usage 1932 * action.easing(cc.easeBackIn()); 1933 */ 1934 cc.EaseBackIn.create = function (action) { 1935 return new cc.EaseBackIn(action); 1936 }; 1937 1938 cc._easeBackInObj = { 1939 easing: function (time1) { 1940 var overshoot = 1.70158; 1941 return (time1===0 || time1===1) ? time1 : time1 * time1 * ((overshoot + 1) * time1 - overshoot); 1942 }, 1943 reverse: function(){ 1944 return cc._easeBackOutObj; 1945 } 1946 }; 1947 1948 /** 1949 * Creates the action easing object. <br /> 1950 * In the opposite direction to move slowly, and then accelerated to the right direction. 1951 * @function 1952 * @return {Object} 1953 * @example 1954 * // example 1955 * action.easing(cc.easeBackIn()); 1956 */ 1957 cc.easeBackIn = function(){ 1958 return cc._easeBackInObj; 1959 }; 1960 1961 /** 1962 * cc.EaseBackOut action. <br /> 1963 * Fast moving more than the finish, and then slowly back to the finish. 1964 * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. 1965 * @class 1966 * @extends cc.ActionEase 1967 * 1968 * @deprecated since v3.0 please use action.easing(cc.easeBackOut()); 1969 * 1970 * @example 1971 * //The old usage 1972 * cc.EaseBackOut.create(action); 1973 * //The new usage 1974 * action.easing(cc.easeBackOut()); 1975 */ 1976 cc.EaseBackOut = cc.ActionEase.extend(/** @lends cc.EaseBackOut# */{ 1977 /** 1978 * Called once per frame. Time is the number of seconds of a frame interval. 1979 * 1980 * @param {Number} dt 1981 */ 1982 update:function (dt) { 1983 var overshoot = 1.70158; 1984 dt = dt - 1; 1985 this._inner.update(dt * dt * ((overshoot + 1) * dt + overshoot) + 1); 1986 }, 1987 1988 /** 1989 * Create a action. Opposite with the original motion trajectory. 1990 * @return {cc.EaseBackIn} 1991 */ 1992 reverse:function () { 1993 return new cc.EaseBackIn(this._inner.reverse()); 1994 }, 1995 1996 /** 1997 * to copy object with deep copy. 1998 * returns a clone of action. 1999 * 2000 * @returns {cc.EaseBackOut} 2001 */ 2002 clone:function(){ 2003 var action = new cc.EaseBackOut(); 2004 action.initWithAction(this._inner.clone()); 2005 return action; 2006 } 2007 }); 2008 2009 /** 2010 * Creates the action. <br /> 2011 * Fast moving more than the finish, and then slowly back to the finish. 2012 * @static 2013 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBackOut()); 2014 * @param {cc.ActionInterval} action 2015 * @return {cc.EaseBackOut} 2016 * 2017 * @example 2018 * //The old usage 2019 * cc.EaseBackOut.create(action); 2020 * //The new usage 2021 * action.easing(cc.easeBackOut()); 2022 */ 2023 cc.EaseBackOut.create = function (action) { 2024 return new cc.EaseBackOut(action); 2025 }; 2026 2027 cc._easeBackOutObj = { 2028 easing: function (time1) { 2029 var overshoot = 1.70158; 2030 time1 = time1 - 1; 2031 return time1 * time1 * ((overshoot + 1) * time1 + overshoot) + 1; 2032 }, 2033 reverse: function(){ 2034 return cc._easeBackInObj; 2035 } 2036 }; 2037 2038 /** 2039 * Creates the action easing object. <br /> 2040 * Fast moving more than the finish, and then slowly back to the finish. 2041 * @function 2042 * @return {Object} 2043 * @example 2044 * // example 2045 * action.easing(cc.easeBackOut()); 2046 */ 2047 cc.easeBackOut = function(){ 2048 return cc._easeBackOutObj; 2049 }; 2050 2051 /** 2052 * cc.EaseBackInOut action. <br /> 2053 * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. 2054 * @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. 2055 * @class 2056 * @extends cc.ActionEase 2057 * 2058 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBackInOut()) 2059 * 2060 * @example 2061 * //The old usage 2062 * cc.EaseBackInOut.create(action); 2063 * //The new usage 2064 * action.easing(cc.easeBackInOut()); 2065 */ 2066 cc.EaseBackInOut = cc.ActionEase.extend(/** @lends cc.EaseBackInOut# */{ 2067 /** 2068 * Called once per frame. Time is the number of seconds of a frame interval. 2069 * 2070 * @param {Number} dt 2071 */ 2072 update:function (dt) { 2073 var overshoot = 1.70158 * 1.525; 2074 dt = dt * 2; 2075 if (dt < 1) { 2076 this._inner.update((dt * dt * ((overshoot + 1) * dt - overshoot)) / 2); 2077 } else { 2078 dt = dt - 2; 2079 this._inner.update((dt * dt * ((overshoot + 1) * dt + overshoot)) / 2 + 1); 2080 } 2081 }, 2082 2083 /** 2084 * to copy object with deep copy. 2085 * returns a clone of action. 2086 * 2087 * @returns {cc.EaseBackInOut} 2088 */ 2089 clone:function(){ 2090 var action = new cc.EaseBackInOut(); 2091 action.initWithAction(this._inner.clone()); 2092 return action; 2093 }, 2094 2095 /** 2096 * Create a action. Opposite with the original motion trajectory. 2097 * @return {cc.EaseBackInOut} 2098 */ 2099 reverse:function () { 2100 return new cc.EaseBackInOut(this._inner.reverse()); 2101 } 2102 }); 2103 2104 2105 /** 2106 * Creates the action. <br /> 2107 * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. 2108 * @static 2109 * @param {cc.ActionInterval} action 2110 * @return {cc.EaseBackInOut} 2111 * 2112 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBackInOut()) 2113 * 2114 * @example 2115 * //The old usage 2116 * cc.EaseBackInOut.create(action); 2117 * //The new usage 2118 * action.easing(cc.easeBackInOut()); 2119 */ 2120 cc.EaseBackInOut.create = function (action) { 2121 return new cc.EaseBackInOut(action); 2122 }; 2123 2124 cc._easeBackInOutObj = { 2125 easing: function (time1) { 2126 var overshoot = 1.70158 * 1.525; 2127 time1 = time1 * 2; 2128 if (time1 < 1) { 2129 return (time1 * time1 * ((overshoot + 1) * time1 - overshoot)) / 2; 2130 } else { 2131 time1 = time1 - 2; 2132 return (time1 * time1 * ((overshoot + 1) * time1 + overshoot)) / 2 + 1; 2133 } 2134 }, 2135 reverse: function(){ 2136 return cc._easeBackInOutObj; 2137 } 2138 }; 2139 2140 /** 2141 * Creates the action easing object. <br /> 2142 * Begining of cc.EaseBackIn. Ending of cc.EaseBackOut. 2143 * @function 2144 * @return {Object} 2145 * @example 2146 * // example 2147 * action.easing(cc.easeBackInOut()); 2148 */ 2149 cc.easeBackInOut = function(){ 2150 return cc._easeBackInOutObj; 2151 }; 2152 2153 /** 2154 * cc.EaseBezierAction action. <br /> 2155 * Manually set a 4 order Bessel curve. <br /> 2156 * According to the set point, calculate the trajectory. 2157 * @class 2158 * @extends cc.ActionEase 2159 * @param {cc.Action} action 2160 * 2161 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBezierAction()) 2162 * 2163 * @example 2164 * //The old usage 2165 * var action = cc.EaseBezierAction.create(action); 2166 * action.setBezierParamer(0.5, 0.5, 1.0, 1.0); 2167 * //The new usage 2168 * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); 2169 */ 2170 cc.EaseBezierAction = cc.ActionEase.extend(/** @lends cc.EaseBezierAction# */{ 2171 2172 _p0: null, 2173 _p1: null, 2174 _p2: null, 2175 _p3: null, 2176 2177 /** 2178 * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function. <br /> 2179 * Initialization requires the application of Bessel curve of action. 2180 * @param {cc.Action} action 2181 */ 2182 ctor: function(action){ 2183 cc.ActionEase.prototype.ctor.call(this, action); 2184 }, 2185 2186 _updateTime: function(a, b, c, d, t){ 2187 return (Math.pow(1-t,3) * a + 3*t*(Math.pow(1-t,2))*b + 3*Math.pow(t,2)*(1-t)*c + Math.pow(t,3)*d ); 2188 }, 2189 2190 /** 2191 * Called once per frame. Time is the number of seconds of a frame interval. 2192 * 2193 * @param {Number} dt 2194 */ 2195 update: function(dt){ 2196 var t = this._updateTime(this._p0, this._p1, this._p2, this._p3, dt); 2197 this._inner.update(t); 2198 }, 2199 2200 /** 2201 * to copy object with deep copy. 2202 * returns a clone of action. 2203 * 2204 * @returns {cc.EaseBezierAction} 2205 */ 2206 clone: function(){ 2207 var action = new cc.EaseBezierAction(); 2208 action.initWithAction(this._inner.clone()); 2209 action.setBezierParamer(this._p0, this._p1, this._p2, this._p3); 2210 return action; 2211 }, 2212 2213 /** 2214 * Create a action. Opposite with the original motion trajectory. 2215 * @return {cc.EaseBezierAction} 2216 */ 2217 reverse: function(){ 2218 var action = new cc.EaseBezierAction(this._inner.reverse()); 2219 action.setBezierParamer(this._p3, this._p2, this._p1, this._p0); 2220 return action; 2221 }, 2222 2223 /** 2224 * Set of 4 reference point 2225 * @param p0 2226 * @param p1 2227 * @param p2 2228 * @param p3 2229 */ 2230 setBezierParamer: function(p0, p1, p2, p3){ 2231 this._p0 = p0 || 0; 2232 this._p1 = p1 || 0; 2233 this._p2 = p2 || 0; 2234 this._p3 = p3 || 0; 2235 } 2236 }); 2237 2238 /** 2239 * Creates the action. <br /> 2240 * After creating the cc.EaseBezierAction, also need to manually call setBezierParamer. <br /> 2241 * According to the set point, calculate the trajectory. 2242 * @static 2243 * @param action 2244 * @returns {cc.EaseBezierAction} 2245 * 2246 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeBezierAction()) 2247 * 2248 * @example 2249 * //The old usage 2250 * var action = cc.EaseBezierAction.create(action); 2251 * action.setBezierParamer(0.5, 0.5, 1.0, 1.0); 2252 * //The new usage 2253 * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); 2254 */ 2255 cc.EaseBezierAction.create = function(action){ 2256 return new cc.EaseBezierAction(action); 2257 }; 2258 2259 /** 2260 * Creates the action easing object. <br /> 2261 * Into the 4 reference point. <br /> 2262 * To calculate the motion curve. 2263 * @param {Number} p0 The first bezier parameter 2264 * @param {Number} p1 The second bezier parameter 2265 * @param {Number} p2 The third bezier parameter 2266 * @param {Number} p3 The fourth bezier parameter 2267 * @returns {Object} 2268 * @example 2269 * // example 2270 * action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0)); 2271 */ 2272 cc.easeBezierAction = function(p0, p1, p2, p3){ 2273 return { 2274 easing: function(time){ 2275 return cc.EaseBezierAction.prototype._updateTime(p0, p1, p2, p3, time); 2276 }, 2277 reverse: function(){ 2278 return cc.easeBezierAction(p3, p2, p1, p0); 2279 } 2280 }; 2281 }; 2282 2283 /** 2284 * cc.EaseQuadraticActionIn action. <br /> 2285 * Reference easeInQuad: <br /> 2286 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2287 * @class 2288 * @extends cc.ActionEase 2289 * 2290 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticAction()) 2291 * 2292 * @example 2293 * //The old usage 2294 * cc.EaseQuadraticActionIn.create(action); 2295 * //The new usage 2296 * action.easing(cc.easeQuadraticActionIn()); 2297 */ 2298 cc.EaseQuadraticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionIn# */{ 2299 2300 _updateTime: function(time){ 2301 return Math.pow(time, 2); 2302 }, 2303 2304 /** 2305 * Called once per frame. Time is the number of seconds of a frame interval. 2306 * 2307 * @param {Number} dt 2308 */ 2309 update: function(dt){ 2310 this._inner.update(this._updateTime(dt)); 2311 }, 2312 2313 /** 2314 * to copy object with deep copy. 2315 * returns a clone of action. 2316 * 2317 * @returns {cc.EaseQuadraticActionIn} 2318 */ 2319 clone: function(){ 2320 var action = new cc.EaseQuadraticActionIn(); 2321 action.initWithAction(this._inner.clone()); 2322 return action; 2323 }, 2324 2325 /** 2326 * Create a action. Opposite with the original motion trajectory. 2327 * @return {cc.EaseQuadraticActionIn} 2328 */ 2329 reverse: function(){ 2330 return new cc.EaseQuadraticActionIn(this._inner.reverse()); 2331 } 2332 2333 }); 2334 2335 /** 2336 * Creates the cc.EaseQuadRaticActionIn. <br /> 2337 * Reference easeInQuad: <br /> 2338 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2339 * @static 2340 * @param action 2341 * @returns {cc.EaseQuadraticActionIn} 2342 * 2343 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticAction()) 2344 * 2345 * @example 2346 * //The old usage 2347 * cc.EaseQuadraticActionIn.create(action); 2348 * //The new usage 2349 * action.easing(cc.easeQuadraticActionIn()); 2350 */ 2351 cc.EaseQuadraticActionIn.create = function(action){ 2352 return new cc.EaseQuadraticActionIn(action); 2353 }; 2354 2355 cc._easeQuadraticActionIn = { 2356 easing: cc.EaseQuadraticActionIn.prototype._updateTime, 2357 reverse: function(){ 2358 return cc._easeQuadraticActionIn; 2359 } 2360 }; 2361 2362 /** 2363 * Creates the action easing object. <br /> 2364 * Reference easeInQuad: <br /> 2365 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2366 * @returns {Object} 2367 * @example 2368 * //example 2369 * action.easing(cc.easeQuadraticActionIn()); 2370 */ 2371 cc.easeQuadraticActionIn = function(){ 2372 return cc._easeQuadraticActionIn; 2373 }; 2374 2375 /** 2376 * cc.EaseQuadraticActionIn action. <br /> 2377 * Reference easeOutQuad: <br /> 2378 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2379 * @class 2380 * @extends cc.ActionEase 2381 * 2382 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionOut()) 2383 * 2384 * @example 2385 * //The old usage 2386 * cc.EaseQuadraticActionOut.create(action); 2387 * //The new usage 2388 * action.easing(cc.easeQuadraticActionOut()); 2389 */ 2390 cc.EaseQuadraticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionOut# */{ 2391 2392 _updateTime: function(time){ 2393 return -time*(time-2); 2394 }, 2395 2396 /** 2397 * Called once per frame. Time is the number of seconds of a frame interval. 2398 * 2399 * @param {Number} dt 2400 */ 2401 update: function(dt){ 2402 this._inner.update(this._updateTime(dt)); 2403 }, 2404 2405 /** 2406 * to copy object with deep copy. 2407 * returns a clone of action. 2408 * 2409 * @returns {cc.EaseQuadraticActionOut} 2410 */ 2411 clone: function(){ 2412 var action = new cc.EaseQuadraticActionOut(); 2413 action.initWithAction(); 2414 return action; 2415 }, 2416 2417 /** 2418 * Create a action. Opposite with the original motion trajectory. 2419 * @return {cc.EaseQuadraticActionOut} 2420 */ 2421 reverse: function(){ 2422 return new cc.EaseQuadraticActionOut(this._inner.reverse()); 2423 } 2424 }); 2425 2426 /** 2427 * Creates the action. <br /> 2428 * Reference easeOutQuad: <br /> 2429 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2430 * @static 2431 * @param action 2432 * @returns {cc.EaseQuadraticActionOut} 2433 * 2434 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionOut()) 2435 * 2436 * @example 2437 * //The old usage 2438 * cc.EaseQuadraticActionOut.create(action); 2439 * //The new usage 2440 * action.easing(cc.easeQuadraticActionOut()); 2441 */ 2442 cc.EaseQuadraticActionOut.create = function(action){ 2443 return new cc.EaseQuadraticActionOut(action); 2444 }; 2445 2446 cc._easeQuadraticActionOut = { 2447 easing: cc.EaseQuadraticActionOut.prototype._updateTime, 2448 reverse: function(){ 2449 return cc._easeQuadraticActionOut; 2450 } 2451 }; 2452 /** 2453 * Creates the action easing object. <br /> 2454 * Reference easeOutQuad: <br /> 2455 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2456 * @function 2457 * @returns {Object} 2458 * @example 2459 * //example 2460 * action.easing(cc.easeQuadraticActionOut()); 2461 */ 2462 cc.easeQuadraticActionOut = function(){ 2463 return cc._easeQuadraticActionOut; 2464 }; 2465 2466 /** 2467 * cc.EaseQuadraticActionInOut action. <br /> 2468 * Reference easeInOutQuad: <br /> 2469 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2470 * @class 2471 * @extends cc.ActionEase 2472 * 2473 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionInOut()) 2474 * 2475 * @example 2476 * //The old usage 2477 * cc.EaseQuadraticActionInOut.create(action); 2478 * //The new usage 2479 * action.easing(cc.easeQuadraticActionInOut()); 2480 */ 2481 cc.EaseQuadraticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuadraticActionInOut# */{ 2482 _updateTime: function(time){ 2483 var resultTime = time; 2484 time *= 2; 2485 if(time < 1){ 2486 resultTime = time * time * 0.5; 2487 }else{ 2488 --time; 2489 resultTime = -0.5 * ( time * ( time - 2 ) - 1) 2490 } 2491 return resultTime; 2492 }, 2493 2494 /** 2495 * Called once per frame. Time is the number of seconds of a frame interval. 2496 * 2497 * @param {Number} dt 2498 */ 2499 update: function(dt){ 2500 this._inner.update(this._updateTime(dt)); 2501 }, 2502 2503 /** 2504 * to copy object with deep copy. 2505 * returns a clone of action. 2506 * 2507 * @returns {cc.EaseQuadraticActionInOut} 2508 */ 2509 clone: function(){ 2510 var action = new cc.EaseQuadraticActionInOut(); 2511 action.initWithAction(this._inner.clone()); 2512 return action; 2513 }, 2514 2515 /** 2516 * Create a action. Opposite with the original motion trajectory. 2517 * @return {cc.EaseQuadraticActionInOut} 2518 */ 2519 reverse: function(){ 2520 return new cc.EaseQuadraticActionInOut(this._inner.reverse()); 2521 } 2522 }); 2523 2524 /** 2525 * Creates the action. <br /> 2526 * Reference easeInOutQuad: <br /> 2527 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2528 * @static 2529 * 2530 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionInOut()) 2531 * 2532 * @example 2533 * //The old usage 2534 * cc.EaseQuadraticActionInOut.create(action); 2535 * //The new usage 2536 * action.easing(cc.easeQuadraticActionInOut()); 2537 * 2538 * @param action 2539 * @returns {cc.EaseQuadraticActionInOut} 2540 */ 2541 cc.EaseQuadraticActionInOut.create = function(action){ 2542 return new cc.EaseQuadraticActionInOut(action); 2543 }; 2544 2545 cc._easeQuadraticActionInOut = { 2546 easing: cc.EaseQuadraticActionInOut.prototype._updateTime, 2547 reverse: function(){ 2548 return cc._easeQuadraticActionInOut; 2549 } 2550 }; 2551 2552 /** 2553 * Creates the action easing object. <br /> 2554 * Reference easeInOutQuad: <br /> 2555 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2556 * @function 2557 * @returns {Object} 2558 * @example 2559 * //example 2560 * action.easing(cc.easeQuadraticActionInOut()); 2561 */ 2562 cc.easeQuadraticActionInOut = function(){ 2563 return cc._easeQuadraticActionInOut; 2564 }; 2565 2566 /** 2567 * cc.EaseQuarticActionIn action. <br /> 2568 * Reference easeInQuart: <br /> 2569 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2570 * @class 2571 * @extends cc.ActionEase 2572 * 2573 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuarticActionIn()); 2574 * 2575 * @example 2576 * //The old usage 2577 * cc.EaseQuarticActionIn.create(action); 2578 * //The new usage 2579 * action.easing(cc.easeQuarticActionIn()); 2580 */ 2581 cc.EaseQuarticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionIn# */{ 2582 _updateTime: function(time){ 2583 return time * time * time * time; 2584 }, 2585 2586 /** 2587 * Called once per frame. Time is the number of seconds of a frame interval. 2588 * 2589 * @param {Number} dt 2590 */ 2591 update: function(dt){ 2592 this._inner.update(this._updateTime(dt)); 2593 }, 2594 2595 /** 2596 * to copy object with deep copy. 2597 * returns a clone of action. 2598 * 2599 * @returns {cc.EaseQuarticActionIn} 2600 */ 2601 clone: function(){ 2602 var action = new cc.EaseQuarticActionIn(); 2603 action.initWithAction(this._inner.clone()); 2604 return action; 2605 }, 2606 2607 /** 2608 * Create a action. Opposite with the original motion trajectory. 2609 * @return {cc.EaseQuarticActionIn} 2610 */ 2611 reverse: function(){ 2612 return new cc.EaseQuarticActionIn(this._inner.reverse()); 2613 } 2614 }); 2615 2616 /** 2617 * Creates the action. <br /> 2618 * Reference easeInQuart: <br /> 2619 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2620 * @static 2621 * 2622 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuarticActionIn()); 2623 * 2624 * @example 2625 * //The old usage 2626 * cc.EaseQuarticActionIn.create(action); 2627 * //The new usage 2628 * action.easing(cc.easeQuarticActionIn()); 2629 * 2630 * @param action 2631 * @returns {cc.EaseQuarticActionIn} 2632 */ 2633 cc.EaseQuarticActionIn.create = function(action){ 2634 return new cc.EaseQuarticActionIn(action); 2635 }; 2636 2637 cc._easeQuarticActionIn = { 2638 easing: cc.EaseQuarticActionIn.prototype._updateTime, 2639 reverse: function(){ 2640 return cc._easeQuarticActionIn; 2641 } 2642 }; 2643 /** 2644 * Creates the action easing object. <br /> 2645 * Reference easeIntQuart: <br /> 2646 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2647 * @function 2648 * @returns {Object} 2649 * @example 2650 * //example 2651 * action.easing(cc.easeQuarticActionIn()); 2652 */ 2653 cc.easeQuarticActionIn = function(){ 2654 return cc._easeQuarticActionIn; 2655 }; 2656 2657 /** 2658 * cc.EaseQuarticActionOut action. <br /> 2659 * Reference easeOutQuart: <br /> 2660 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2661 * @class 2662 * @extends cc.ActionEase 2663 * 2664 * @deprecated since v3.0 <br /> Please use action.easing(cc.QuarticActionOut()); 2665 * 2666 * @example 2667 * //The old usage 2668 * cc.EaseQuarticActionOut.create(action); 2669 * //The new usage 2670 * action.easing(cc.EaseQuarticActionOut()); 2671 */ 2672 cc.EaseQuarticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionOut# */{ 2673 _updateTime: function(time){ 2674 time -= 1; 2675 return -(time * time * time * time - 1); 2676 }, 2677 2678 /** 2679 * Called once per frame. Time is the number of seconds of a frame interval. 2680 * 2681 * @param {Number} dt 2682 */ 2683 update: function(dt){ 2684 this._inner.update(this._updateTime(dt)); 2685 }, 2686 2687 /** 2688 * to copy object with deep copy. 2689 * returns a clone of action. 2690 * 2691 * @returns {cc.EaseQuarticActionOut} 2692 */ 2693 clone: function(){ 2694 var action = new cc.EaseQuarticActionOut(); 2695 action.initWithAction(this._inner.clone()); 2696 return action; 2697 }, 2698 2699 /** 2700 * Create a action. Opposite with the original motion trajectory. 2701 * @return {cc.EaseQuarticActionOut} 2702 */ 2703 reverse: function(){ 2704 return new cc.EaseQuarticActionOut(this._inner.reverse()); 2705 } 2706 }); 2707 2708 /** 2709 * Creates the action. <br /> 2710 * Reference easeOutQuart: <br /> 2711 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2712 * @static 2713 * 2714 * @deprecated since v3.0 <br /> Please use action.easing(cc.QuarticActionOut()); 2715 * 2716 * @example 2717 * //The old usage 2718 * cc.EaseQuarticActionOut.create(action); 2719 * //The new usage 2720 * action.easing(cc.EaseQuarticActionOut()); 2721 * 2722 * @param action 2723 * @returns {cc.EaseQuarticActionOut} 2724 */ 2725 cc.EaseQuarticActionOut.create = function(action){ 2726 return new cc.EaseQuarticActionOut(action); 2727 }; 2728 2729 cc._easeQuarticActionOut = { 2730 easing: cc.EaseQuarticActionOut.prototype._updateTime, 2731 reverse: function(){ 2732 return cc._easeQuarticActionOut; 2733 } 2734 }; 2735 2736 /** 2737 * Creates the action easing object. <br /> 2738 * Reference easeOutQuart: <br /> 2739 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2740 * @function 2741 * @returns {Object} 2742 * @example 2743 * //example 2744 * action.easing(cc.QuarticActionOut()); 2745 */ 2746 cc.easeQuarticActionOut = function(){ 2747 return cc._easeQuarticActionOut; 2748 }; 2749 2750 /** 2751 * cc.EaseQuarticActionInOut action. <br /> 2752 * Reference easeInOutQuart: <br /> 2753 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2754 * @class 2755 * @extends cc.ActionEase 2756 * 2757 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuarticActionInOut()); 2758 * 2759 * @example 2760 * //The old usage 2761 * cc.EaseQuarticActionInOut.create(action); 2762 * //The new usage 2763 * action.easing(cc.easeQuarticActionInOut()); 2764 */ 2765 cc.EaseQuarticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuarticActionInOut# */{ 2766 _updateTime: function(time){ 2767 time = time*2; 2768 if (time < 1) 2769 return 0.5 * time * time * time * time; 2770 time -= 2; 2771 return -0.5 * (time * time * time * time - 2); 2772 }, 2773 2774 /** 2775 * Called once per frame. Time is the number of seconds of a frame interval. 2776 * 2777 * @param {Number} dt 2778 */ 2779 update: function(dt){ 2780 this._inner.update(this._updateTime(dt)); 2781 }, 2782 2783 /** 2784 * to copy object with deep copy. 2785 * returns a clone of action. 2786 * 2787 * @returns {cc.EaseQuarticActionInOut} 2788 */ 2789 clone: function(){ 2790 var action = new cc.EaseQuarticActionInOut(); 2791 action.initWithAction(this._inner.clone()); 2792 return action; 2793 }, 2794 2795 /** 2796 * Create a action. Opposite with the original motion trajectory. 2797 * @return {cc.EaseQuarticActionInOut} 2798 */ 2799 reverse: function(){ 2800 return new cc.EaseQuarticActionInOut(this._inner.reverse()); 2801 } 2802 }); 2803 2804 /** 2805 * Creates the action. <br /> 2806 * Reference easeInOutQuart: <br /> 2807 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2808 * @static 2809 * 2810 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuarticActionInOut()); 2811 * 2812 * @example 2813 * //The old usage 2814 * cc.EaseQuarticActionInOut.create(action); 2815 * //The new usage 2816 * action.easing(cc.easeQuarticActionInOut()); 2817 * 2818 * @param action 2819 * @returns {cc.EaseQuarticActionInOut} 2820 */ 2821 cc.EaseQuarticActionInOut.create = function(action){ 2822 return new cc.EaseQuarticActionInOut(action); 2823 }; 2824 2825 cc._easeQuarticActionInOut = { 2826 easing: cc.EaseQuarticActionInOut.prototype._updateTime, 2827 reverse: function(){ 2828 return cc._easeQuarticActionInOut; 2829 } 2830 }; 2831 /** 2832 * Creates the action easing object. <br /> 2833 * Reference easeInOutQuart: <br /> 2834 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2835 * @function 2836 * @returns {Object} 2837 */ 2838 cc.easeQuarticActionInOut = function(){ 2839 return cc._easeQuarticActionInOut; 2840 }; 2841 2842 /** 2843 * cc.EaseQuinticActionIn action. <br /> 2844 * Reference easeInQuint: <br /> 2845 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2846 * @class 2847 * @extends cc.ActionEase 2848 * 2849 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuinticActionIn()); 2850 * 2851 * @example 2852 * //The old usage 2853 * cc.EaseQuinticActionIn.create(action); 2854 * //The new usage 2855 * action.easing(cc.easeQuinticActionIn()); 2856 */ 2857 cc.EaseQuinticActionIn = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionIn# */{ 2858 _updateTime: function(time){ 2859 return time * time * time * time * time; 2860 }, 2861 2862 /** 2863 * Called once per frame. Time is the number of seconds of a frame interval. 2864 * 2865 * @param {Number} dt 2866 */ 2867 update: function(dt){ 2868 this._inner.update(this._updateTime(dt)); 2869 }, 2870 2871 /** 2872 * to copy object with deep copy. 2873 * returns a clone of action. 2874 * 2875 * @returns {cc.EaseQuinticActionIn} 2876 */ 2877 clone: function(){ 2878 var action = new cc.EaseQuinticActionIn(); 2879 action.initWithAction(this._inner.clone()); 2880 return action; 2881 }, 2882 2883 /** 2884 * Create a action. Opposite with the original motion trajectory. 2885 * @return {cc.EaseQuinticActionIn} 2886 */ 2887 reverse: function(){ 2888 return new cc.EaseQuinticActionIn(this._inner.reverse()); 2889 } 2890 }); 2891 2892 /** 2893 * Creates the action. <br /> 2894 * Reference easeInQuint: <br /> 2895 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2896 * @static 2897 * 2898 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuinticActionIn()); 2899 * 2900 * @example 2901 * //The old usage 2902 * cc.EaseQuinticActionIn.create(action); 2903 * //The new usage 2904 * action.easing(cc.easeQuinticActionIn()); 2905 * 2906 * @param action 2907 * @returns {cc.EaseQuinticActionIn} 2908 */ 2909 cc.EaseQuinticActionIn.create = function(action){ 2910 return new cc.EaseQuinticActionIn(action); 2911 }; 2912 2913 cc._easeQuinticActionIn = { 2914 easing: cc.EaseQuinticActionIn.prototype._updateTime, 2915 reverse: function(){ 2916 return cc._easeQuinticActionIn; 2917 } 2918 }; 2919 2920 /** 2921 * Creates the action easing object. <br /> 2922 * Reference easeInQuint: <br /> 2923 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2924 * @function 2925 * @returns {Object} 2926 * @example 2927 * //example 2928 * action.easing(cc.easeQuinticActionIn()); 2929 */ 2930 cc.easeQuinticActionIn = function(){ 2931 return cc._easeQuinticActionIn; 2932 }; 2933 2934 /** 2935 * cc.EaseQuinticActionOut action. <br /> 2936 * Reference easeQuint: <br /> 2937 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2938 * @class 2939 * @extends cc.ActionEase 2940 * 2941 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionOut()); 2942 * 2943 * @example 2944 * //The old usage 2945 * cc.EaseQuinticActionOut.create(action); 2946 * //The new usage 2947 * action.easing(cc.easeQuadraticActionOut()); 2948 */ 2949 cc.EaseQuinticActionOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionOut# */{ 2950 _updateTime: function(time){ 2951 time -=1; 2952 return (time * time * time * time * time + 1); 2953 }, 2954 2955 /** 2956 * Called once per frame. Time is the number of seconds of a frame interval. 2957 * 2958 * @param {Number} dt 2959 */ 2960 update: function(dt){ 2961 this._inner.update(this._updateTime(dt)); 2962 }, 2963 2964 /** 2965 * to copy object with deep copy. 2966 * returns a clone of action. 2967 * 2968 * @returns {cc.EaseQuinticActionOut} 2969 */ 2970 clone: function(){ 2971 var action = new cc.EaseQuinticActionOut(); 2972 action.initWithAction(this._inner.clone()); 2973 return action; 2974 }, 2975 2976 /** 2977 * Create a action. Opposite with the original motion trajectory. 2978 * @return {cc.EaseQuinticActionOut} 2979 */ 2980 reverse: function(){ 2981 return new cc.EaseQuinticActionOut(this._inner.reverse()); 2982 } 2983 }); 2984 2985 /** 2986 * Creates the action. <br /> 2987 * Reference easeOutQuint: <br /> 2988 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 2989 * @static 2990 * 2991 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuadraticActionOut()); 2992 * 2993 * @example 2994 * //The old usage 2995 * cc.EaseQuinticActionOut.create(action); 2996 * //The new usage 2997 * action.easing(cc.easeQuadraticActionOut()); 2998 * 2999 * @param action 3000 * @returns {cc.EaseQuinticActionOut} 3001 */ 3002 cc.EaseQuinticActionOut.create = function(action){ 3003 return new cc.EaseQuinticActionOut(action); 3004 }; 3005 3006 cc._easeQuinticActionOut = { 3007 easing: cc.EaseQuinticActionOut.prototype._updateTime, 3008 reverse: function(){ 3009 return cc._easeQuinticActionOut; 3010 } 3011 }; 3012 3013 /** 3014 * Creates the action easing object. <br /> 3015 * Reference easeOutQuint: <br /> 3016 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3017 * @function 3018 * @returns {Object} 3019 * @example 3020 * //example 3021 * action.easing(cc.easeQuadraticActionOut()); 3022 */ 3023 cc.easeQuinticActionOut = function(){ 3024 return cc._easeQuinticActionOut; 3025 }; 3026 3027 /** 3028 * cc.EaseQuinticActionInOut action. <br /> 3029 * Reference easeInOutQuint: <br /> 3030 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3031 * @class 3032 * @extends cc.ActionEase 3033 * 3034 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuinticActionInOut()); 3035 * 3036 * @example 3037 * //The old usage 3038 * cc.EaseQuinticActionInOut.create(action); 3039 * //The new usage 3040 * action.easing(cc.easeQuinticActionInOut()); 3041 */ 3042 cc.EaseQuinticActionInOut = cc.ActionEase.extend(/** @lends cc.EaseQuinticActionInOut# */{ 3043 _updateTime: function(time){ 3044 time = time*2; 3045 if (time < 1) 3046 return 0.5 * time * time * time * time * time; 3047 time -= 2; 3048 return 0.5 * (time * time * time * time * time + 2); 3049 }, 3050 3051 /** 3052 * Called once per frame. Time is the number of seconds of a frame interval. 3053 * 3054 * @param {Number} dt 3055 */ 3056 update: function(dt){ 3057 this._inner.update(this._updateTime(dt)); 3058 }, 3059 3060 /** 3061 * to copy object with deep copy. 3062 * returns a clone of action. 3063 * 3064 * @returns {cc.EaseQuinticActionInOut} 3065 */ 3066 clone: function(){ 3067 var action = new cc.EaseQuinticActionInOut(); 3068 action.initWithAction(this._inner.clone()); 3069 return action; 3070 }, 3071 3072 /** 3073 * Create a action. Opposite with the original motion trajectory. 3074 * @return {cc.EaseQuinticActionInOut} 3075 */ 3076 reverse: function(){ 3077 return new cc.EaseQuinticActionInOut(this._inner.reverse()); 3078 } 3079 }); 3080 3081 /** 3082 * Creates the action. <br /> 3083 * Reference easeInOutQuint: <br /> 3084 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3085 * @static 3086 * 3087 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeQuinticActionInOut()); 3088 * 3089 * @example 3090 * //The old usage 3091 * cc.EaseQuinticActionInOut.create(action); 3092 * //The new usage 3093 * action.easing(cc.easeQuinticActionInOut()); 3094 * 3095 * @param action 3096 * @returns {cc.EaseQuinticActionInOut} 3097 */ 3098 cc.EaseQuinticActionInOut.create = function(action){ 3099 return new cc.EaseQuinticActionInOut(action); 3100 }; 3101 3102 cc._easeQuinticActionInOut = { 3103 easing: cc.EaseQuinticActionInOut.prototype._updateTime, 3104 reverse: function(){ 3105 return cc._easeQuinticActionInOut; 3106 } 3107 }; 3108 3109 /** 3110 * Creates the action easing object. <br /> 3111 * Reference easeInOutQuint: <br /> 3112 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3113 * @function 3114 * @returns {Object} 3115 * @example 3116 * //example 3117 * action.easing(cc.easeQuinticActionInOut()); 3118 */ 3119 cc.easeQuinticActionInOut = function(){ 3120 return cc._easeQuinticActionInOut; 3121 }; 3122 3123 /** 3124 * cc.EaseCircleActionIn action. <br /> 3125 * Reference easeInCirc: <br /> 3126 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3127 * @class 3128 * @extends cc.ActionEase 3129 * 3130 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionIn()); 3131 * 3132 * @example 3133 * //The old usage 3134 * cc.EaseCircleActionIn.create(action); 3135 * //The new usage 3136 * action.easing(cc.easeCircleActionIn()); 3137 */ 3138 cc.EaseCircleActionIn = cc.ActionEase.extend(/** @lends cc.EaseCircleActionIn# */{ 3139 _updateTime: function(time){ 3140 return -1 * (Math.sqrt(1 - time * time) - 1); 3141 }, 3142 3143 /** 3144 * Called once per frame. Time is the number of seconds of a frame interval. 3145 * 3146 * @param {Number} dt 3147 */ 3148 update: function(dt){ 3149 this._inner.update(this._updateTime(dt)); 3150 }, 3151 3152 /** 3153 * to copy object with deep copy. 3154 * returns a clone of action. 3155 * 3156 * @returns {cc.EaseCircleActionIn} 3157 */ 3158 clone: function(){ 3159 var action = new cc.EaseCircleActionIn(); 3160 action.initWithAction(this._inner.clone()); 3161 return action; 3162 }, 3163 3164 /** 3165 * Create a action. Opposite with the original motion trajectory. 3166 * @return {cc.EaseCircleActionIn} 3167 */ 3168 reverse: function(){ 3169 return new cc.EaseCircleActionIn(this._inner.reverse()); 3170 } 3171 }); 3172 3173 /** 3174 * Creates the action. <br /> 3175 * Reference easeInCirc: <br /> 3176 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3177 * @static 3178 * 3179 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionIn()); 3180 * 3181 * @example 3182 * //The old usage 3183 * cc.EaseCircleActionIn.create(action); 3184 * //The new usage 3185 * action.easing(cc.easeCircleActionIn()); 3186 * 3187 * @param action 3188 * @returns {cc.EaseCircleActionIn} 3189 */ 3190 cc.EaseCircleActionIn.create = function(action){ 3191 return new cc.EaseCircleActionIn(action); 3192 }; 3193 3194 cc._easeCircleActionIn = { 3195 easing: cc.EaseCircleActionIn.prototype._updateTime, 3196 reverse: function(){ 3197 return cc._easeCircleActionIn; 3198 } 3199 }; 3200 3201 /** 3202 * Creates the action easing object. <br /> 3203 * Reference easeInCirc: <br /> 3204 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3205 * @function 3206 * @returns {Object} 3207 * @example 3208 * //example 3209 * action.easing(cc.easeCircleActionIn()); 3210 */ 3211 cc.easeCircleActionIn = function(){ 3212 return cc._easeCircleActionIn; 3213 }; 3214 3215 /** 3216 * cc.EaseCircleActionOut action. <br /> 3217 * Reference easeOutCirc: <br /> 3218 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3219 * @class 3220 * @extends cc.ActionEase 3221 * 3222 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionOut()); 3223 * 3224 * @example 3225 * //The old usage 3226 * cc.EaseCircleActionOut.create(action); 3227 * //The new usage 3228 * action.easing(cc.easeCircleActionOut()); 3229 */ 3230 cc.EaseCircleActionOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionOut# */{ 3231 _updateTime: function(time){ 3232 time = time - 1; 3233 return Math.sqrt(1 - time * time); 3234 }, 3235 3236 /** 3237 * Called once per frame. Time is the number of seconds of a frame interval. 3238 * 3239 * @param {Number} dt 3240 */ 3241 update: function(dt){ 3242 this._inner.update(this._updateTime(dt)); 3243 }, 3244 3245 /** 3246 * to copy object with deep copy. 3247 * returns a clone of action. 3248 * 3249 * @returns {cc.EaseCircleActionOut} 3250 */ 3251 clone: function(){ 3252 var action = new cc.EaseCircleActionOut(); 3253 action.initWithAction(this._inner.clone()); 3254 return action; 3255 }, 3256 3257 /** 3258 * Create a action. Opposite with the original motion trajectory. 3259 * @return {cc.EaseCircleActionOut} 3260 */ 3261 reverse: function(){ 3262 return new cc.EaseCircleActionOut(this._inner.reverse()); 3263 } 3264 }); 3265 3266 /** 3267 * Creates the action. <br /> 3268 * Reference easeOutCirc: <br /> 3269 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3270 * @static 3271 * 3272 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionOut()); 3273 * 3274 * @example 3275 * //The old usage 3276 * cc.EaseCircleActionOut.create(action); 3277 * //The new usage 3278 * action.easing(cc.easeCircleActionOut()); 3279 * 3280 * @param action 3281 * @returns {cc.EaseCircleActionOut} 3282 */ 3283 cc.EaseCircleActionOut.create = function(action){ 3284 return new cc.EaseCircleActionOut(action); 3285 }; 3286 3287 cc._easeCircleActionOut = { 3288 easing: cc.EaseCircleActionOut.prototype._updateTime, 3289 reverse: function(){ 3290 return cc._easeCircleActionOut; 3291 } 3292 }; 3293 3294 /** 3295 * Creates the action easing object. <br /> 3296 * Reference easeOutCirc: <br /> 3297 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3298 * @function 3299 * @returns {Object} 3300 * @exampple 3301 * //example 3302 * actioneasing(cc.easeCircleActionOut()); 3303 */ 3304 cc.easeCircleActionOut = function(){ 3305 return cc._easeCircleActionOut; 3306 }; 3307 3308 /** 3309 * cc.EaseCircleActionInOut action. <br /> 3310 * Reference easeInOutCirc: <br /> 3311 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3312 * @class 3313 * @extends cc.ActionEase 3314 * 3315 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionInOut()); 3316 * 3317 * @example 3318 * //The old usage 3319 * cc.EaseCircleActionInOut.create(action); 3320 * //The new usage 3321 * action.easing(cc.easeCircleActionInOut()); 3322 */ 3323 cc.EaseCircleActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCircleActionInOut# */{ 3324 _updateTime: function(time){ 3325 time = time * 2; 3326 if (time < 1) 3327 return -0.5 * (Math.sqrt(1 - time * time) - 1); 3328 time -= 2; 3329 return 0.5 * (Math.sqrt(1 - time * time) + 1); 3330 }, 3331 3332 /** 3333 * Called once per frame. Time is the number of seconds of a frame interval. 3334 * 3335 * @param {Number} dt 3336 */ 3337 update: function(dt){ 3338 this._inner.update(this._updateTime(dt)); 3339 }, 3340 3341 /** 3342 * to copy object with deep copy. 3343 * returns a clone of action. 3344 * 3345 * @returns {cc.EaseCircleActionInOut} 3346 */ 3347 clone: function(){ 3348 var action = new cc.EaseCircleActionInOut(); 3349 action.initWithAction(this._inner.clone()); 3350 return action; 3351 }, 3352 3353 /** 3354 * Create a action. Opposite with the original motion trajectory. 3355 * @return {cc.EaseCircleActionInOut} 3356 */ 3357 reverse: function(){ 3358 return new cc.EaseCircleActionInOut(this._inner.reverse()); 3359 } 3360 }); 3361 3362 /** 3363 * Creates the action. <br /> 3364 * Reference easeInOutCirc: <br /> 3365 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3366 * @static 3367 * 3368 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCircleActionInOut()); 3369 * 3370 * @example 3371 * //The old usage 3372 * cc.EaseCircleActionInOut.create(action); 3373 * //The new usage 3374 * action.easing(cc.easeCircleActionInOut()); 3375 * 3376 * @param action 3377 * @returns {cc.EaseCircleActionInOut} 3378 */ 3379 cc.EaseCircleActionInOut.create = function(action){ 3380 return new cc.EaseCircleActionInOut(action); 3381 }; 3382 3383 cc._easeCircleActionInOut = { 3384 easing: cc.EaseCircleActionInOut.prototype._updateTime, 3385 reverse: function(){ 3386 return cc._easeCircleActionInOut; 3387 } 3388 }; 3389 3390 /** 3391 * Creates the action easing object. <br /> 3392 * Reference easeInOutCirc: <br /> 3393 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3394 * @function 3395 * @returns {Object} 3396 * @example 3397 * //example 3398 * action.easing(cc.easeCircleActionInOut()); 3399 */ 3400 cc.easeCircleActionInOut = function(){ 3401 return cc._easeCircleActionInOut; 3402 }; 3403 3404 /** 3405 * cc.EaseCubicActionIn action. <br /> 3406 * Reference easeInCubic: <br /> 3407 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3408 * @class 3409 * @extends cc.ActionEase 3410 * 3411 * @deprecated since v3.0 <br /> action.easing(cc.easeCubicActionIn()); 3412 * 3413 * @example 3414 * //The old usage 3415 * cc.EaseCubicActionIn.create(action); 3416 * //The new usage 3417 * action.easing(cc.easeCubicActionIn()); 3418 */ 3419 cc.EaseCubicActionIn = cc.ActionEase.extend(/** @lends cc.EaseCubicActionIn# */{ 3420 _updateTime: function(time){ 3421 return time * time * time; 3422 }, 3423 3424 /** 3425 * Called once per frame. Time is the number of seconds of a frame interval. 3426 * 3427 * @param {Number} dt 3428 */ 3429 update: function(dt){ 3430 this._inner.update(this._updateTime(dt)); 3431 }, 3432 3433 /** 3434 * to copy object with deep copy. 3435 * returns a clone of action. 3436 * 3437 * @returns {cc.EaseCubicActionIn} 3438 */ 3439 clone: function(){ 3440 var action = new cc.EaseCubicActionIn(); 3441 action.initWithAction(this._inner.clone()); 3442 return action; 3443 }, 3444 3445 /** 3446 * Create a action. Opposite with the original motion trajectory. 3447 * @return {cc.EaseCubicActionIn} 3448 */ 3449 reverse: function(){ 3450 return new cc.EaseCubicActionIn(this._inner.reverse()); 3451 } 3452 }); 3453 3454 /** 3455 * Creates the action. <br /> 3456 * Reference easeInCubic: <br /> 3457 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3458 * @static 3459 * 3460 * @deprecated since v3.0 <br /> action.easing(cc.easeCubicActionIn()); 3461 * 3462 * @example 3463 * //The old usage 3464 * cc.EaseCubicActionIn.create(action); 3465 * //The new usage 3466 * action.easing(cc.easeCubicActionIn()); 3467 * 3468 * @param action 3469 * @returns {cc.EaseCubicActionIn} 3470 */ 3471 cc.EaseCubicActionIn.create = function(action){ 3472 return new cc.EaseCubicActionIn(action); 3473 }; 3474 3475 cc._easeCubicActionIn = { 3476 easing: cc.EaseCubicActionIn.prototype._updateTime, 3477 reverse: function(){ 3478 return cc._easeCubicActionIn; 3479 } 3480 }; 3481 3482 /** 3483 * Creates the action easing object. <br /> 3484 * Reference easeInCubic: <br /> 3485 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3486 * @function 3487 * @returns {Object} 3488 * @example 3489 * //example 3490 * action.easing(cc.easeCubicActionIn()); 3491 */ 3492 cc.easeCubicActionIn = function(){ 3493 return cc._easeCubicActionIn; 3494 }; 3495 3496 /** 3497 * cc.EaseCubicActionOut action. <br /> 3498 * Reference easeOutCubic: <br /> 3499 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3500 * @class 3501 * @extends cc.ActionEase 3502 * 3503 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCubicActionOut()); 3504 * 3505 * @example 3506 * //The old usage 3507 * cc.EaseCubicActionOut.create(action); 3508 * //The new usage 3509 * action.easing(cc.easeCubicActionOut()); 3510 */ 3511 cc.EaseCubicActionOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionOut# */{ 3512 _updateTime: function(time){ 3513 time -= 1; 3514 return (time * time * time + 1); 3515 }, 3516 3517 /** 3518 * Called once per frame. Time is the number of seconds of a frame interval. 3519 * 3520 * @param {Number} dt 3521 */ 3522 update: function(dt){ 3523 this._inner.update(this._updateTime(dt)); 3524 }, 3525 3526 /** 3527 * to copy object with deep copy. 3528 * returns a clone of action. 3529 * 3530 * @returns {cc.EaseCubicActionOut} 3531 */ 3532 clone: function(){ 3533 var action = new cc.EaseCubicActionOut(); 3534 action.initWithAction(this._inner.clone()); 3535 return action; 3536 }, 3537 3538 /** 3539 * Create a action. Opposite with the original motion trajectory. 3540 * @return {cc.EaseCubicActionOut} 3541 */ 3542 reverse: function(){ 3543 return new cc.EaseCubicActionOut(this._inner.reverse()); 3544 } 3545 }); 3546 3547 /** 3548 * Creates the action. <br /> 3549 * Reference easeOutCubic: <br /> 3550 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3551 * @static 3552 * 3553 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCubicActionOut()); 3554 * 3555 * @example 3556 * //The old usage 3557 * cc.EaseCubicActionOut.create(action); 3558 * //The new usage 3559 * action.easing(cc.easeCubicActionOut()); 3560 * 3561 * @param action 3562 * @returns {cc.EaseCubicActionOut} 3563 */ 3564 cc.EaseCubicActionOut.create = function(action){ 3565 return new cc.EaseCubicActionOut(action); 3566 }; 3567 3568 cc._easeCubicActionOut = { 3569 easing: cc.EaseCubicActionOut.prototype._updateTime, 3570 reverse: function(){ 3571 return cc._easeCubicActionOut; 3572 } 3573 }; 3574 3575 /** 3576 * Creates the action easing object. <br /> 3577 * Reference easeOutCubic: <br /> 3578 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3579 * @function 3580 * @returns {Object} 3581 * @example 3582 * //example 3583 * action.easing(cc.easeCubicActionOut()); 3584 */ 3585 cc.easeCubicActionOut = function(){ 3586 return cc._easeCubicActionOut; 3587 }; 3588 3589 /** 3590 * cc.EaseCubicActionInOut action. <br /> 3591 * Reference easeInOutCubic: <br /> 3592 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3593 * @class 3594 * @extends cc.ActionEase 3595 * 3596 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCubicActionInOut()); 3597 * 3598 * @example 3599 * //The old usage 3600 * cc.EaseCubicActionInOut.create(action); 3601 * //The new usage 3602 * action.easing(cc.easeCubicActionInOut()); 3603 */ 3604 cc.EaseCubicActionInOut = cc.ActionEase.extend(/** @lends cc.EaseCubicActionInOut# */{ 3605 _updateTime: function(time){ 3606 time = time*2; 3607 if (time < 1) 3608 return 0.5 * time * time * time; 3609 time -= 2; 3610 return 0.5 * (time * time * time + 2); 3611 }, 3612 3613 /** 3614 * Called once per frame. Time is the number of seconds of a frame interval. 3615 * 3616 * @param {Number} dt 3617 */ 3618 update: function(dt){ 3619 this._inner.update(this._updateTime(dt)); 3620 }, 3621 3622 /** 3623 * to copy object with deep copy. 3624 * returns a clone of action. 3625 * 3626 * @returns {cc.EaseCubicActionInOut} 3627 */ 3628 clone: function(){ 3629 var action = new cc.EaseCubicActionInOut(); 3630 action.initWithAction(this._inner.clone()); 3631 return action; 3632 }, 3633 3634 /** 3635 * Create a action. Opposite with the original motion trajectory. 3636 * @return {cc.EaseCubicActionInOut} 3637 */ 3638 reverse: function(){ 3639 return new cc.EaseCubicActionInOut(this._inner.reverse()); 3640 } 3641 }); 3642 3643 /** 3644 * Creates the action. <br /> 3645 * Reference easeInOutCubic: <br /> 3646 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3647 * @static 3648 * 3649 * @deprecated since v3.0 <br /> Please use action.easing(cc.easeCubicActionInOut()); 3650 * 3651 * @example 3652 * //The old usage 3653 * cc.EaseCubicActionInOut.create(action); 3654 * //The new usage 3655 * action.easing(cc.easeCubicActionInOut()); 3656 * 3657 * @param action 3658 * @returns {cc.EaseCubicActionInOut} 3659 */ 3660 cc.EaseCubicActionInOut.create = function(action){ 3661 return new cc.EaseCubicActionInOut(action); 3662 }; 3663 3664 cc._easeCubicActionInOut = { 3665 easing: cc.EaseCubicActionInOut.prototype._updateTime, 3666 reverse: function(){ 3667 return cc._easeCubicActionInOut; 3668 } 3669 }; 3670 3671 /** 3672 * Creates the action easing object. <br /> 3673 * Reference easeInOutCubic: <br /> 3674 * {@link http://www.zhihu.com/question/21981571/answer/19925418} 3675 * @function 3676 * @returns {Object} 3677 */ 3678 cc.easeCubicActionInOut = function(){ 3679 return cc._easeCubicActionInOut; 3680 }; 3681 3682