private void InitializeGameOverSprites() { _gameOverSprite = new Sprite(this, "textures/gameOver"); _gameOverSprite.Hide(); _gameOverSprite.DisableClick(); _gameOverSprite.CenterHorizontally(); _gameOverSprite.CenterVertically(); AddComponent(_gameOverSprite, "Sprites"); _gameOverSprite.Click += (sender, e) => SceneManager.PlayPreviousScene(); }
protected override void Load() { if (_hasBeenLoaded) return; _hasBeenLoaded = true; AddGroup("Environment"); AddGroup("Models"); AddGroup("Sprites"); var camera = new MainMenuCamera(this, Camera.Default().Between(0.1f, 1000.0f).Wide(MathHelper.PiOver4)); AddComponent(camera); SetCurrentCamera(camera); AddComponent(new SkyGlobe(this, "models/SkyGlobeTexture", 200.0f), "Environment"); AddComponent(new Sprite(this, "textures/logo").FillScreen(), "Sprites"); _startGameMenuItem = new Sprite(this, "textures/startGame"); AddComponent(_startGameMenuItem, "Sprites"); _fadeOutAnimation = new TextureFadeAnimation(this, "textures/blank", BuildTransition.Between(1.0f, 0.0f) .Within(TimeSpan.FromSeconds(0.5f)) .InterpolateWith(MathHelper.Lerp) .Auditable() .Instance()); AddComponent(_fadeOutAnimation, "Sprites"); _fadeInAnimation = new TextureFadeAnimation(this, "textures/blank", BuildTransition.Between(0.0f, 1.0f) .Within(TimeSpan.FromSeconds(0.5f)) .InterpolateWith(MathHelper.SmoothStep) .Auditable() .Instance()); AddComponent(_fadeInAnimation, "Sprites"); _startGameMenuItem.Click += (sender, e) => { _startGameMenuItem.DisableClick(); _fadeInAnimation.Start(SceneManager.PlayNextScene); }; _startGameMenuItem.DisableClick() .SetPosition(new Vector2(0.0f, 340.0f)) .CenterHorizontally(); base.Load(); }