Cocos2d如何切换场景

时间:2016-07-02 02:49:53

标签: c# android cocos2d-iphone cocos2d-x cocos2d-android

所以我有mainScene而且我有LogoScene,我想知道如果我可以让logoscene显示一个标识,然后过渡到mainscene。

这是我的

    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显示一个标识,然后过渡到mainscene。

1 个答案:

答案 0 :(得分:0)

场景之间的转换 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 scene:[Race scene]]];