【问题标题】:Splash screen not working for Cocossharp game启动画面不适用于 Cocossharp 游戏
【发布时间】:2015-09-16 05:22:38
【问题描述】:

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

【问题讨论】:

    标签: c# xamarin cocos2d-x cocos2d-android cocossharp


    【解决方案1】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多