Cocos2d如何切换场景
Cocos2d How do I switch scenes
所以我有 mainScene 和 LogoScene,我想知道是否可以让 logoscene 显示徽标,然后过渡到主场景。
这是我的
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());
}
}
所以我有 mainScene 和 LogoScene,我想知道是否可以让 logoscene 显示徽标,然后过渡到主场景。
场景之间的转换
Check here
这是我用的:
auto scene = SecondClass::createScene();
auto transition = TransitionShrinkGrow::create(1.0, scene);
Director::getInstance()->pushScene(transition);
一个类似于你的问题check link
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 场景:[比赛场景]]];
所以我有 mainScene 和 LogoScene,我想知道是否可以让 logoscene 显示徽标,然后过渡到主场景。
这是我的
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());
}
}
所以我有 mainScene 和 LogoScene,我想知道是否可以让 logoscene 显示徽标,然后过渡到主场景。
场景之间的转换 Check here
这是我用的:
auto scene = SecondClass::createScene();
auto transition = TransitionShrinkGrow::create(1.0, scene);
Director::getInstance()->pushScene(transition);
一个类似于你的问题check link
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 场景:[比赛场景]]];