sn0wfall sn0wfall - 5 months ago 24
Android Question

Cocos2d How do I switch scenes

So I have mainScene and I have LogoScene, I am wondering If i can make logoscene show a logo, then transition to mainscene.

here is what i have

import org.cocos2d.layers.CCLayer;
import org.cocos2d.layers.CCScene;
import org.cocos2d.menus.CCMenu;
import org.cocos2d.menus.CCMenuItemImage;
import org.cocos2d.nodes.CCDirector;
import org.cocos2d.nodes.CCSprite;
import org.cocos2d.types.CGPoint;
import org.cocos2d.types.CGSize;

import android.graphics.Color;
import android.graphics.Rect;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;


public class LogoScene extends CCLayer {
public static CCScene scene() {
CCScene scene = CCScene.node();
LogoScene layer = new LogoScene();
scene.addChild(layer);
return scene;
}

public LogoScene() {
super();
this.init();

}



CCSprite pSpNameText = CCSprite.sprite("img/logo_name_textfield.png");
pSpNameText.setPosition(CGPoint.ccp(1080, 300));
this.addChild(pSpNameText, 0);
= bingo.getLayout();
layout.removeAllViews();


CCDirector.sharedDirector().replaceScene(MainScene.scene());
}
}


So I have mainScene and I have LogoScene, I am wondering If i can make logoscene show a logo, then transition to mainscene.

Answer

Transitioning between Scenes Check here

This is what I use:

auto scene = SecondClass::createScene();
auto transition = TransitionShrinkGrow::create(1.0, scene);
Director::getInstance()->pushScene(transition);

A question similar to your's check link

[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[Race scene] ]];