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 * A tag constant for identifying fade scenes 28 * @constant 29 * @type Number 30 */ 31 cc.SCENE_FADE = 4208917214; 32 33 /** 34 * horizontal orientation Type where the Left is nearer 35 * @constant 36 * @type Number 37 */ 38 cc.TRANSITION_ORIENTATION_LEFT_OVER = 0; 39 /** 40 * horizontal orientation type where the Right is nearer 41 * @constant 42 * @type Number 43 */ 44 cc.TRANSITION_ORIENTATION_RIGHT_OVER = 1; 45 /** 46 * vertical orientation type where the Up is nearer 47 * @constant 48 * @type Number 49 */ 50 cc.TRANSITION_ORIENTATION_UP_OVER = 0; 51 /** 52 * vertical orientation type where the Bottom is nearer 53 * @constant 54 * @type Number 55 */ 56 cc.TRANSITION_ORIENTATION_DOWN_OVER = 1; 57 58 /** 59 * @class 60 * @extends cc.Scene 61 * @param {Number} t time in seconds 62 * @param {cc.Scene} scene the scene to transit with 63 * @example 64 * var trans = new TransitionScene(time,scene); 65 */ 66 cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{ 67 _inScene:null, 68 _outScene:null, 69 _duration:null, 70 _isInSceneOnTop:false, 71 _isSendCleanupToScene:false, 72 _className:"TransitionScene", 73 74 /** 75 * creates a base transition with duration and incoming scene 76 * Constructor of cc.TransitionScene 77 * @param {Number} t time in seconds 78 * @param {cc.Scene} scene the scene to transit with 79 */ 80 ctor:function (t, scene) { 81 cc.Scene.prototype.ctor.call(this); 82 if(t !== undefined && scene !== undefined) 83 this.initWithDuration(t, scene); 84 }, 85 86 //private 87 _setNewScene:function (dt) { 88 this.unschedule(this._setNewScene); 89 // Before replacing, save the "send cleanup to scene" 90 var director = cc.director; 91 this._isSendCleanupToScene = director.isSendCleanupToScene(); 92 director.runScene(this._inScene); 93 94 // enable events while transitions 95 cc.eventManager.setEnabled(true); 96 97 // issue #267 98 this._outScene.visible = true; 99 }, 100 101 //protected 102 _sceneOrder:function () { 103 this._isInSceneOnTop = true; 104 }, 105 106 /** 107 * stuff gets drawn here 108 */ 109 draw:function () { 110 if (this._isInSceneOnTop) { 111 this._outScene.visit(); 112 this._inScene.visit(); 113 } else { 114 this._inScene.visit(); 115 this._outScene.visit(); 116 } 117 }, 118 119 /** 120 * <p> 121 * Event callback that is invoked every time when cc.TransitionScene enters the 'stage'. <br/> 122 * If the TransitionScene enters the 'stage' with a transition, this event is called when the transition starts. <br/> 123 * During onEnter you can't access a "sister/brother" node. <br/> 124 * If you override onEnter, you must call its parent's onEnter function with this._super(). 125 * </p> 126 */ 127 onEnter:function () { 128 cc.Node.prototype.onEnter.call(this); 129 130 // disable events while transitions 131 cc.eventManager.setEnabled(false); 132 133 // outScene should not receive the onEnter callback 134 // only the onExitTransitionDidStart 135 this._outScene.onExitTransitionDidStart(); 136 137 this._inScene.onEnter(); 138 }, 139 140 /** 141 * <p> 142 * callback that is called every time the cc.TransitionScene leaves the 'stage'. <br/> 143 * If the cc.TransitionScene leaves the 'stage' with a transition, this callback is called when the transition finishes. <br/> 144 * During onExit you can't access a sibling node. <br/> 145 * If you override onExit, you shall call its parent's onExit with this._super(). 146 * </p> 147 */ 148 onExit:function () { 149 cc.Node.prototype.onExit.call(this); 150 151 // enable events while transitions 152 cc.eventManager.setEnabled(true); 153 154 this._outScene.onExit(); 155 156 // _inScene should not receive the onEnter callback 157 // only the onEnterTransitionDidFinish 158 this._inScene.onEnterTransitionDidFinish(); 159 }, 160 161 /** 162 * custom cleanup 163 */ 164 cleanup:function () { 165 cc.Node.prototype.cleanup.call(this); 166 167 if (this._isSendCleanupToScene) 168 this._outScene.cleanup(); 169 }, 170 171 /** 172 * initializes a transition with duration and incoming scene 173 * @param {Number} t time in seconds 174 * @param {cc.Scene} scene a scene to transit to 175 * @return {Boolean} return false if error 176 */ 177 initWithDuration:function (t, scene) { 178 if(!scene) 179 throw "cc.TransitionScene.initWithDuration(): Argument scene must be non-nil"; 180 181 if (this.init()) { 182 this._duration = t; 183 this.attr({ 184 x: 0, 185 y: 0, 186 anchorX: 0, 187 anchorY: 0 188 }); 189 // retain 190 this._inScene = scene; 191 this._outScene = cc.director.getRunningScene(); 192 if (!this._outScene) { 193 this._outScene = cc.Scene.create(); 194 this._outScene.init(); 195 } 196 197 if(this._inScene == this._outScene) 198 throw "cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene"; 199 200 this._sceneOrder(); 201 return true; 202 } else { 203 return false; 204 } 205 }, 206 207 /** 208 * called after the transition finishes 209 */ 210 finish:function () { 211 // clean up 212 this._inScene.attr({ 213 visible: true, 214 x: 0, 215 y: 0, 216 scale: 1.0, 217 rotation: 0.0 218 }); 219 if(cc._renderType === cc._RENDER_TYPE_WEBGL) 220 this._inScene.getCamera().restore(); 221 222 this._outScene.attr({ 223 visible: false, 224 x: 0, 225 y: 0, 226 scale: 1.0, 227 rotation: 0.0 228 }); 229 if(cc._renderType === cc._RENDER_TYPE_WEBGL) 230 this._outScene.getCamera().restore(); 231 232 //[self schedule:@selector(setNewScene:) interval:0]; 233 this.schedule(this._setNewScene, 0); 234 }, 235 236 /** 237 * set hide the out scene and show in scene 238 */ 239 hideOutShowIn:function () { 240 this._inScene.visible = true; 241 this._outScene.visible = false; 242 } 243 }); 244 /** 245 * creates a base transition with duration and incoming scene 246 * @deprecated since v3.0, please use new cc.TransitionScene(t,scene) instead 247 * @param {Number} t time in seconds 248 * @param {cc.Scene} scene the scene to transit with 249 * @return {cc.TransitionScene|Null} 250 */ 251 cc.TransitionScene.create = function (t, scene) { 252 return new cc.TransitionScene(t, scene); 253 }; 254 255 /** 256 * A cc.Transition that supports orientation like.<br/> 257 * Possible orientation: LeftOver, RightOver, UpOver, DownOver<br/> 258 * useful for when you want to make a transition happen between 2 orientations 259 * @class 260 * @extends cc.TransitionScene 261 * @param {Number} t time in seconds 262 * @param {cc.Scene} scene 263 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation 264 * @example 265 * var trans = new cc.TransitionSceneOriented(time,scene,orientation); 266 */ 267 cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionSceneOriented# */{ 268 _orientation:0, 269 270 /** 271 * Constructor of TransitionSceneOriented 272 * @param {Number} t time in seconds 273 * @param {cc.Scene} scene 274 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation 275 */ 276 ctor:function (t, scene, orientation) { 277 cc.TransitionScene.prototype.ctor.call(this); 278 orientation != undefined && this.initWithDuration(t, scene, orientation); 279 }, 280 /** 281 * initialize the transition 282 * @param {Number} t time in seconds 283 * @param {cc.Scene} scene 284 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation 285 * @return {Boolean} 286 */ 287 initWithDuration:function (t, scene, orientation) { 288 if (cc.TransitionScene.prototype.initWithDuration.call(this, t, scene)) { 289 this._orientation = orientation; 290 } 291 return true; 292 } 293 }); 294 295 /** 296 * creates a base transition with duration and incoming scene 297 * @deprecated since v3.0 ,please use new cc.TransitionSceneOriented(t, scene, orientation) instead. 298 * @param {Number} t time in seconds 299 * @param {cc.Scene} scene 300 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation 301 * @return {cc.TransitionSceneOriented} 302 * @example 303 * // Example 304 * var goHorizontal = cc.TransitionSceneOriented.create(0.5, thisScene, cc.TRANSITION_ORIENTATION_LEFT_OVER) 305 */ 306 cc.TransitionSceneOriented.create = function (t, scene, orientation) { 307 return new cc.TransitionSceneOriented(t, scene, orientation); 308 }; 309 310 /** 311 * Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming 312 * @class 313 * @extends cc.TransitionScene 314 * @param {Number} t time in seconds 315 * @param {cc.Scene} scene 316 * @example 317 * var trans = new cc.TransitionRotoZoom(t, scene); 318 */ 319 cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZoom# */{ 320 321 /** 322 * Constructor of TransitionRotoZoom 323 * @function 324 * @param {Number} t time in seconds 325 * @param {cc.Scene} scene 326 */ 327 ctor:function (t, scene) { 328 cc.TransitionScene.prototype.ctor.call(this); 329 scene && this.initWithDuration(t, scene); 330 }, 331 /** 332 * Custom On Enter callback 333 * @override 334 */ 335 onEnter:function () { 336 cc.TransitionScene.prototype.onEnter.call(this); 337 338 this._inScene.attr({ 339 scale: 0.001, 340 anchorX: 0.5, 341 anchorY: 0.5 342 }); 343 this._outScene.attr({ 344 scale: 1.0, 345 anchorX: 0.5, 346 anchorY: 0.5 347 }); 348 349 var rotoZoom = cc.sequence( 350 cc.spawn(cc.scaleBy(this._duration / 2, 0.001), 351 cc.rotateBy(this._duration / 2, 360 * 2)), 352 cc.delayTime(this._duration / 2)); 353 354 this._outScene.runAction(rotoZoom); 355 this._inScene.runAction( 356 cc.sequence(rotoZoom.reverse(), 357 cc.callFunc(this.finish, this))); 358 } 359 }); 360 361 /** 362 * Creates a Transtion rotation and zoom 363 * @deprecated since v3.0,please use new cc.TransitionRotoZoom(t, scene) instead 364 * @param {Number} t time in seconds 365 * @param {cc.Scene} scene the scene to work with 366 * @return {cc.TransitionRotoZoom} 367 * @example 368 * var RotoZoomTrans = cc.TransitionRotoZoom.create(2, nextScene); 369 */ 370 cc.TransitionRotoZoom.create = function (t, scene) { 371 return new cc.TransitionRotoZoom(t, scene); 372 }; 373 374 /** 375 * Zoom out and jump the outgoing scene, and then jump and zoom in the incoming 376 * @class 377 * @extends cc.TransitionScene 378 * @param {Number} t time in seconds 379 * @param {cc.Scene} scene 380 * @example 381 * var trans = new cc.TransitionJumpZoom(t, scene); 382 */ 383 cc.TransitionJumpZoom = cc.TransitionScene.extend(/** @lends cc.TransitionJumpZoom# */{ 384 /** 385 * Constructor of TransitionJumpZoom 386 * @param {Number} t time in seconds 387 * @param {cc.Scene} scene 388 */ 389 ctor:function (t, scene) { 390 cc.TransitionScene.prototype.ctor.call(this); 391 scene && this.initWithDuration(t, scene); 392 }, 393 /** 394 * Custom on enter 395 */ 396 onEnter:function () { 397 cc.TransitionScene.prototype.onEnter.call(this); 398 var winSize = cc.director.getWinSize(); 399 400 this._inScene.attr({ 401 scale: 0.5, 402 x: winSize.width, 403 y: 0, 404 anchorX: 0.5, 405 anchorY: 0.5 406 }); 407 this._outScene.anchorX = 0.5; 408 this._outScene.anchorY = 0.5; 409 410 var jump = cc.jumpBy(this._duration / 4, cc.p(-winSize.width, 0), winSize.width / 4, 2); 411 var scaleIn = cc.scaleTo(this._duration / 4, 1.0); 412 var scaleOut = cc.scaleTo(this._duration / 4, 0.5); 413 414 var jumpZoomOut = cc.sequence(scaleOut, jump); 415 var jumpZoomIn = cc.sequence(jump, scaleIn); 416 417 var delay = cc.delayTime(this._duration / 2); 418 this._outScene.runAction(jumpZoomOut); 419 this._inScene.runAction(cc.sequence(delay, jumpZoomIn, cc.callFunc(this.finish, this))); 420 } 421 }); 422 423 /** 424 * creates a scene transition that zooms then jump across the screen, the same for the incoming scene 425 * @deprecated since v3.0,please use new cc.TransitionJumpZoom(t, scene); 426 * @param {Number} t time in seconds 427 * @param {cc.Scene} scene 428 * @return {cc.TransitionJumpZoom} 429 */ 430 cc.TransitionJumpZoom.create = function (t, scene) { 431 return new cc.TransitionJumpZoom(t, scene); 432 }; 433 434 /** 435 * Move in from to the left the incoming scene. 436 * @class 437 * @extends cc.TransitionScene 438 * @param {Number} t time in seconds 439 * @param {cc.Scene} scene 440 * @example 441 * var trans = new cc.TransitionMoveInL(time,scene); 442 */ 443 cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL# */{ 444 /** 445 * Constructor of TransitionMoveInL 446 * @param {Number} t time in seconds 447 * @param {cc.Scene} scene 448 */ 449 ctor:function (t, scene) { 450 cc.TransitionScene.prototype.ctor.call(this); 451 scene && this.initWithDuration(t, scene); 452 }, 453 /** 454 * Custom on enter 455 */ 456 onEnter:function () { 457 cc.TransitionScene.prototype.onEnter.call(this); 458 this.initScenes(); 459 460 var action = this.action(); 461 this._inScene.runAction( 462 cc.sequence(this.easeActionWithAction(action), cc.callFunc(this.finish, this)) 463 ); 464 }, 465 466 /** 467 * initializes the scenes 468 */ 469 initScenes:function () { 470 this._inScene.setPosition(-cc.director.getWinSize().width, 0); 471 }, 472 473 /** 474 * returns the action that will be performed 475 */ 476 action:function () { 477 return cc.moveTo(this._duration, cc.p(0, 0)); 478 }, 479 480 /** 481 * creates an ease action from action 482 * @param {cc.ActionInterval} action 483 * @return {cc.EaseOut} 484 */ 485 easeActionWithAction:function (action) { 486 return new cc.EaseOut(action, 2.0); 487 } 488 }); 489 490 /** 491 * creates an action that Move in from to the left the incoming scene. 492 * @deprecated since v3.0,please use new cc.TransitionMoveInL(t, scene) instead 493 * @param {Number} t time in seconds 494 * @param {cc.Scene} scene 495 * @return {cc.TransitionMoveInL} 496 * @example 497 * var MoveInLeft = cc.TransitionMoveInL.create(1, nextScene) 498 */ 499 cc.TransitionMoveInL.create = function (t, scene) { 500 return new cc.TransitionMoveInL(t, scene); 501 }; 502 503 /** 504 * Move in from to the right the incoming scene. 505 * @class 506 * @extends cc.TransitionMoveInL 507 * @param {Number} t time in seconds 508 * @param {cc.Scene} scene 509 * @example 510 * var trans = new cc.TransitionMoveInR(time,scene); 511 */ 512 cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInR# */{ 513 /** 514 * Constructor of TransitionMoveInR 515 * @param {Number} t time in seconds 516 * @param {cc.Scene} scene 517 */ 518 ctor:function (t, scene) { 519 cc.TransitionMoveInL.prototype.ctor.call(this); 520 scene && this.initWithDuration(t, scene); 521 }, 522 /** 523 * Init function 524 */ 525 initScenes:function () { 526 this._inScene.setPosition(cc.director.getWinSize().width, 0); 527 } 528 }); 529 530 /** 531 * create a scene transition that Move in from to the right the incoming scene. 532 * @deprecated since v3.0,please use new cc.TransitionMoveInR(t, scene) instead 533 * @param {Number} t time in seconds 534 * @param {cc.Scene} scene 535 * @return {cc.TransitionMoveInR} 536 * @example 537 * var MoveInRight = cc.TransitionMoveInR.create(1, nextScene) 538 */ 539 cc.TransitionMoveInR.create = function (t, scene) { 540 return new cc.TransitionMoveInR(t, scene); 541 }; 542 543 /** 544 * Move in from to the top the incoming scene. 545 * @class 546 * @extends cc.TransitionMoveInL 547 * @param {Number} t time in seconds 548 * @param {cc.Scene} scene 549 * @example 550 * var trans = new cc.TransitionMoveInT(time,scene); 551 */ 552 cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInT# */{ 553 /** 554 * Constructor of TransitionMoveInT 555 * @param {Number} t time in seconds 556 * @param {cc.Scene} scene 557 */ 558 ctor:function (t, scene) { 559 cc.TransitionMoveInL.prototype.ctor.call(this); 560 scene && this.initWithDuration(t, scene); 561 }, 562 /** 563 * init function 564 */ 565 initScenes:function () { 566 this._inScene.setPosition(0, cc.director.getWinSize().height); 567 } 568 }); 569 570 /** 571 * Move in from to the top the incoming scene. 572 * @deprecated since v3.0,please use new cc.TransitionMoveInT(t, scene) instead 573 * @param {Number} t time in seconds 574 * @param {cc.Scene} scene 575 * @return {cc.TransitionMoveInT} 576 * @example 577 * var MoveInTop = cc.TransitionMoveInT.create(1, nextScene) 578 */ 579 cc.TransitionMoveInT.create = function (t, scene) { 580 return new cc.TransitionMoveInT(t, scene); 581 }; 582 583 /** 584 * Move in from to the bottom the incoming scene. 585 * @class 586 * @extends cc.TransitionMoveInL 587 * @param {Number} t time in seconds 588 * @param {cc.Scene} scene 589 * @example 590 * var trans = new cc.TransitionMoveInB(time,scene); 591 */ 592 cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInB# */{ 593 /** 594 * Constructor of TransitionMoveInB 595 * @param {Number} t time in seconds 596 * @param {cc.Scene} scene 597 */ 598 ctor:function (t, scene) { 599 cc.TransitionMoveInL.prototype.ctor.call(this); 600 scene && this.initWithDuration(t, scene); 601 }, 602 603 /** 604 * init function 605 */ 606 initScenes:function () { 607 this._inScene.setPosition(0, -cc.director.getWinSize().height); 608 } 609 }); 610 611 /** 612 * create a scene transition that Move in from to the bottom the incoming scene. 613 * @deprecated since v3.0,please use new cc.TransitionMoveInB(t, scene) instead 614 * @param {Number} t time in seconds 615 * @param {cc.Scene} scene 616 * @return {cc.TransitionMoveInB} 617 * @example 618 * var MoveinB = cc.TransitionMoveInB.create(1, nextScene) 619 */ 620 cc.TransitionMoveInB.create = function (t, scene) { 621 return new cc.TransitionMoveInB(t, scene); 622 }; 623 624 /** 625 * The adjust factor is needed to prevent issue #442<br/> 626 * One solution is to use DONT_RENDER_IN_SUBPIXELS images, but NO<br/> 627 * The other issue is that in some transitions (and I don't know why)<br/> 628 * the order should be reversed (In in top of Out or vice-versa). 629 * @constant 630 * @type Number 631 */ 632 cc.ADJUST_FACTOR = 0.5; 633 634 /** 635 * a transition that a new scene is slided from left 636 * @class 637 * @extends cc.TransitionScene 638 * @param {Number} t time in seconds 639 * @param {cc.Scene} scene 640 * @example 641 * var trans = cc.TransitionSlideInL(time,scene); 642 */ 643 cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideInL# */{ 644 /** 645 * Constructor of TransitionSlideInL 646 * @param {Number} t time in seconds 647 * @param {cc.Scene} scene 648 */ 649 ctor:function (t, scene) { 650 cc.TransitionScene.prototype.ctor.call(this); 651 scene && this.initWithDuration(t, scene); 652 }, 653 _sceneOrder:function () { 654 this._isInSceneOnTop = false; 655 }, 656 657 /** 658 * custom on enter 659 */ 660 onEnter:function () { 661 cc.TransitionScene.prototype.onEnter.call(this); 662 this.initScenes(); 663 664 var inA = this.action(); 665 var outA = this.action(); 666 667 var inAction = this.easeActionWithAction(inA); 668 var outAction = cc.sequence(this.easeActionWithAction(outA), cc.callFunc(this.finish, this)); 669 this._inScene.runAction(inAction); 670 this._outScene.runAction(outAction); 671 }, 672 673 /** 674 * initializes the scenes 675 */ 676 initScenes:function () { 677 this._inScene.setPosition(-cc.director.getWinSize().width + cc.ADJUST_FACTOR, 0); 678 }, 679 /** 680 * returns the action that will be performed by the incomming and outgoing scene 681 * @return {cc.MoveBy} 682 */ 683 action:function () { 684 return cc.moveBy(this._duration, cc.p(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0)); 685 }, 686 687 /** 688 * @param {cc.ActionInterval} action 689 * @return {*} 690 */ 691 easeActionWithAction:function (action) { 692 return new cc.EaseInOut(action, 2.0); 693 } 694 }); 695 696 /** 697 * create a transition that a new scene is slided from left 698 * @deprecated since v3.0,please use new cc.TransitionSlideInL(t, scene) instead 699 * @param {Number} t time in seconds 700 * @param {cc.Scene} scene 701 * @return {cc.TransitionSlideInL} 702 * @example 703 * var myTransition = cc.TransitionSlideInL.create(1.5, nextScene) 704 */ 705 cc.TransitionSlideInL.create = function (t, scene) { 706 return new cc.TransitionSlideInL(t, scene); 707 }; 708 709 /** 710 * Slide in the incoming scene from the right border. 711 * @class 712 * @extends cc.TransitionSlideInL 713 * @param {Number} t time in seconds 714 * @param {cc.Scene} scene 715 * @example 716 * var trans = new cc.TransitionSlideInR(time,scene); 717 */ 718 cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInR# */{ 719 /** 720 * Constructor of TransitionSlideInR 721 * @param {Number} t time in seconds 722 * @param {cc.Scene} scene 723 */ 724 ctor:function (t, scene) { 725 cc.TransitionSlideInL.prototype.ctor.call(this); 726 scene && this.initWithDuration(t, scene); 727 }, 728 _sceneOrder:function () { 729 this._isInSceneOnTop = true; 730 }, 731 /** 732 * initializes the scenes 733 */ 734 initScenes:function () { 735 this._inScene.setPosition(cc.director.getWinSize().width - cc.ADJUST_FACTOR, 0); 736 }, 737 /** 738 * returns the action that will be performed by the incomming and outgoing scene 739 * @return {cc.MoveBy} 740 */ 741 action:function () { 742 return cc.moveBy(this._duration, cc.p(-(cc.director.getWinSize().width - cc.ADJUST_FACTOR), 0)); 743 } 744 }); 745 746 /** 747 * create Slide in the incoming scene from the right border. 748 * @deprecated since v3.0,please use new cc.TransitionSlideInR(t, scene) instead 749 * @param {Number} t time in seconds 750 * @param {cc.Scene} scene 751 * @return {cc.TransitionSlideInR} 752 * @example 753 * var myTransition = cc.TransitionSlideInR.create(1.5, nextScene) 754 */ 755 cc.TransitionSlideInR.create = function (t, scene) { 756 return new cc.TransitionSlideInR(t, scene); 757 }; 758 759 /** 760 * Slide in the incoming scene from the bottom border. 761 * @class 762 * @extends cc.TransitionSlideInL 763 * @param {Number} t time in seconds 764 * @param {cc.Scene} scene 765 * @example 766 * var trans = new cc.TransitionSlideInB(time,scene); 767 */ 768 cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInB# */{ 769 /** 770 * Constructor of TransitionSlideInB 771 * @param {Number} t time in seconds 772 * @param {cc.Scene} scene 773 */ 774 ctor:function (t, scene) { 775 cc.TransitionSlideInL.prototype.ctor.call(this); 776 scene && this.initWithDuration(t, scene); 777 }, 778 _sceneOrder:function () { 779 this._isInSceneOnTop = false; 780 }, 781 782 /** 783 * initializes the scenes 784 */ 785 initScenes:function () { 786 this._inScene.setPosition(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR)); 787 }, 788 789 /** 790 * returns the action that will be performed by the incomming and outgoing scene 791 * @return {cc.MoveBy} 792 */ 793 action:function () { 794 return cc.moveBy(this._duration, cc.p(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR)); 795 } 796 }); 797 798 /** 799 * create a Slide in the incoming scene from the bottom border. 800 * @deprecated since v3.0,please use new cc.TransitionSlideInB(t, scene) instead. 801 * @param {Number} t time in seconds 802 * @param {cc.Scene} scene 803 * @return {cc.TransitionSlideInB} 804 * @example 805 * var myTransition = cc.TransitionSlideInB.create(1.5, nextScene) 806 */ 807 cc.TransitionSlideInB.create = function (t, scene) { 808 return new cc.TransitionSlideInB(t, scene); 809 }; 810 811 /** 812 * Slide in the incoming scene from the top border. 813 * @class 814 * @extends cc.TransitionSlideInL 815 * @param {Number} t time in seconds 816 * @param {cc.Scene} scene 817 * @example 818 * var trans = new cc.TransitionSlideInT(time,scene); 819 */ 820 cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInT# */{ 821 /** 822 * Constructor of TransitionSlideInT 823 * @param {Number} t time in seconds 824 * @param {cc.Scene} scene 825 */ 826 ctor:function (t, scene) { 827 cc.TransitionSlideInL.prototype.ctor.call(this); 828 scene && this.initWithDuration(t, scene); 829 }, 830 _sceneOrder:function () { 831 this._isInSceneOnTop = true; 832 }, 833 834 /** 835 * initializes the scenes 836 */ 837 initScenes:function () { 838 this._inScene.setPosition(0, cc.director.getWinSize().height - cc.ADJUST_FACTOR); 839 }, 840 841 /** 842 * returns the action that will be performed by the incomming and outgoing scene 843 * @return {cc.MoveBy} 844 */ 845 action:function () { 846 return cc.moveBy(this._duration, cc.p(0, -(cc.director.getWinSize().height - cc.ADJUST_FACTOR))); 847 } 848 }); 849 850 /** 851 * create a Slide in the incoming scene from the top border. 852 * @deprecated since v3.0,please use new cc.TransitionSlideInT(t, scene) instead. 853 * @param {Number} t time in seconds 854 * @param {cc.Scene} scene 855 * @return {cc.TransitionSlideInT} 856 * @example 857 * var myTransition = cc.TransitionSlideInT.create(1.5, nextScene) 858 */ 859 cc.TransitionSlideInT.create = function (t, scene) { 860 return new cc.TransitionSlideInT(t, scene); 861 }; 862 863 /** 864 * Shrink the outgoing scene while grow the incoming scene 865 * @class 866 * @extends cc.TransitionScene 867 * @param {Number} t time in seconds 868 * @param {cc.Scene} scene 869 * @example 870 * var trans = new cc.TransitionShrinkGrow(time,scene); 871 */ 872 cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShrinkGrow# */{ 873 /** 874 * Constructor of TransitionShrinkGrow 875 * @param {Number} t time in seconds 876 * @param {cc.Scene} scene 877 */ 878 ctor:function (t, scene) { 879 cc.TransitionScene.prototype.ctor.call(this); 880 scene && this.initWithDuration(t, scene); 881 }, 882 /** 883 * Custom on enter 884 */ 885 onEnter:function () { 886 cc.TransitionScene.prototype.onEnter.call(this); 887 888 this._inScene.attr({ 889 scale: 0.001, 890 anchorX: 2 / 3.0, 891 anchorY: 0.5 892 }); 893 this._outScene.attr({ 894 scale: 1.0, 895 anchorX: 1 / 3.0, 896 anchorY: 0.5 897 }); 898 899 var scaleOut = cc.scaleTo(this._duration, 0.01); 900 var scaleIn = cc.scaleTo(this._duration, 1.0); 901 902 this._inScene.runAction(this.easeActionWithAction(scaleIn)); 903 this._outScene.runAction( 904 cc.sequence(this.easeActionWithAction(scaleOut), cc.callFunc(this.finish, this)) 905 ); 906 }, 907 908 /** 909 * @param action 910 * @return {cc.EaseOut} 911 */ 912 easeActionWithAction:function (action) { 913 return new cc.EaseOut(action, 2.0); 914 } 915 }); 916 917 /** 918 * Shrink the outgoing scene while grow the incoming scene 919 * @deprecated since v3.0,please use new cc.TransitionShrinkGrow(t, scene) instead. 920 * @param {Number} t time in seconds 921 * @param {cc.Scene} scene 922 * @return {cc.TransitionShrinkGrow} 923 * @example 924 * var myTransition = cc.TransitionShrinkGrow.create(1.5, nextScene) 925 */ 926 cc.TransitionShrinkGrow.create = function (t, scene) { 927 return new cc.TransitionShrinkGrow(t, scene); 928 }; 929 930 /** 931 * Flips the screen horizontally.<br/> 932 * The front face is the outgoing scene and the back face is the incoming scene. 933 * @class 934 * @extends cc.TransitionSceneOriented 935 * @param {Number} t time in seconds 936 * @param {cc.Scene} scene 937 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 938 * @example 939 * var trans = new cc.TransitionFlipX(t,scene,o); 940 */ 941 cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipX# */{ 942 /** 943 * Constructor of TransitionFlipX 944 * @function 945 * @param {Number} t time in seconds 946 * @param {cc.Scene} scene 947 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 948 */ 949 ctor:function (t, scene, o) { 950 cc.TransitionSceneOriented.prototype.ctor.call(this); 951 o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; 952 scene && this.initWithDuration(t, scene, o); 953 }, 954 955 /** 956 * custom on enter 957 */ 958 onEnter:function () { 959 cc.TransitionScene.prototype.onEnter.call(this); 960 961 var inA, outA; 962 this._inScene.visible = false; 963 964 var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ; 965 966 if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) { 967 inDeltaZ = 90; 968 inAngleZ = 270; 969 outDeltaZ = 90; 970 outAngleZ = 0; 971 } else { 972 inDeltaZ = -90; 973 inAngleZ = 90; 974 outDeltaZ = -90; 975 outAngleZ = 0; 976 } 977 978 inA = cc.sequence( 979 cc.delayTime(this._duration / 2), cc.show(), 980 cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0), 981 cc.callFunc(this.finish, this) 982 ); 983 984 outA = cc.sequence( 985 cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0), 986 cc.hide(), cc.delayTime(this._duration / 2) 987 ); 988 989 this._inScene.runAction(inA); 990 this._outScene.runAction(outA); 991 } 992 }); 993 994 /** 995 * Flips the screen horizontally.<br/> 996 * The front face is the outgoing scene and the back face is the incoming scene. 997 * @deprecated since v3.0,please use new cc.TransitionFlipX(t, scene,o) instead. 998 * @param {Number} t time in seconds 999 * @param {cc.Scene} scene 1000 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1001 * @return {cc.TransitionFlipX} 1002 * @example 1003 * var myTransition = cc.TransitionFlipX.create(1.5, nextScene) //default is cc.TRANSITION_ORIENTATION_RIGHT_OVER 1004 * //OR 1005 * var myTransition = cc.TransitionFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_UP_OVER) 1006 */ 1007 cc.TransitionFlipX.create = function (t, scene, o) { 1008 return new cc.TransitionFlipX(t, scene, o); 1009 }; 1010 1011 /** 1012 * Flips the screen vertically.<br/> 1013 * The front face is the outgoing scene and the back face is the incoming scene. 1014 * @class 1015 * @extends cc.TransitionSceneOriented 1016 * @param {Number} t time in seconds 1017 * @param {cc.Scene} scene 1018 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1019 * @example 1020 * var trans = new cc.TransitionFlipY(time,scene,0); 1021 */ 1022 cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipY# */{ 1023 1024 /** 1025 * Constructor of TransitionFlipY 1026 * @param {Number} t time in seconds 1027 * @param {cc.Scene} scene 1028 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1029 */ 1030 ctor:function (t, scene, o) { 1031 cc.TransitionSceneOriented.prototype.ctor.call(this); 1032 o = o || cc.TRANSITION_ORIENTATION_UP_OVER; 1033 scene && this.initWithDuration(t, scene, o); 1034 }, 1035 /** 1036 * custom on enter 1037 */ 1038 onEnter:function () { 1039 cc.TransitionScene.prototype.onEnter.call(this); 1040 1041 var inA, outA; 1042 this._inScene.visible = false; 1043 1044 var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ; 1045 1046 if (this._orientation == cc.TRANSITION_ORIENTATION_UP_OVER) { 1047 inDeltaZ = 90; 1048 inAngleZ = 270; 1049 outDeltaZ = 90; 1050 outAngleZ = 0; 1051 } else { 1052 inDeltaZ = -90; 1053 inAngleZ = 90; 1054 outDeltaZ = -90; 1055 outAngleZ = 0; 1056 } 1057 1058 inA = cc.Sequence.create( 1059 cc.DelayTime.create(this._duration / 2), cc.Show.create(), 1060 cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0), 1061 cc.CallFunc.create(this.finish, this) 1062 ); 1063 outA = cc.Sequence.create( 1064 cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0), 1065 cc.Hide.create(), cc.DelayTime.create(this._duration / 2) 1066 ); 1067 1068 this._inScene.runAction(inA); 1069 this._outScene.runAction(outA); 1070 } 1071 }); 1072 1073 /** 1074 * Flips the screen vertically.<br/> 1075 * The front face is the outgoing scene and the back face is the incoming scene. 1076 * @deprecated since v3.0,please use new cc.TransitionFlipY(t, scene,o) instead. 1077 * @param {Number} t time in seconds 1078 * @param {cc.Scene} scene 1079 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1080 * @return {cc.TransitionFlipY} 1081 * @example 1082 * var myTransition = cc.TransitionFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER 1083 * //OR 1084 * var myTransition = cc.TransitionFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_RIGHT_OVER) 1085 */ 1086 cc.TransitionFlipY.create = function (t, scene, o) { 1087 return new cc.TransitionFlipY(t, scene, o); 1088 }; 1089 1090 /** 1091 * Flips the screen half horizontally and half vertically.<br/> 1092 * The front face is the outgoing scene and the back face is the incoming scene. 1093 * @class 1094 * @extends cc.TransitionSceneOriented 1095 * @param {Number} t time in seconds 1096 * @param {cc.Scene} scene 1097 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1098 * @example 1099 * var trans = cc.TransitionFlipAngular(time,scene,o); 1100 */ 1101 cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipAngular# */{ 1102 /** 1103 * Constructor of TransitionFlipAngular 1104 * @param {Number} t time in seconds 1105 * @param {cc.Scene} scene 1106 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1107 */ 1108 ctor:function (t, scene, o) { 1109 cc.TransitionSceneOriented.prototype.ctor.call(this); 1110 o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; 1111 scene && this.initWithDuration(t, scene, o); 1112 }, 1113 /** 1114 * custom on enter 1115 */ 1116 onEnter:function () { 1117 cc.TransitionScene.prototype.onEnter.call(this); 1118 1119 var inA, outA; 1120 this._inScene.visible = false; 1121 1122 var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ; 1123 1124 if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) { 1125 inDeltaZ = 90; 1126 inAngleZ = 270; 1127 outDeltaZ = 90; 1128 outAngleZ = 0; 1129 } else { 1130 inDeltaZ = -90; 1131 inAngleZ = 90; 1132 outDeltaZ = -90; 1133 outAngleZ = 0; 1134 } 1135 1136 inA = cc.sequence( 1137 cc.delayTime(this._duration / 2), cc.show(), 1138 cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0), 1139 cc.callFunc(this.finish, this) 1140 ); 1141 outA = cc.sequence( 1142 cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0), 1143 cc.hide(), cc.delayTime(this._duration / 2) 1144 ); 1145 1146 this._inScene.runAction(inA); 1147 this._outScene.runAction(outA); 1148 } 1149 }); 1150 1151 /** 1152 * Flips the screen half horizontally and half vertically.<br/> 1153 * The front face is the outgoing scene and the back face is the incoming scene. 1154 * @deprecated since v3.0,please use new new cc.TransitionFlipAngular(t, scene, o) instead 1155 * @param {Number} t time in seconds 1156 * @param {cc.Scene} scene 1157 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1158 * @return {cc.TransitionFlipAngular} 1159 * @example 1160 * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER 1161 * //or 1162 * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) 1163 */ 1164 cc.TransitionFlipAngular.create = function (t, scene, o) { 1165 return new cc.TransitionFlipAngular(t, scene, o); 1166 }; 1167 1168 /** 1169 * Flips the screen horizontally doing a zoom out/in<br/> 1170 * The front face is the outgoing scene and the back face is the incoming scene. 1171 * @class 1172 * @extends cc.TransitionSceneOriented 1173 * @param {Number} t time in seconds 1174 * @param {cc.Scene} scene 1175 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1176 * @example 1177 * var trans = new cc.TransitionZoomFlipX(time,scene,o); 1178 */ 1179 cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipX# */{ 1180 1181 /** 1182 * Constructor of TransitionZoomFlipX 1183 * @param {Number} t time in seconds 1184 * @param {cc.Scene} scene 1185 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1186 */ 1187 ctor:function (t, scene, o) { 1188 cc.TransitionSceneOriented.prototype.ctor.call(this); 1189 o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; 1190 scene && this.initWithDuration(t, scene, o); 1191 }, 1192 /** 1193 * custom on enter 1194 */ 1195 onEnter:function () { 1196 cc.TransitionScene.prototype.onEnter.call(this); 1197 1198 var inA, outA; 1199 this._inScene.visible = false; 1200 1201 var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ; 1202 1203 if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) { 1204 inDeltaZ = 90; 1205 inAngleZ = 270; 1206 outDeltaZ = 90; 1207 outAngleZ = 0; 1208 } else { 1209 inDeltaZ = -90; 1210 inAngleZ = 90; 1211 outDeltaZ = -90; 1212 outAngleZ = 0; 1213 } 1214 1215 inA = cc.sequence( 1216 cc.delayTime(this._duration / 2), 1217 cc.spawn( 1218 cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0), 1219 cc.scaleTo(this._duration / 2, 1), cc.show()), 1220 cc.callFunc(this.finish, this) 1221 ); 1222 outA = cc.sequence( 1223 cc.spawn( 1224 cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0), 1225 cc.scaleTo(this._duration / 2, 0.5)), 1226 cc.hide(), 1227 cc.delayTime(this._duration / 2) 1228 ); 1229 1230 this._inScene.scale = 0.5; 1231 this._inScene.runAction(inA); 1232 this._outScene.runAction(outA); 1233 } 1234 }); 1235 1236 /** 1237 * Flips the screen horizontally doing a zoom out/in<br/> 1238 * The front face is the outgoing scene and the back face is the incoming scene. 1239 * @deprecated since v3.0,please use new new cc.TransitionZoomFlipX(t, scene, o) instead 1240 * @param {Number} t time in seconds 1241 * @param {cc.Scene} scene 1242 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1243 * @return {cc.TransitionZoomFlipX} 1244 * @example 1245 * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER 1246 * //OR 1247 * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) 1248 */ 1249 cc.TransitionZoomFlipX.create = function (t, scene, o) { 1250 return new cc.TransitionZoomFlipX(t, scene, o); 1251 }; 1252 1253 /** 1254 * Flips the screen vertically doing a little zooming out/in<br/> 1255 * The front face is the outgoing scene and the back face is the incoming scene. 1256 * @class 1257 * @extends cc.TransitionSceneOriented 1258 * @param {Number} t time in seconds 1259 * @param {cc.Scene} scene 1260 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1261 * @example 1262 * var trans = new cc.TransitionZoomFlipY(t,scene,o); 1263 */ 1264 cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipY# */{ 1265 1266 /** 1267 * Constructor of TransitionZoomFlipY 1268 * @param {Number} t time in seconds 1269 * @param {cc.Scene} scene 1270 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1271 */ 1272 ctor:function (t, scene, o) { 1273 cc.TransitionSceneOriented.prototype.ctor.call(this); 1274 o = o || cc.TRANSITION_ORIENTATION_UP_OVER; 1275 scene && this.initWithDuration(t, scene, o); 1276 }, 1277 /** 1278 * custom on enter 1279 */ 1280 onEnter:function () { 1281 cc.TransitionScene.prototype.onEnter.call(this); 1282 1283 var inA, outA; 1284 this._inScene.visible = false; 1285 1286 var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ; 1287 1288 if (this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER) { 1289 inDeltaZ = 90; 1290 inAngleZ = 270; 1291 outDeltaZ = 90; 1292 outAngleZ = 0; 1293 } else { 1294 inDeltaZ = -90; 1295 inAngleZ = 90; 1296 outDeltaZ = -90; 1297 outAngleZ = 0; 1298 } 1299 1300 inA = cc.sequence( 1301 cc.delayTime(this._duration / 2), 1302 cc.spawn( 1303 cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0), 1304 cc.scaleTo(this._duration / 2, 1), cc.show()), 1305 cc.callFunc(this.finish, this)); 1306 1307 outA = cc.sequence( 1308 cc.spawn( 1309 cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0), 1310 cc.scaleTo(this._duration / 2, 0.5)), 1311 cc.hide(), cc.delayTime(this._duration / 2)); 1312 1313 this._inScene.scale = 0.5; 1314 this._inScene.runAction(inA); 1315 this._outScene.runAction(outA); 1316 } 1317 }); 1318 1319 /** 1320 * Flips the screen vertically doing a little zooming out/in<br/> 1321 * The front face is the outgoing scene and the back face is the incoming scene. 1322 * @deprecated since v3.0,please use new new cc.TransitionZoomFlipY(t, scene, o) instead 1323 * @param {Number} t time in seconds 1324 * @param {cc.Scene} scene 1325 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1326 * @return {cc.TransitionZoomFlipY} 1327 * @example 1328 * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER 1329 * //OR 1330 * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) 1331 */ 1332 cc.TransitionZoomFlipY.create = function (t, scene, o) { 1333 return new cc.TransitionZoomFlipY(t, scene, o); 1334 }; 1335 1336 /** 1337 * Flips the screen half horizontally and half vertically doing a little zooming out/in.<br/> 1338 * The front face is the outgoing scene and the back face is the incoming scene. 1339 * @class 1340 * @extends cc.TransitionSceneOriented 1341 * @param {Number} t time in seconds 1342 * @param {cc.Scene} scene 1343 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1344 * @example 1345 * var trans = new cc.TransitionZoomFlipAngular(time,scene,o); 1346 */ 1347 cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipAngular# */{ 1348 1349 /** 1350 * Constructor of TransitionZoomFlipAngular 1351 * @param {Number} t time in seconds 1352 * @param {cc.Scene} scene 1353 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1354 */ 1355 ctor:function (t, scene, o) { 1356 cc.TransitionSceneOriented.prototype.ctor.call(this); 1357 o = o || cc.TRANSITION_ORIENTATION_RIGHT_OVER; 1358 scene && this.initWithDuration(t, scene, o); 1359 }, 1360 /** 1361 * custom on enter 1362 */ 1363 onEnter:function () { 1364 cc.TransitionScene.prototype.onEnter.call(this); 1365 1366 var inA, outA; 1367 this._inScene.visible = false; 1368 1369 var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ; 1370 if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) { 1371 inDeltaZ = 90; 1372 inAngleZ = 270; 1373 outDeltaZ = 90; 1374 outAngleZ = 0; 1375 } else { 1376 inDeltaZ = -90; 1377 inAngleZ = 90; 1378 outDeltaZ = -90; 1379 outAngleZ = 0; 1380 } 1381 1382 inA = cc.sequence( 1383 cc.delayTime(this._duration / 2), 1384 cc.spawn( 1385 cc.orbitCamera(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0), 1386 cc.scaleTo(this._duration / 2, 1), cc.show()), 1387 cc.show(), 1388 cc.callFunc(this.finish, this)); 1389 outA = cc.sequence( 1390 cc.spawn( 1391 cc.orbitCamera(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0), 1392 cc.scaleTo(this._duration / 2, 0.5)), 1393 cc.hide(), cc.delayTime(this._duration / 2)); 1394 1395 this._inScene.scale = 0.5; 1396 this._inScene.runAction(inA); 1397 this._outScene.runAction(outA); 1398 } 1399 }); 1400 1401 /** 1402 * Flips the screen half horizontally and half vertically doing a little zooming out/in.<br/> 1403 * The front face is the outgoing scene and the back face is the incoming scene. 1404 * @deprecated since v3.0,please use new new cc.TransitionZoomFlipAngular(t, scene, o) instead 1405 * @param {Number} t time in seconds 1406 * @param {cc.Scene} scene 1407 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1408 * @return {cc.TransitionZoomFlipAngular} 1409 * @example 1410 * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER 1411 * //OR 1412 * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER) 1413 */ 1414 cc.TransitionZoomFlipAngular.create = function (t, scene, o) { 1415 return new cc.TransitionZoomFlipAngular(t, scene, o); 1416 }; 1417 1418 /** 1419 * Fade out the outgoing scene and then fade in the incoming scene. 1420 * @class 1421 * @extends cc.TransitionScene 1422 * @param {Number} t time in seconds 1423 * @param {cc.Scene} scene 1424 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1425 * @example 1426 * var trans = new cc.TransitionFade(time,scene,color) 1427 */ 1428 cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{ 1429 _color:null, 1430 1431 /** 1432 * Constructor of TransitionFade 1433 * @param {Number} t time in seconds 1434 * @param {cc.Scene} scene 1435 * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o 1436 */ 1437 ctor:function (t, scene, color) { 1438 cc.TransitionScene.prototype.ctor.call(this); 1439 this._color = cc.color(); 1440 scene && this.initWithDuration(t, scene, color); 1441 }, 1442 1443 /** 1444 * custom on enter 1445 */ 1446 onEnter:function () { 1447 cc.TransitionScene.prototype.onEnter.call(this); 1448 1449 var l = new cc.LayerColor(this._color); 1450 this._inScene.visible = false; 1451 1452 this.addChild(l, 2, cc.SCENE_FADE); 1453 var f = this.getChildByTag(cc.SCENE_FADE); 1454 1455 var a = cc.sequence( 1456 cc.fadeIn(this._duration / 2), 1457 cc.callFunc(this.hideOutShowIn, this), 1458 cc.fadeOut(this._duration / 2), 1459 cc.callFunc(this.finish, this) 1460 ); 1461 f.runAction(a); 1462 }, 1463 1464 /** 1465 * custom on exit 1466 */ 1467 onExit:function () { 1468 cc.TransitionScene.prototype.onExit.call(this); 1469 this.removeChildByTag(cc.SCENE_FADE, false); 1470 }, 1471 1472 /** 1473 * initializes the transition with a duration and with an RGB color 1474 * @param {Number} t time in seconds 1475 * @param {cc.Scene} scene 1476 * @param {cc.Color} color 1477 * @return {Boolean} 1478 */ 1479 initWithDuration:function (t, scene, color) { 1480 color = color || cc.color.BLACK; 1481 if (cc.TransitionScene.prototype.initWithDuration.call(this, t, scene)) { 1482 this._color.r = color.r; 1483 this._color.g = color.g; 1484 this._color.b = color.b; 1485 this._color.a = 0; 1486 } 1487 return true; 1488 } 1489 }); 1490 1491 1492 /** 1493 * Fade out the outgoing scene and then fade in the incoming scene. 1494 * @deprecated since v3.0,please use new cc.TransitionFade(time,scene,color) instead. 1495 * @param {Number} t time in seconds 1496 * @param {cc.Scene} scene 1497 * @param {cc.Color} color 1498 * @return {cc.TransitionFade} 1499 * @example 1500 * var myTransition = cc.TransitionFade.create(1.5, nextScene, cc.color(255,0,0))//fade to red 1501 */ 1502 cc.TransitionFade.create = function (t, scene, color) { 1503 return new cc.TransitionFade(t, scene, color); 1504 }; 1505 1506 /** 1507 * Cross fades two scenes using the cc.RenderTexture object. 1508 * @class 1509 * @extends cc.TransitionScene 1510 * @param {Number} t time in seconds 1511 * @param {cc.Scene} scene 1512 * @example 1513 * var trans = new cc.TransitionCrossFade(time,scene); 1514 */ 1515 cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCrossFade# */{ 1516 /** 1517 * Constructor of TransitionCrossFade 1518 * @param {Number} t time in seconds 1519 * @param {cc.Scene} scene 1520 */ 1521 ctor:function (t, scene) { 1522 cc.TransitionScene.prototype.ctor.call(this); 1523 scene && this.initWithDuration(t, scene); 1524 }, 1525 /** 1526 * custom on enter 1527 */ 1528 onEnter:function () { 1529 cc.TransitionScene.prototype.onEnter.call(this); 1530 1531 // create a transparent color layer 1532 // in which we are going to add our rendertextures 1533 var color = cc.color(0, 0, 0, 0); 1534 var winSize = cc.director.getWinSize(); 1535 var layer = cc.LayerColor.create(color); 1536 1537 // create the first render texture for inScene 1538 var inTexture = cc.RenderTexture.create(winSize.width, winSize.height); 1539 1540 if (null == inTexture) 1541 return; 1542 1543 inTexture.sprite.anchorX = 0.5; 1544 inTexture.sprite.anchorY = 0.5; 1545 inTexture.attr({ 1546 x: winSize.width / 2, 1547 y: winSize.height / 2, 1548 anchorX: 0.5, 1549 anchorY: 0.5 1550 }); 1551 1552 // render inScene to its texturebuffer 1553 inTexture.begin(); 1554 this._inScene.visit(); 1555 inTexture.end(); 1556 1557 // create the second render texture for outScene 1558 var outTexture = cc.RenderTexture.create(winSize.width, winSize.height); 1559 outTexture.setPosition(winSize.width / 2, winSize.height / 2); 1560 outTexture.sprite.anchorX = outTexture.anchorX = 0.5; 1561 outTexture.sprite.anchorY = outTexture.anchorY = 0.5; 1562 1563 // render outScene to its texturebuffer 1564 outTexture.begin(); 1565 this._outScene.visit(); 1566 outTexture.end(); 1567 1568 inTexture.sprite.setBlendFunc(cc.ONE, cc.ONE); // inScene will lay on background and will not be used with alpha 1569 outTexture.sprite.setBlendFunc(cc.SRC_ALPHA, cc.ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha 1570 1571 // add render textures to the layer 1572 layer.addChild(inTexture); 1573 layer.addChild(outTexture); 1574 1575 // initial opacity: 1576 inTexture.sprite.opacity = 255; 1577 outTexture.sprite.opacity = 255; 1578 1579 // create the blend action 1580 var layerAction = cc.sequence( 1581 cc.fadeTo(this._duration, 0), cc.callFunc(this.hideOutShowIn, this), 1582 cc.callFunc(this.finish, this) 1583 ); 1584 1585 // run the blend action 1586 outTexture.sprite.runAction(layerAction); 1587 1588 // add the layer (which contains our two rendertextures) to the scene 1589 this.addChild(layer, 2, cc.SCENE_FADE); 1590 }, 1591 1592 /** 1593 * custom on exit 1594 */ 1595 onExit:function () { 1596 this.removeChildByTag(cc.SCENE_FADE, false); 1597 cc.TransitionScene.prototype.onExit.call(this); 1598 }, 1599 1600 /** 1601 * overide draw 1602 */ 1603 draw:function () { 1604 // override draw since both scenes (textures) are rendered in 1 scene 1605 } 1606 }); 1607 1608 /** 1609 * Cross fades two scenes using the cc.RenderTexture object. 1610 * @deprecated since v3.0,please use new cc.TransitionCrossFade(t, scene) instead. 1611 * @param {Number} t time in seconds 1612 * @param {cc.Scene} scene 1613 * @return {cc.TransitionCrossFade} 1614 * @example 1615 * var myTransition = cc.TransitionCrossFade.create(1.5, nextScene) 1616 */ 1617 cc.TransitionCrossFade.create = function (t, scene) { 1618 return new cc.TransitionCrossFade(t, scene); 1619 }; 1620 1621 /** 1622 * Turn off the tiles of the outgoing scene in random order 1623 * @class 1624 * @extends cc.TransitionScene 1625 * @param {Number} t time in seconds 1626 * @param {cc.Scene} scene 1627 * @example 1628 * var trans = new cc.TransitionTurnOffTiles(time,scene); 1629 */ 1630 cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTurnOffTiles# */{ 1631 1632 /** 1633 * Constructor of TransitionCrossFade 1634 * @param {Number} t time in seconds 1635 * @param {cc.Scene} scene 1636 */ 1637 ctor:function (t, scene) { 1638 cc.TransitionScene.prototype.ctor.call(this); 1639 scene && this.initWithDuration(t, scene); 1640 }, 1641 1642 _sceneOrder:function () { 1643 this._isInSceneOnTop = false; 1644 }, 1645 1646 /** 1647 * custom on enter 1648 */ 1649 onEnter:function () { 1650 cc.TransitionScene.prototype.onEnter.call(this); 1651 var winSize = cc.director.getWinSize(); 1652 var aspect = winSize.width / winSize.height; 1653 var x = 0 | (12 * aspect); 1654 var y = 12; 1655 var toff = cc.turnOffTiles(this._duration, cc.size(x, y)); 1656 var action = this.easeActionWithAction(toff); 1657 this._outScene.runAction(cc.sequence(action, cc.callFunc(this.finish, this), cc.stopGrid())); 1658 }, 1659 1660 /** 1661 * @param {cc.ActionInterval} action 1662 * @return {cc.ActionInterval} 1663 */ 1664 easeActionWithAction:function (action) { 1665 return action; 1666 } 1667 }); 1668 1669 /** 1670 * Turn off the tiles of the outgoing scene in random order 1671 * @deprecated since v3.0,please use new cc.TransitionTurnOffTiles(t, scene) instead. 1672 * @param {Number} t time in seconds 1673 * @param {cc.Scene} scene 1674 * @return {cc.TransitionTurnOffTiles} 1675 * @example 1676 * var myTransition = cc.TransitionTurnOffTiles.create(1.5, nextScene) 1677 */ 1678 cc.TransitionTurnOffTiles.create = function (t, scene) { 1679 return new cc.TransitionTurnOffTiles(t, scene); 1680 }; 1681 1682 /** 1683 * The odd columns goes upwards while the even columns goes downwards. 1684 * @class 1685 * @extends cc.TransitionScene 1686 * @param {Number} t time in seconds 1687 * @param {cc.Scene} scene 1688 * @example 1689 * var trans = new cc.TransitionSplitCols(time,scene); 1690 */ 1691 cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplitCols# */{ 1692 1693 /** 1694 * Constructor of TransitionSplitCols 1695 * @param {Number} t time in seconds 1696 * @param {cc.Scene} scene 1697 */ 1698 ctor:function (t, scene) { 1699 cc.TransitionScene.prototype.ctor.call(this); 1700 scene && this.initWithDuration(t, scene); 1701 }, 1702 /** 1703 * custom on enter 1704 */ 1705 onEnter:function () { 1706 cc.TransitionScene.prototype.onEnter.call(this); 1707 this._inScene.visible = false; 1708 1709 var split = this.action(); 1710 var seq = cc.sequence( 1711 split, cc.callFunc(this.hideOutShowIn, this), split.reverse()); 1712 1713 this.runAction( 1714 cc.sequence(this.easeActionWithAction(seq), cc.callFunc(this.finish, this), cc.stopGrid()) 1715 ); 1716 }, 1717 1718 /** 1719 * @param {cc.ActionInterval} action 1720 * @return {cc.EaseInOut} 1721 */ 1722 easeActionWithAction:function (action) { 1723 return new cc.EaseInOut(action, 3.0); 1724 }, 1725 1726 /** 1727 * @return {*} 1728 */ 1729 action:function () { 1730 return cc.splitCols(this._duration / 2.0, 3); 1731 } 1732 }); 1733 1734 /** 1735 * The odd columns goes upwards while the even columns goes downwards. 1736 * @deprecated since v3.0,please use new cc.TransitionSplitCols(t, scene) instead. 1737 * @param {Number} t time in seconds 1738 * @param {cc.Scene} scene 1739 * @return {cc.TransitionSplitCols} 1740 * @example 1741 * var myTransition = cc.TransitionSplitCols.create(1.5, nextScene) 1742 */ 1743 cc.TransitionSplitCols.create = function (t, scene) { 1744 return new cc.TransitionSplitCols(t, scene); 1745 }; 1746 1747 /** 1748 * The odd rows goes to the left while the even rows goes to the right. 1749 * @class 1750 * @extends cc.TransitionSplitCols 1751 * @param {Number} t time in seconds 1752 * @param {cc.Scene} scene 1753 * @example 1754 * var trans = new cc.TransitionSplitRows(time,scene); 1755 */ 1756 cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionSplitRows# */{ 1757 1758 /** 1759 * Constructor of TransitionSplitRows 1760 * @param {Number} t time in seconds 1761 * @param {cc.Scene} scene 1762 */ 1763 ctor:function (t, scene) { 1764 cc.TransitionSplitCols.prototype.ctor.call(this); 1765 scene && this.initWithDuration(t, scene); 1766 }, 1767 /** 1768 * @return {*} 1769 */ 1770 action:function () { 1771 return cc.splitRows(this._duration / 2.0, 3); 1772 } 1773 }); 1774 1775 /** 1776 * The odd rows goes to the left while the even rows goes to the right. 1777 * @deprecated since v3.0,please use new cc.TransitionSplitRows(t, scene) instead. 1778 * @param {Number} t time in seconds 1779 * @param {cc.Scene} scene 1780 * @return {cc.TransitionSplitRows} 1781 * @example 1782 * var myTransition = cc.TransitionSplitRows.create(1.5, nextScene) 1783 */ 1784 cc.TransitionSplitRows.create = function (t, scene) { 1785 return new cc.TransitionSplitRows(t, scene); 1786 }; 1787 1788 /** 1789 * Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner. 1790 * @class 1791 * @extends cc.TransitionScene 1792 * @param {Number} t time in seconds 1793 * @param {cc.Scene} scene 1794 * @example 1795 * var trans = new cc.TransitionFadeTR(time,scene); 1796 */ 1797 cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# */{ 1798 1799 /** 1800 * Constructor of TransitionFadeTR 1801 * @param {Number} t time in seconds 1802 * @param {cc.Scene} scene 1803 */ 1804 ctor:function (t, scene) { 1805 cc.TransitionScene.prototype.ctor.call(this); 1806 scene && this.initWithDuration(t, scene); 1807 }, 1808 _sceneOrder:function () { 1809 this._isInSceneOnTop = false; 1810 }, 1811 1812 /** 1813 * Custom on enter 1814 */ 1815 onEnter:function () { 1816 cc.TransitionScene.prototype.onEnter.call(this); 1817 1818 var winSize = cc.director.getWinSize(); 1819 var aspect = winSize.width / winSize.height; 1820 var x = 0 | (12 * aspect); 1821 var y = 12; 1822 1823 var action = this.actionWithSize(cc.size(x, y)); 1824 this._outScene.runAction( 1825 cc.Sequence.create(this.easeActionWithAction(action), cc.CallFunc.create(this.finish, this), 1826 cc.StopGrid.create()) 1827 ); 1828 }, 1829 1830 /** 1831 * @param {cc.ActionInterval} action 1832 * @return {cc.ActionInterval} 1833 */ 1834 easeActionWithAction:function (action) { 1835 return action; 1836 }, 1837 1838 /** 1839 * @param {cc.Size} size 1840 * @return {*} 1841 */ 1842 actionWithSize:function (size) { 1843 return cc.fadeOutTRTiles(this._duration, size); 1844 } 1845 }); 1846 1847 /** 1848 * Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner. 1849 * @deprecated since v3.0 please use new cc.TransitionFadeTR(t, scene) instead. 1850 * @param {Number} t time in seconds 1851 * @param {cc.Scene} scene 1852 * @return {cc.TransitionFadeTR} 1853 * @example 1854 * var myTransition = cc.TransitionFadeTR.create(1.5, nextScene) 1855 */ 1856 cc.TransitionFadeTR.create = function (t, scene) { 1857 return new cc.TransitionFadeTR(t, scene); 1858 }; 1859 1860 /** 1861 * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. 1862 * @class 1863 * @extends cc.TransitionFadeTR 1864 * @param {Number} t time in seconds 1865 * @param {cc.Scene} scene 1866 * @example 1867 * var trans = new cc.TransitionFadeBL(time,scene) 1868 */ 1869 cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# */{ 1870 /** 1871 * Constructor of TransitionFadeBL 1872 * @param {Number} t time in seconds 1873 * @param {cc.Scene} scene 1874 */ 1875 ctor:function (t, scene) { 1876 cc.TransitionFadeTR.prototype.ctor.call(this); 1877 scene && this.initWithDuration(t, scene); 1878 }, 1879 1880 /** 1881 * @param {cc.Size} size 1882 * @return {*} 1883 */ 1884 actionWithSize:function (size) { 1885 return cc.fadeOutBLTiles(this._duration, size); 1886 } 1887 }); 1888 1889 /** 1890 * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. 1891 * @deprecated since v3.0,please use new cc.TransitionFadeBL(t, scene); 1892 * @param {Number} t time in seconds 1893 * @param {cc.Scene} scene 1894 * @return {cc.TransitionFadeBL} 1895 * @example 1896 * // Example 1897 * var myTransition = cc.TransitionFadeBL.create(1.5, nextScene) 1898 */ 1899 cc.TransitionFadeBL.create = function (t, scene) { 1900 return new cc.TransitionFadeBL(t, scene); 1901 }; 1902 1903 /** 1904 * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. 1905 * @class 1906 * @extends cc.TransitionFadeTR 1907 * @param {Number} t time in seconds 1908 * @param {cc.Scene} scene 1909 * @example 1910 * var trans = new cc.TransitionFadeUp(time,scene); 1911 */ 1912 cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# */{ 1913 1914 /** 1915 * Constructor of TransitionFadeUp 1916 * @function 1917 * @param {Number} t time in seconds 1918 * @param {cc.Scene} scene 1919 */ 1920 ctor:function (t, scene) { 1921 cc.TransitionFadeTR.prototype.ctor.call(this); 1922 scene && this.initWithDuration(t, scene); 1923 }, 1924 1925 /** 1926 * @param {cc.Size} size 1927 * @return {cc.FadeOutUpTiles} 1928 */ 1929 actionWithSize:function (size) { 1930 return new cc.FadeOutUpTiles(this._duration, size); 1931 } 1932 }); 1933 1934 /** 1935 * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner. 1936 * @deprecated since v3.0,please use new cc.TransitionFadeUp(t, scene) instead. 1937 * @param {Number} t time in seconds 1938 * @param {cc.Scene} scene 1939 * @return {cc.TransitionFadeUp} 1940 * @example 1941 * var myTransition = cc.TransitionFadeUp.create(1.5, nextScene) 1942 */ 1943 cc.TransitionFadeUp.create = function (t, scene) { 1944 return new cc.TransitionFadeUp(t, scene); 1945 }; 1946 1947 /** 1948 * Fade the tiles of the outgoing scene from the top to the bottom. 1949 * @class 1950 * @extends cc.TransitionFadeTR 1951 * @param {Number} t time in seconds 1952 * @param {cc.Scene} scene 1953 * @example 1954 * var trans = new cc.TransitionFadeDown(time,scene); 1955 */ 1956 cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeDown# */{ 1957 1958 /** 1959 * Constructor of TransitionFadeDown 1960 * @param {Number} t time in seconds 1961 * @param {cc.Scene} scene 1962 */ 1963 ctor:function (t, scene) { 1964 cc.TransitionFadeTR.prototype.ctor.call(this); 1965 scene && this.initWithDuration(t, scene); 1966 }, 1967 1968 /** 1969 * @param {cc.Size} size 1970 * @return {*} 1971 */ 1972 actionWithSize:function (size) { 1973 return cc.fadeOutDownTiles( this._duration, size); 1974 } 1975 }); 1976 1977 /** 1978 * Fade the tiles of the outgoing scene from the top to the bottom. 1979 * @deprecated since v3.0,please use new cc.TransitionFadeDown(t, scene) instead. 1980 * @param {Number} t time in seconds 1981 * @param {cc.Scene} scene 1982 * @return {cc.TransitionFadeDown} 1983 * @example 1984 * var myTransition = cc.TransitionFadeDown.create(1.5, nextScene) 1985 */ 1986 cc.TransitionFadeDown.create = function (t, scene) { 1987 return new cc.TransitionFadeDown(t, scene); 1988 }; 1989