1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00
osu-lazer/osu.Game/Screens/BackgroundScreen.cs
2019-01-24 19:47:44 +09:00

72 lines
2.0 KiB
C#

// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Screens;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osuTK;
namespace osu.Game.Screens
{
public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen>
{
protected BackgroundScreen()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
public virtual bool Equals(BackgroundScreen other)
{
return other?.GetType() == GetType();
}
private const float transition_length = 500;
private const float x_movement_amount = 50;
protected override bool OnKeyDown(KeyDownEvent e)
{
//we don't want to handle escape key.
return false;
}
protected override void Update()
{
base.Update();
Scale = new Vector2(1 + x_movement_amount / DrawSize.X * 2);
}
public override void OnEntering(IScreen last)
{
this.FadeOut();
this.MoveToX(x_movement_amount);
this.FadeIn(transition_length, Easing.InOutQuart);
this.MoveToX(0, transition_length, Easing.InOutQuart);
base.OnEntering(last);
}
public override void OnSuspending(IScreen next)
{
this.MoveToX(-x_movement_amount, transition_length, Easing.InOutQuart);
base.OnSuspending(next);
}
public override bool OnExiting(IScreen next)
{
this.FadeOut(transition_length, Easing.OutExpo);
this.MoveToX(x_movement_amount, transition_length, Easing.OutExpo);
return base.OnExiting(next);
}
public override void OnResuming(IScreen last)
{
this.MoveToX(0, transition_length, Easing.OutExpo);
base.OnResuming(last);
}
}
}