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