12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691 |
- /****************************************************************************
- Copyright (c) 2010-2012 cocos2d-x.org
- Copyright (c) 2008-2010 Ricardo Quesada
- Copyright (c) 2011 Zynga Inc.
- http://www.cocos2d-x.org
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
- /**
- * A tag constant for identifying fade scenes
- * @constant
- * @type Number
- */
- cc.SCENE_FADE = 4208917214;
- /**
- * cc.TransitionEaseScene can ease the actions of the scene protocol.
- * @class
- * @extends cc.Class
- */
- cc.TransitionEaseScene = cc.Class.extend(/** @lends cc.TransitionEaseScene# */{
- /**
- * returns the Ease action that will be performed on a linear action.
- */
- easeActionWithAction:function () {
- }
- });
- /**
- * horizontal orientation Type where the Left is nearer
- * @constant
- * @type Number
- */
- cc.TRANSITION_ORIENTATION_LEFT_OVER = 0;
- /**
- * horizontal orientation type where the Right is nearer
- * @constant
- * @type Number
- */
- cc.TRANSITION_ORIENTATION_RIGHT_OVER = 1;
- /**
- * vertical orientation type where the Up is nearer
- * @constant
- * @type Number
- */
- cc.TRANSITION_ORIENTATION_UP_OVER = 0;
- /**
- * vertical orientation type where the Bottom is nearer
- * @constant
- * @type Number
- */
- cc.TRANSITION_ORIENTATION_DOWN_OVER = 1;
- /**
- * @class
- * @extends cc.Scene
- */
- cc.TransitionScene = cc.Scene.extend(/** @lends cc.TransitionScene# */{
- _inScene:null,
- _outScene:null,
- _duration:null,
- _isInSceneOnTop:false,
- _isSendCleanupToScene:false,
- //private
- _setNewScene:function (dt) {
- this.unschedule(this._setNewScene);
- // Before replacing, save the "send cleanup to scene"
- var director = cc.Director.getInstance();
- this._isSendCleanupToScene = director.isSendCleanupToScene();
- director.replaceScene(this._inScene);
- // enable events while transitions
- if(cc.TouchDispatcher)
- director.getTouchDispatcher().setDispatchEvents(true);
- // issue #267
- this._outScene.setVisible(true);
- },
- //protected
- _sceneOrder:function () {
- this._isInSceneOnTop = true;
- },
- /**
- * stuff gets drawn here
- */
- draw:function () {
- if (this._isInSceneOnTop) {
- this._outScene.visit();
- this._inScene.visit();
- } else {
- this._inScene.visit();
- this._outScene.visit();
- }
- },
- /**
- * custom onEnter
- */
- onEnter:function () {
- cc.Node.prototype.onEnter.call(this);
- // disable events while transitions
- if(cc.TouchDispatcher)
- cc.Director.getInstance().getTouchDispatcher().setDispatchEvents(false);
- // outScene should not receive the onEnter callback
- // only the onExitTransitionDidStart
- this._outScene.onExitTransitionDidStart();
- this._inScene.onEnter();
- },
- /**
- * custom onExit
- */
- onExit:function () {
- cc.Node.prototype.onExit.call(this);
- // enable events while transitions
- if(cc.TouchDispatcher)
- cc.Director.getInstance().getTouchDispatcher().setDispatchEvents(true);
- this._outScene.onExit();
- // _inScene should not receive the onEnter callback
- // only the onEnterTransitionDidFinish
- this._inScene.onEnterTransitionDidFinish();
- },
- /**
- * custom cleanup
- */
- cleanup:function () {
- cc.Node.prototype.cleanup.call(this);
- if (this._isSendCleanupToScene)
- this._outScene.cleanup();
- },
- /**
- * initializes a transition with duration and incoming scene
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene a scene to transit to
- * @return {Boolean} return false if error
- */
- initWithDuration:function (t, scene) {
- if(!scene)
- throw "cc.TransitionScene.initWithDuration(): Argument scene must be non-nil";
- if (this.init()) {
- this._duration = t;
- this.setAnchorPoint(0, 0);
- this.setPosition(0, 0);
- // retain
- this._inScene = scene;
- this._outScene = cc.Director.getInstance().getRunningScene();
- if (!this._outScene) {
- this._outScene = cc.Scene.create();
- this._outScene.init();
- }
- if(this._inScene == this._outScene)
- throw "cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene";
- this._sceneOrder();
- return true;
- } else {
- return false;
- }
- },
- /**
- * called after the transition finishes
- */
- finish:function () {
- // clean up
- this._inScene.setVisible(true);
- this._inScene.setPosition(0, 0);
- this._inScene.setScale(1.0);
- this._inScene.setRotation(0.0);
- if(cc.renderContextType === cc.WEBGL)
- this._inScene.getCamera().restore();
- this._outScene.setVisible(false);
- this._outScene.setPosition(0, 0);
- this._outScene.setScale(1.0);
- this._outScene.setRotation(0.0);
- if(cc.renderContextType === cc.WEBGL)
- this._outScene.getCamera().restore();
- //[self schedule:@selector(setNewScene:) interval:0];
- this.schedule(this._setNewScene, 0);
- },
- /**
- * set hide the out scene and show in scene
- */
- hideOutShowIn:function () {
- this._inScene.setVisible(true);
- this._outScene.setVisible(false);
- }
- });
- /**
- * creates a base transition with duration and incoming scene
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene the scene to transit with
- * @return {cc.TransitionScene|Null}
- */
- cc.TransitionScene.create = function (t, scene) {
- var tempScene = new cc.TransitionScene();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * A cc.Transition that supports orientation like.<br/>
- * Possible orientation: LeftOver, RightOver, UpOver, DownOver<br/>
- * useful for when you want to make a transition happen between 2 orientations
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionSceneOriented = cc.TransitionScene.extend(/** @lends cc.TransitionSceneOriented# */{
- _orientation:0,
- /**
- * initialize the transition
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation
- * @return {Boolean}
- */
- initWithDuration:function (t, scene, orientation) {
- if (cc.TransitionScene.prototype.initWithDuration.call(this, t, scene)) {
- this._orientation = orientation;
- }
- return true;
- }
- });
- /**
- * creates a base transition with duration and incoming scene
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} orientation
- * @return {cc.TransitionSceneOriented}
- * @example
- * // Example
- * var goHorizontal = cc.TransitionSceneOriented.create(0.5, thisScene, cc.TRANSITION_ORIENTATION_LEFT_OVER)
- */
- cc.TransitionSceneOriented.create = function (t, scene, orientation) {
- var tempScene = new cc.TransitionSceneOriented();
- tempScene.initWithDuration(t, scene, orientation);
- return tempScene;
- };
- /**
- * Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionRotoZoom = cc.TransitionScene.extend(/** @lends cc.TransitionRotoZoom# */{
- /**
- * Custom On Enter callback
- * @override
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- this._inScene.setScale(0.001);
- this._outScene.setScale(1.0);
- this._inScene.setAnchorPoint(0.5, 0.5);
- this._outScene.setAnchorPoint(0.5, 0.5);
- var rotoZoom = cc.Sequence.create(
- cc.Spawn.create(cc.ScaleBy.create(this._duration / 2, 0.001),
- cc.RotateBy.create(this._duration / 2, 360 * 2)),
- cc.DelayTime.create(this._duration / 2));
- this._outScene.runAction(rotoZoom);
- this._inScene.runAction(
- cc.Sequence.create(rotoZoom.reverse(),
- cc.CallFunc.create(this.finish, this)));
- }
- });
- /**
- * Creates a Transtion rotation and zoom
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene the scene to work with
- * @return {cc.TransitionRotoZoom}
- * @example
- * // Example
- * var RotoZoomTrans = cc.TransitionRotoZoom.create(2, nextScene);
- */
- cc.TransitionRotoZoom.create = function (t, scene) {
- var tempScene = new cc.TransitionRotoZoom();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Zoom out and jump the outgoing scene, and then jump and zoom in the incoming
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionJumpZoom = cc.TransitionScene.extend(/** @lends cc.TransitionJumpZoom# */{
- /**
- * Custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var winSize = cc.Director.getInstance().getWinSize();
- this._inScene.setScale(0.5);
- this._inScene.setPosition(winSize.width, 0);
- this._inScene.setAnchorPoint(0.5, 0.5);
- this._outScene.setAnchorPoint(0.5, 0.5);
- var jump = cc.JumpBy.create(this._duration / 4, cc.p(-winSize.width, 0), winSize.width / 4, 2);
- var scaleIn = cc.ScaleTo.create(this._duration / 4, 1.0);
- var scaleOut = cc.ScaleTo.create(this._duration / 4, 0.5);
- var jumpZoomOut = cc.Sequence.create(scaleOut, jump);
- var jumpZoomIn = cc.Sequence.create(jump, scaleIn);
- var delay = cc.DelayTime.create(this._duration / 2);
- this._outScene.runAction(jumpZoomOut);
- this._inScene.runAction(cc.Sequence.create(delay, jumpZoomIn, cc.CallFunc.create(this.finish, this)));
- }
- });
- /**
- * creates a scene transition that zooms then jump across the screen, the same for the incoming scene
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionJumpZoom}
- */
- cc.TransitionJumpZoom.create = function (t, scene) {
- var tempScene = new cc.TransitionJumpZoom();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Move in from to the left the incoming scene.
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionMoveInL = cc.TransitionScene.extend(/** @lends cc.TransitionMoveInL# */{
- /**
- * Custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- this.initScenes();
- var action = this.action();
- this._inScene.runAction(
- cc.Sequence.create(this.easeActionWithAction(action), cc.CallFunc.create(this.finish, this))
- );
- },
- /**
- * initializes the scenes
- */
- initScenes:function () {
- this._inScene.setPosition(-cc.Director.getInstance().getWinSize().width, 0);
- },
- /**
- * returns the action that will be performed
- */
- action:function () {
- return cc.MoveTo.create(this._duration, cc.p(0, 0));
- },
- /**
- * creates an ease action from action
- * @param {cc.ActionInterval} action
- * @return {cc.EaseOut}
- */
- easeActionWithAction:function (action) {
- return cc.EaseOut.create(action, 2.0);
- }
- });
- /**
- * creates an action that Move in from to the left the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionMoveInL}
- * @example
- * // Example
- * var MoveInLeft = cc.TransitionMoveInL.create(1, nextScene)
- */
- cc.TransitionMoveInL.create = function (t, scene) {
- var tempScene = new cc.TransitionMoveInL();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Move in from to the right the incoming scene.
- * @class
- * @extends cc.TransitionMoveInL
- */
- cc.TransitionMoveInR = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInR# */{
- /**
- * Init
- */
- initScenes:function () {
- this._inScene.setPosition(cc.Director.getInstance().getWinSize().width, 0);
- }
- });
- /**
- * create a scene transition that Move in from to the right the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionMoveInR}
- * @example
- * // Example
- * var MoveInRight = cc.TransitionMoveInR.create(1, nextScene)
- */
- cc.TransitionMoveInR.create = function (t, scene) {
- var tempScene = new cc.TransitionMoveInR();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Move in from to the top the incoming scene.
- * @class
- * @extends cc.TransitionMoveInL
- */
- cc.TransitionMoveInT = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInT# */{
- /**
- * init
- */
- initScenes:function () {
- this._inScene.setPosition(0, cc.Director.getInstance().getWinSize().height);
- }
- });
- /**
- * Move in from to the top the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionMoveInT}
- * @example
- * // Example
- * var MoveInTop = cc.TransitionMoveInT.create(1, nextScene)
- */
- cc.TransitionMoveInT.create = function (t, scene) {
- var tempScene = new cc.TransitionMoveInT();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Move in from to the bottom the incoming scene.
- * @class
- * @extends cc.TransitionMoveInL
- */
- cc.TransitionMoveInB = cc.TransitionMoveInL.extend(/** @lends cc.TransitionMoveInB# */{
- /**
- * init
- */
- initScenes:function () {
- this._inScene.setPosition(0, -cc.Director.getInstance().getWinSize().height);
- }
- });
- /**
- * create a scene transition that Move in from to the bottom the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionMoveInB}
- * @example
- * // Example
- * var MoveinB = cc.TransitionMoveInB.create(1, nextScene)
- */
- cc.TransitionMoveInB.create = function (t, scene) {
- var tempScene = new cc.TransitionMoveInB();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * The adjust factor is needed to prevent issue #442<br/>
- * One solution is to use DONT_RENDER_IN_SUBPIXELS images, but NO<br/>
- * The other issue is that in some transitions (and I don't know why)<br/>
- * the order should be reversed (In in top of Out or vice-versa).
- * @constant
- * @type Number
- */
- cc.ADJUST_FACTOR = 0.5;
- /**
- * a transition that a new scene is slided from left
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionSlideInL = cc.TransitionScene.extend(/** @lends cc.TransitionSlideInL# */{
- _sceneOrder:function () {
- this._isInSceneOnTop = false;
- },
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- this.initScenes();
- var inA = this.action();
- var outA = this.action();
- var inAction = this.easeActionWithAction(inA);
- var outAction = cc.Sequence.create(this.easeActionWithAction(outA), cc.CallFunc.create(this.finish, this));
- this._inScene.runAction(inAction);
- this._outScene.runAction(outAction);
- },
- /**
- * initializes the scenes
- */
- initScenes:function () {
- this._inScene.setPosition(-(cc.Director.getInstance().getWinSize().width - cc.ADJUST_FACTOR), 0);
- },
- /**
- * returns the action that will be performed by the incomming and outgoing scene
- * @return {cc.MoveBy}
- */
- action:function () {
- return cc.MoveBy.create(this._duration, cc.p(cc.Director.getInstance().getWinSize().width - cc.ADJUST_FACTOR, 0));
- },
- /**
- * @param {cc.ActionInterval} action
- * @return {*}
- */
- easeActionWithAction:function (action) {
- return cc.EaseOut.create(action, 2.0);
- }
- });
- /**
- * create a transition that a new scene is slided from left
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionSlideInL}
- * @example
- * // Example
- * var myTransition = cc.TransitionSlideInL.create(1.5, nextScene)
- */
- cc.TransitionSlideInL.create = function (t, scene) {
- var tempScene = new cc.TransitionSlideInL();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Slide in the incoming scene from the right border.
- * @class
- * @extends cc.TransitionSlideInL
- */
- cc.TransitionSlideInR = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInR# */{
- _sceneOrder:function () {
- this._isInSceneOnTop = true;
- },
- /**
- * initializes the scenes
- */
- initScenes:function () {
- this._inScene.setPosition(cc.Director.getInstance().getWinSize().width - cc.ADJUST_FACTOR, 0);
- },
- /**
- * returns the action that will be performed by the incomming and outgoing scene
- * @return {cc.MoveBy}
- */
- action:function () {
- return cc.MoveBy.create(this._duration, cc.p(-(cc.Director.getInstance().getWinSize().width - cc.ADJUST_FACTOR), 0));
- }
- });
- /**
- * create Slide in the incoming scene from the right border.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionSlideInR}
- * @example
- * // Example
- * var myTransition = cc.TransitionSlideInR.create(1.5, nextScene)
- */
- cc.TransitionSlideInR.create = function (t, scene) {
- var tempScene = new cc.TransitionSlideInR();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Slide in the incoming scene from the bottom border.
- * @class
- * @extends cc.TransitionSlideInL
- */
- cc.TransitionSlideInB = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInB# */{
- _sceneOrder:function () {
- this._isInSceneOnTop = false;
- },
- /**
- * initializes the scenes
- */
- initScenes:function () {
- this._inScene.setPosition(0, cc.Director.getInstance().getWinSize().height - cc.ADJUST_FACTOR);
- },
- /**
- * returns the action that will be performed by the incomming and outgoing scene
- * @return {cc.MoveBy}
- */
- action:function () {
- return cc.MoveBy.create(this._duration, cc.p(0, -(cc.Director.getInstance().getWinSize().height - cc.ADJUST_FACTOR)));
- }
- });
- /**
- * create a Slide in the incoming scene from the bottom border.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionSlideInB}
- * @example
- * // Example
- * var myTransition = cc.TransitionSlideInB.create(1.5, nextScene)
- */
- cc.TransitionSlideInB.create = function (t, scene) {
- var tempScene = new cc.TransitionSlideInB();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Slide in the incoming scene from the top border.
- * @class
- * @extends cc.TransitionSlideInL
- */
- cc.TransitionSlideInT = cc.TransitionSlideInL.extend(/** @lends cc.TransitionSlideInT# */{
- _sceneOrder:function () {
- this._isInSceneOnTop = true;
- },
- /**
- * initializes the scenes
- */
- initScenes:function () {
- this._inScene.setPosition(0, -(cc.Director.getInstance().getWinSize().height - cc.ADJUST_FACTOR));
- },
- /**
- * returns the action that will be performed by the incomming and outgoing scene
- * @return {cc.MoveBy}
- */
- action:function () {
- return cc.MoveBy.create(this._duration, cc.p(0, cc.Director.getInstance().getWinSize().height - cc.ADJUST_FACTOR));
- }
- });
- /**
- * create a Slide in the incoming scene from the top border.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionSlideInT}
- * @example
- * // Example
- * var myTransition = cc.TransitionSlideInT.create(1.5, nextScene)
- */
- cc.TransitionSlideInT.create = function (t, scene) {
- var tempScene = new cc.TransitionSlideInT();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Shrink the outgoing scene while grow the incoming scene
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionShrinkGrow = cc.TransitionScene.extend(/** @lends cc.TransitionShrinkGrow# */{
- /**
- * Custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- this._inScene.setScale(0.001);
- this._outScene.setScale(1.0);
- this._inScene.setAnchorPoint(2 / 3.0, 0.5);
- this._outScene.setAnchorPoint(1 / 3.0, 0.5);
- var scaleOut = cc.ScaleTo.create(this._duration, 0.01);
- var scaleIn = cc.ScaleTo.create(this._duration, 1.0);
- this._inScene.runAction(this.easeActionWithAction(scaleIn));
- this._outScene.runAction(
- cc.Sequence.create(this.easeActionWithAction(scaleOut), cc.CallFunc.create(this.finish, this))
- );
- },
- /**
- * @param action
- * @return {cc.EaseOut}
- */
- easeActionWithAction:function (action) {
- return cc.EaseOut.create(action, 2.0);
- }
- });
- /**
- * Shrink the outgoing scene while grow the incoming scene
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionShrinkGrow}
- * @example
- * // Example
- * var myTransition = cc.TransitionShrinkGrow.create(1.5, nextScene)
- */
- cc.TransitionShrinkGrow.create = function (t, scene) {
- var tempScene = new cc.TransitionShrinkGrow();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Flips the screen horizontally.<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @class
- * @extends cc.TransitionSceneOriented
- */
- cc.TransitionFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipX# */{
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var inA, outA;
- this._inScene.setVisible(false);
- var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
- if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) {
- inDeltaZ = 90;
- inAngleZ = 270;
- outDeltaZ = 90;
- outAngleZ = 0;
- } else {
- inDeltaZ = -90;
- inAngleZ = 90;
- outDeltaZ = -90;
- outAngleZ = 0;
- }
- inA = cc.Sequence.create(
- cc.DelayTime.create(this._duration / 2), cc.Show.create(),
- cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0),
- cc.CallFunc.create(this.finish, this)
- );
- outA = cc.Sequence.create(
- cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0),
- cc.Hide.create(), cc.DelayTime.create(this._duration / 2)
- );
- this._inScene.runAction(inA);
- this._outScene.runAction(outA);
- }
- });
- /**
- * Flips the screen horizontally.<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
- * @return {cc.TransitionFlipX}
- * @example
- * // Example
- * var myTransition = cc.TransitionFlipX.create(1.5, nextScene) //default is cc.TRANSITION_ORIENTATION_RIGHT_OVER
- *
- * //OR
- * var myTransition = cc.TransitionFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_UP_OVER)
- */
- cc.TransitionFlipX.create = function (t, scene, o) {
- if (o == null)
- o = cc.TRANSITION_ORIENTATION_RIGHT_OVER;
- var tempScene = new cc.TransitionFlipX();
- tempScene.initWithDuration(t, scene, o);
- return tempScene;
- };
- /**
- * Flips the screen vertically.<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @class
- * @extends cc.TransitionSceneOriented
- */
- cc.TransitionFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipY# */{
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var inA, outA;
- this._inScene.setVisible(false);
- var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
- if (this._orientation == cc.TRANSITION_ORIENTATION_UP_OVER) {
- inDeltaZ = 90;
- inAngleZ = 270;
- outDeltaZ = 90;
- outAngleZ = 0;
- } else {
- inDeltaZ = -90;
- inAngleZ = 90;
- outDeltaZ = -90;
- outAngleZ = 0;
- }
- inA = cc.Sequence.create(
- cc.DelayTime.create(this._duration / 2), cc.Show.create(),
- cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
- cc.CallFunc.create(this.finish, this)
- );
- outA = cc.Sequence.create(
- cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0),
- cc.Hide.create(), cc.DelayTime.create(this._duration / 2)
- );
- this._inScene.runAction(inA);
- this._outScene.runAction(outA);
- }
- });
- /**
- * Flips the screen vertically.<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
- * @return {cc.TransitionFlipY}
- * @example
- * // Example
- * var myTransition = cc.TransitionFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER
- *
- * //OR
- * var myTransition = cc.TransitionFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_RIGHT_OVER)
- */
- cc.TransitionFlipY.create = function (t, scene, o) {
- if (o == null)
- o = cc.TRANSITION_ORIENTATION_UP_OVER;
- var tempScene = new cc.TransitionFlipY();
- tempScene.initWithDuration(t, scene, o);
- return tempScene;
- };
- /**
- * Flips the screen half horizontally and half vertically.<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @class
- * @extends cc.TransitionSceneOriented
- */
- cc.TransitionFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionFlipAngular# */{
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var inA, outA;
- this._inScene.setVisible(false);
- var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
- if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) {
- inDeltaZ = 90;
- inAngleZ = 270;
- outDeltaZ = 90;
- outAngleZ = 0;
- } else {
- inDeltaZ = -90;
- inAngleZ = 90;
- outDeltaZ = -90;
- outAngleZ = 0;
- }
- inA = cc.Sequence.create(
- cc.DelayTime.create(this._duration / 2), cc.Show.create(),
- cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
- cc.CallFunc.create(this.finish, this)
- );
- outA = cc.Sequence.create(
- cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0),
- cc.Hide.create(), cc.DelayTime.create(this._duration / 2)
- );
- this._inScene.runAction(inA);
- this._outScene.runAction(outA);
- }
- });
- /**
- * Flips the screen half horizontally and half vertically.<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
- * @return {cc.TransitionFlipAngular}
- * @example
- * // Example
- * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER
- *
- * //or
- * var myTransition = cc.TransitionFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER)
- */
- cc.TransitionFlipAngular.create = function (t, scene, o) {
- if (o == null)
- o = cc.TRANSITION_ORIENTATION_RIGHT_OVER;
- var tempScene = new cc.TransitionFlipAngular();
- tempScene.initWithDuration(t, scene, o);
- return tempScene;
- };
- /**
- * Flips the screen horizontally doing a zoom out/in<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @class
- * @extends cc.TransitionSceneOriented
- */
- cc.TransitionZoomFlipX = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipX# */{
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var inA, outA;
- this._inScene.setVisible(false);
- var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
- if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) {
- inDeltaZ = 90;
- inAngleZ = 270;
- outDeltaZ = 90;
- outAngleZ = 0;
- } else {
- inDeltaZ = -90;
- inAngleZ = 90;
- outDeltaZ = -90;
- outAngleZ = 0;
- }
- inA = cc.Sequence.create(
- cc.DelayTime.create(this._duration / 2),
- cc.Spawn.create(
- cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 0, 0),
- cc.ScaleTo.create(this._duration / 2, 1), cc.Show.create()),
- cc.CallFunc.create(this.finish, this)
- );
- outA = cc.Sequence.create(
- cc.Spawn.create(
- cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 0, 0),
- cc.ScaleTo.create(this._duration / 2, 0.5)),
- cc.Hide.create(),
- cc.DelayTime.create(this._duration / 2)
- );
- this._inScene.setScale(0.5);
- this._inScene.runAction(inA);
- this._outScene.runAction(outA);
- }
- });
- /**
- * Flips the screen horizontally doing a zoom out/in<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
- * @return {cc.TransitionZoomFlipX}
- * @example
- * // Example
- * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER
- *
- * //OR
- * var myTransition = cc.TransitionZoomFlipX.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER)
- */
- cc.TransitionZoomFlipX.create = function (t, scene, o) {
- if (o == null)
- o = cc.TRANSITION_ORIENTATION_RIGHT_OVER;
- var tempScene = new cc.TransitionZoomFlipX();
- tempScene.initWithDuration(t, scene, o);
- return tempScene;
- };
- /**
- * Flips the screen vertically doing a little zooming out/in<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @class
- * @extends cc.TransitionSceneOriented
- */
- cc.TransitionZoomFlipY = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipY# */{
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var inA, outA;
- this._inScene.setVisible(false);
- var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
- if (this._orientation === cc.TRANSITION_ORIENTATION_UP_OVER) {
- inDeltaZ = 90;
- inAngleZ = 270;
- outDeltaZ = 90;
- outAngleZ = 0;
- } else {
- inDeltaZ = -90;
- inAngleZ = 90;
- outDeltaZ = -90;
- outAngleZ = 0;
- }
- inA = cc.Sequence.create(
- cc.DelayTime.create(this._duration / 2),
- cc.Spawn.create(
- cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
- cc.ScaleTo.create(this._duration / 2, 1), cc.Show.create()),
- cc.CallFunc.create(this.finish, this));
- outA = cc.Sequence.create(
- cc.Spawn.create(
- cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0),
- cc.ScaleTo.create(this._duration / 2, 0.5)),
- cc.Hide.create(), cc.DelayTime.create(this._duration / 2));
- this._inScene.setScale(0.5);
- this._inScene.runAction(inA);
- this._outScene.runAction(outA);
- }
- });
- /**
- * Flips the screen vertically doing a little zooming out/in<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
- * @return {cc.TransitionZoomFlipY}
- * @example
- * // Example
- * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_UP_OVER
- *
- * //OR
- * var myTransition = cc.TransitionZoomFlipY.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER)
- */
- cc.TransitionZoomFlipY.create = function (t, scene, o) {
- if (o == null)
- o = cc.TRANSITION_ORIENTATION_UP_OVER;
- var tempScene = new cc.TransitionZoomFlipY();
- tempScene.initWithDuration(t, scene, o);
- return tempScene;
- };
- /**
- * Flips the screen half horizontally and half vertically doing a little zooming out/in.<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @class
- * @extends cc.TransitionSceneOriented
- */
- cc.TransitionZoomFlipAngular = cc.TransitionSceneOriented.extend(/** @lends cc.TransitionZoomFlipAngular# */{
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var inA, outA;
- this._inScene.setVisible(false);
- var inDeltaZ, inAngleZ, outDeltaZ, outAngleZ;
- if (this._orientation === cc.TRANSITION_ORIENTATION_RIGHT_OVER) {
- inDeltaZ = 90;
- inAngleZ = 270;
- outDeltaZ = 90;
- outAngleZ = 0;
- } else {
- inDeltaZ = -90;
- inAngleZ = 90;
- outDeltaZ = -90;
- outAngleZ = 0;
- }
- inA = cc.Sequence.create(
- cc.DelayTime.create(this._duration / 2),
- cc.Spawn.create(
- cc.OrbitCamera.create(this._duration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
- cc.ScaleTo.create(this._duration / 2, 1), cc.Show.create()),
- cc.Show.create(),
- cc.CallFunc.create(this.finish, this));
- outA = cc.Sequence.create(
- cc.Spawn.create(
- cc.OrbitCamera.create(this._duration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0),
- cc.ScaleTo.create(this._duration / 2, 0.5)),
- cc.Hide.create(), cc.DelayTime.create(this._duration / 2));
- this._inScene.setScale(0.5);
- this._inScene.runAction(inA);
- this._outScene.runAction(outA);
- }
- });
- /**
- * Flips the screen half horizontally and half vertically doing a little zooming out/in.<br/>
- * The front face is the outgoing scene and the back face is the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.TRANSITION_ORIENTATION_LEFT_OVER|cc.TRANSITION_ORIENTATION_RIGHT_OVER|cc.TRANSITION_ORIENTATION_UP_OVER|cc.TRANSITION_ORIENTATION_DOWN_OVER} o
- * @return {cc.TransitionZoomFlipAngular}
- * @example
- * // Example
- * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene)//default is cc.TRANSITION_ORIENTATION_RIGHT_OVER
- *
- * //OR
- * var myTransition = cc.TransitionZoomFlipAngular.create(1.5, nextScene, cc.TRANSITION_ORIENTATION_DOWN_OVER)
- */
- cc.TransitionZoomFlipAngular.create = function (t, scene, o) {
- if (o == null)
- o = cc.TRANSITION_ORIENTATION_RIGHT_OVER;
- var tempScene = new cc.TransitionZoomFlipAngular();
- tempScene.initWithDuration(t, scene, o);
- return tempScene;
- };
- /**
- * Fade out the outgoing scene and then fade in the incoming scene.
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionFade = cc.TransitionScene.extend(/** @lends cc.TransitionFade# */{
- _color:null,
- /**
- * Constructor
- */
- ctor:function () {
- cc.TransitionScene.prototype.ctor.call(this);
- this._color = new cc.Color4B()
- },
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var l = cc.LayerColor.create(this._color);
- this._inScene.setVisible(false);
- this.addChild(l, 2, cc.SCENE_FADE);
- var f = this.getChildByTag(cc.SCENE_FADE);
- var a = cc.Sequence.create(
- cc.FadeIn.create(this._duration / 2),
- cc.CallFunc.create(this.hideOutShowIn, this), //CCCallFunc.actionWithTarget:self selector:@selector(hideOutShowIn)],
- cc.FadeOut.create(this._duration / 2),
- cc.CallFunc.create(this.finish, this) //:self selector:@selector(finish)],
- );
- f.runAction(a);
- },
- /**
- * custom on exit
- */
- onExit:function () {
- cc.TransitionScene.prototype.onExit.call(this);
- this.removeChildByTag(cc.SCENE_FADE, false);
- },
- /**
- * initializes the transition with a duration and with an RGB color
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.Color3B} color
- * @return {Boolean}
- */
- initWithDuration:function (t, scene, color) {
- color = color || cc.black();
- if (cc.TransitionScene.prototype.initWithDuration.call(this, t, scene)) {
- this._color.r = color.r;
- this._color.g = color.g;
- this._color.b = color.b;
- this._color.a = 0;
- }
- return true;
- }
- });
- /**
- * Fade out the outgoing scene and then fade in the incoming scene.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @param {cc.Color3B} color
- * @return {cc.TransitionFade}
- * @example
- * // Example
- * var myTransition = cc.TransitionFade.create(1.5, nextScene, cc.c3b(255,0,0))//fade to red
- */
- cc.TransitionFade.create = function (t, scene, color) {
- var transition = new cc.TransitionFade();
- transition.initWithDuration(t, scene, color);
- return transition;
- };
- /**
- * Cross fades two scenes using the cc.RenderTexture object.
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionCrossFade = cc.TransitionScene.extend(/** @lends cc.TransitionCrossFade# */{
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- // create a transparent color layer
- // in which we are going to add our rendertextures
- var color = new cc.Color4B(0, 0, 0, 0);
- var winSize = cc.Director.getInstance().getWinSize();
- var layer = cc.LayerColor.create(color);
- // create the first render texture for inScene
- var inTexture = cc.RenderTexture.create(winSize.width, winSize.height);
- if (null == inTexture)
- return;
- inTexture.getSprite().setAnchorPoint(0.5, 0.5);
- inTexture.setPosition(winSize.width / 2, winSize.height / 2);
- inTexture.setAnchorPoint(0.5, 0.5);
- // render inScene to its texturebuffer
- inTexture.begin();
- this._inScene.visit();
- inTexture.end();
- // create the second render texture for outScene
- var outTexture = cc.RenderTexture.create(winSize.width, winSize.height);
- outTexture.getSprite().setAnchorPoint(0.5, 0.5);
- outTexture.setPosition(winSize.width / 2, winSize.height / 2);
- outTexture.setAnchorPoint(0.5, 0.5);
- // render outScene to its texturebuffer
- outTexture.begin();
- this._outScene.visit();
- outTexture.end();
- inTexture.getSprite().setBlendFunc(gl.ONE, gl.ONE); // inScene will lay on background and will not be used with alpha
- outTexture.getSprite().setBlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); // we are going to blend outScene via alpha
- // add render textures to the layer
- layer.addChild(inTexture);
- layer.addChild(outTexture);
- // initial opacity:
- inTexture.getSprite().setOpacity(255);
- outTexture.getSprite().setOpacity(255);
- // create the blend action
- var layerAction = cc.Sequence.create(
- cc.FadeTo.create(this._duration, 0), cc.CallFunc.create(this.hideOutShowIn, this),
- cc.CallFunc.create(this.finish, this)
- );
- // run the blend action
- outTexture.getSprite().runAction(layerAction);
- // add the layer (which contains our two rendertextures) to the scene
- this.addChild(layer, 2, cc.SCENE_FADE);
- },
- /**
- * custom on exit
- */
- onExit:function () {
- this.removeChildByTag(cc.SCENE_FADE, false);
- cc.TransitionScene.prototype.onExit.call(this);
- },
- /**
- * overide draw
- */
- draw:function () {
- // override draw since both scenes (textures) are rendered in 1 scene
- }
- });
- /**
- * Cross fades two scenes using the cc.RenderTexture object.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionCrossFade}
- * @example
- * // Example
- * var myTransition = cc.TransitionCrossFade.create(1.5, nextScene)
- */
- cc.TransitionCrossFade.create = function (t, scene) {
- var Transition = new cc.TransitionCrossFade();
- Transition.initWithDuration(t, scene);
- return Transition;
- };
- /**
- * Turn off the tiles of the outgoing scene in random order
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionTurnOffTiles = cc.TransitionScene.extend(/** @lends cc.TransitionTurnOffTiles# */{
- _sceneOrder:function () {
- this._isInSceneOnTop = false;
- },
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var winSize = cc.Director.getInstance().getWinSize();
- var aspect = winSize.width / winSize.height;
- var x = 0 | (12 * aspect);
- var y = 12;
- var toff = cc.TurnOffTiles.create(this._duration, cc.size(x, y));
- var action = this.easeActionWithAction(toff);
- this._outScene.runAction(cc.Sequence.create(action, cc.CallFunc.create(this.finish, this), cc.StopGrid.create()));
- },
- /**
- * @param {cc.ActionInterval} action
- * @return {cc.ActionInterval}
- */
- easeActionWithAction:function (action) {
- return action;
- }
- });
- /**
- * Turn off the tiles of the outgoing scene in random order
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionTurnOffTiles}
- * @example
- * // Example
- * var myTransition = cc.TransitionTurnOffTiles.create(1.5, nextScene)
- */
- cc.TransitionTurnOffTiles.create = function (t, scene) {
- var tempScene = new cc.TransitionTurnOffTiles();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * The odd columns goes upwards while the even columns goes downwards.
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionSplitCols = cc.TransitionScene.extend(/** @lends cc.TransitionSplitCols# */{
- /**
- * custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- this._inScene.setVisible(false);
- var split = this.action();
- var seq = cc.Sequence.create(
- split, cc.CallFunc.create(this.hideOutShowIn, this), split.reverse());
- this.runAction(
- cc.Sequence.create(this.easeActionWithAction(seq), cc.CallFunc.create(this.finish, this), cc.StopGrid.create())
- );
- },
- /**
- * @param {cc.ActionInterval} action
- * @return {cc.EaseInOut}
- */
- easeActionWithAction:function (action) {
- return cc.EaseInOut.create(action, 3.0);
- },
- /**
- * @return {*}
- */
- action:function () {
- return cc.SplitCols.create(this._duration / 2.0, 3);
- }
- });
- /**
- * The odd columns goes upwards while the even columns goes downwards.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionSplitCols}
- * @example
- * // Example
- * var myTransition = cc.TransitionSplitCols.create(1.5, nextScene)
- */
- cc.TransitionSplitCols.create = function (t, scene) {
- var tempScene = new cc.TransitionSplitCols();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * The odd rows goes to the left while the even rows goes to the right.
- * @class
- * @extends cc.TransitionSplitCols
- */
- cc.TransitionSplitRows = cc.TransitionSplitCols.extend(/** @lends cc.TransitionSplitRows# */{
- /**
- * @return {*}
- */
- action:function () {
- return cc.SplitRows.create(this._duration / 2.0, 3);
- }
- });
- /**
- * The odd rows goes to the left while the even rows goes to the right.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionSplitRows}
- * @example
- * // Example
- * var myTransition = cc.TransitionSplitRows.create(1.5, nextScene)
- */
- cc.TransitionSplitRows.create = function (t, scene) {
- var tempScene = new cc.TransitionSplitRows();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner.
- * @class
- * @extends cc.TransitionScene
- */
- cc.TransitionFadeTR = cc.TransitionScene.extend(/** @lends cc.TransitionFadeTR# */{
- _sceneOrder:function () {
- this._isInSceneOnTop = false;
- },
- /**
- * Custom on enter
- */
- onEnter:function () {
- cc.TransitionScene.prototype.onEnter.call(this);
- var winSize = cc.Director.getInstance().getWinSize();
- var aspect = winSize.width / winSize.height;
- var x = 0 | (12 * aspect);
- var y = 12;
- var action = this.actionWithSize(cc.size(x, y));
- this._outScene.runAction(
- cc.Sequence.create(this.easeActionWithAction(action), cc.CallFunc.create(this.finish, this),
- cc.StopGrid.create())
- );
- },
- /**
- * @param {cc.ActionInterval} action
- * @return {cc.ActionInterval}
- */
- easeActionWithAction:function (action) {
- return action;
- },
- /**
- * @param {cc.Size} size
- * @return {*}
- */
- actionWithSize:function (size) {
- return cc.FadeOutTRTiles.create(this._duration, size);
- }
- });
- /**
- * Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionFadeTR}
- * @example
- * // Example
- * var myTransition = cc.TransitionFadeTR.create(1.5, nextScene)
- */
- cc.TransitionFadeTR.create = function (t, scene) {
- var tempScene = new cc.TransitionFadeTR();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene)))
- return tempScene;
- return null;
- };
- /**
- * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
- * @class
- * @extends cc.TransitionFadeTR
- */
- cc.TransitionFadeBL = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeBL# */{
- /**
- * @param {cc.Size} size
- * @return {*}
- */
- actionWithSize:function (size) {
- return cc.FadeOutBLTiles.create(this._duration, size);
- }
- });
- /**
- * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionFadeBL}
- * @example
- * // Example
- * var myTransition = cc.TransitionFadeBL.create(1.5, nextScene)
- */
- cc.TransitionFadeBL.create = function (t, scene) {
- var tempScene = new cc.TransitionFadeBL();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene)))
- return tempScene;
- return null;
- };
- /**
- * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
- * @class
- * @extends cc.TransitionFadeTR
- */
- cc.TransitionFadeUp = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeUp# */{
- /**
- * @param {cc.Size} size
- * @return {*}
- */
- actionWithSize:function (size) {
- return cc.FadeOutUpTiles.create(this._duration, size);
- }
- });
- /**
- * Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionFadeUp}
- * @example
- * // Example
- * var myTransition = cc.TransitionFadeUp.create(1.5, nextScene)
- */
- cc.TransitionFadeUp.create = function (t, scene) {
- var tempScene = new cc.TransitionFadeUp();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
- /**
- * Fade the tiles of the outgoing scene from the top to the bottom.
- * @class
- * @extends cc.TransitionFadeTR
- */
- cc.TransitionFadeDown = cc.TransitionFadeTR.extend(/** @lends cc.TransitionFadeDown# */{
- /**
- * @param {cc.Size} size
- * @return {*}
- */
- actionWithSize:function (size) {
- return cc.FadeOutDownTiles.create( this._duration, size);
- }
- });
- /**
- * Fade the tiles of the outgoing scene from the top to the bottom.
- * @param {Number} t time in seconds
- * @param {cc.Scene} scene
- * @return {cc.TransitionFadeDown}
- * @example
- * // Example
- * var myTransition = cc.TransitionFadeDown.create(1.5, nextScene)
- */
- cc.TransitionFadeDown.create = function (t, scene) {
- var tempScene = new cc.TransitionFadeDown();
- if ((tempScene != null) && (tempScene.initWithDuration(t, scene))) {
- return tempScene;
- }
- return null;
- };
|