Switching among scenes with translation Animations

Hi

I want to play small translation animation while switching from scene1 to scene2.I have used cc.game.addPersistRootNode(this.transitNode) to store scene1 node , but while switching to scene2 my scene2 got scaled down . please take a look in code

cc.Class({
extends: cc.Component,

properties: {
    label: {
        default: null,
        type: cc.Label
    },
    // defaults, set visually when attaching this script to the Canvas
    text: 'Hello, World!'
},

// use this for initialization
onLoad: function () {
    
    this.label.string = this.text;
    var self = this;

    this.transitNode = this.node;
    cc.game.addPersistRootNode(this.transitNode);
    this.node.on(cc.Node.EventType.TOUCH_END, function(event){
        
        cc.director.loadScene("scene2",function(err, data){
        
            //self.transitNode.removeFromParent();
            cc.game.removePersistRootNode(self.transitNode);
            //delete(self.transitNode);
            
            
            cc.log(self)
        });
    });
},

});

What version of Cocos Creator do you use?

Cocos Creator Version V2.1.0

You need to put the resident node in the root directory.
Do your two scenes have the same resolution, and do you use the same adaptation strategy?

Yes i have same resolution, and i am using the same adaptation strategy. Can you give a simple example having small transition effect between two scenes.

Hi all
after doing lots of brainstorming i got solution which contains transition between scenes,

cc.Class({
extends: cc.Component,

properties: {
    label: {
        default: null,
        type: cc.Label
    },
    // defaults, set visually when attaching this script to the Canvas
    text: 'Hello, World!'
},

// use this for initialization
onLoad: function () {
    var self = this;
    window.persistNode = this.node.getChildByName("container")//create container at root of scene and add all nodes as child of this container
    this.label.string = this.text;
    
    this.node.on(cc.Node.EventType.TOUCH_END, function(event){
        window.persistNode.removeFromParent();
        cc.game.addPersistRootNode(window.persistNode);
       //reset position to center of screen, its necessary  
        window.persistNode.setPosition(cc.v2(cc.view.getVisibleSize().width/2,cc.view.getVisibleSize().height/2));
        self.switchScene2();
    });

},

switchScene2 :function(){
    cc.director.loadScene("scene2",function(err, data){
        var loginNode = cc.director.getScene();
        var containerLogin = loginNode.getChildByName('Canvas').getChildByName('container');
        containerLogin.setPosition(cc.v2(1280,0));

        var sequence = cc.spawn(cc.moveBy(0.5, cc.v2(-1280, 0)), 
            cc.callFunc(function () {
               
                cc.game.removePersistRootNode(window.persistNode);
                delete(window.persistNode)
            }
        ));

        window.persistNode.runAction(cc.spawn(sequence, 
                cc.callFunc(function () {
                    var action2 =  cc.moveBy(.5, cc.v2(-1280, 0));
                    containerLogin.runAction(action2);
                }
            )       
        ));

    });
}

});

good job!

read ans , good job!

2 days ago
Hi
I am using cocos Creator version 2.1 and need to get openGL reference in AppController.mm file, while writing code
cocos2d::Director::getInstance()->getOpenGLView() , i am not able to find reference , please let me know how to get openGL reference.
I am able to find CCEAGLView reference as follows
glView = (CCEAGLView *)appController->_viewController.view;

How do we get glview as below code is not working for me while building native app using cocosCreator 2.1

auto director = cocos2d::Director::getInstance();
auto glview = director->getOpenGLView();//not working…