1

我尝试在我的第一个 cocossharp 游戏中编写启动画面,就像在 android 应用程序中编写启动画面一样。但是,它显示一个黑屏,然后直接进入游戏场景。那么我应该改变什么?非常感谢!

public class SplashScene : CCScene
{
    CCSprite splashImage1;
    CCSprite splashImage2;
    CCLayer splashLayer;

    public SplashScene (CCWindow mainWindow) : base(mainWindow)
    {
        splashLayer = new CCLayer ();
        this.AddChild (splashLayer);

        splashImage1 = new CCSprite ("Splash1");
        splashImage1.Position = ContentSize.Center;
        splashImage1.IsAntialiased = false;

        splashImage2 = new CCSprite ("Splash2");
        splashImage2.Position = ContentSize.Center;
        splashImage2.IsAntialiased = false;
    }

    public void PerformSplash()
    {
        splashLayer.AddChild (splashImage1);
        Thread.Sleep(3000);
        splashLayer.RemoveChild(splashImage1);

        splashLayer.AddChild (splashImage2);
        Thread.Sleep(2000);
        splashLayer.RemoveChild (splashImage2);

        GameAppDelegate.GoToGameScene ();
    }
}
4

1 回答 1

1

游戏循环必须针对任何要显示和更新的游戏框架运行。调用以Thread.Sleep暂停线程的执行。

如果您想在一段时间内显示启动画面,最好的方法是简单地按原样创建启动画面,然后安排一个动作序列

这样的东西会等待2s,然后移除splashLayer,进入游戏场景。

auto seq = Sequence::create(
  DelayTime::create(2.0),
  CallFunc::create([=](){
    splashLayer->removeFromParent();
    GameAppDelegate.GoToGameScene();
  }),
  nullptr);
runAction(seq);
于 2015-09-16T05:41:24.050 回答