启动画面不适用于 Cocossharp 游戏

Splash screen not working for Cocossharp game

我尝试在我的第一个 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 ();
    }
}

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

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

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

auto seq = Sequence::create(
  DelayTime::create(2.0),
  CallFunc::create([=](){
    splashLayer->removeFromParent();
    GameAppDelegate.GoToGameScene();
  }),
  nullptr);
runAction(seq);