2016-09-30 17:45:55 +08:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2016-10-01 14:02:38 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2016-10-10 16:17:26 +08:00
|
|
|
|
using osu.Framework;
|
2016-09-30 17:45:55 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Background
|
|
|
|
|
{
|
2016-10-01 17:40:14 +08:00
|
|
|
|
class Background : Container
|
2016-09-30 17:45:55 +08:00
|
|
|
|
{
|
|
|
|
|
protected Sprite BackgroundSprite;
|
|
|
|
|
|
2016-10-05 15:35:10 +08:00
|
|
|
|
string textureName;
|
|
|
|
|
|
2016-10-05 19:03:52 +08:00
|
|
|
|
public Background(string textureName = @"Backgrounds/bg1")
|
2016-10-01 17:40:14 +08:00
|
|
|
|
{
|
2016-10-05 15:35:10 +08:00
|
|
|
|
this.textureName = textureName;
|
2016-10-01 17:40:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2016-10-05 15:35:10 +08:00
|
|
|
|
Depth = float.MinValue;
|
2016-10-01 17:40:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 16:17:26 +08:00
|
|
|
|
public override void Load(BaseGame game)
|
2016-09-30 17:45:55 +08:00
|
|
|
|
{
|
2016-10-10 16:17:26 +08:00
|
|
|
|
base.Load(game);
|
2016-09-30 17:45:55 +08:00
|
|
|
|
|
|
|
|
|
Add(BackgroundSprite = new Sprite
|
|
|
|
|
{
|
2016-10-10 16:17:26 +08:00
|
|
|
|
Texture = game.Textures.Get(textureName),
|
2016-09-30 17:45:55 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Colour = Color4.DarkGray
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2016-10-01 17:40:14 +08:00
|
|
|
|
BackgroundSprite.Scale = new Vector2(Math.Max(Size.X / BackgroundSprite.Size.X, Size.Y / BackgroundSprite.Size.Y));
|
2016-09-30 17:45:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|