osu/osu.Game/Graphics/Background/Background.cs

51 lines
1.5 KiB
C#
Raw Normal View History

2016-09-30 09:45:55 +00: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;
using osu.Framework.Graphics.Containers;
2016-10-10 08:17:26 +00:00
using osu.Framework;
2016-11-01 14:24:14 +00:00
using System.Threading.Tasks;
2016-11-08 23:13:20 +00:00
using osu.Framework.Graphics.Textures;
using osu.Framework.Allocation;
2016-09-30 09:45:55 +00:00
namespace osu.Game.Graphics.Background
{
class Background : Container
2016-09-30 09:45:55 +00:00
{
protected Sprite BackgroundSprite;
2016-10-05 07:35:10 +00:00
string textureName;
2016-10-05 11:03:52 +00:00
public Background(string textureName = @"Backgrounds/bg1")
{
2016-10-05 07:35:10 +00:00
this.textureName = textureName;
RelativeSizeAxes = Axes.Both;
2016-10-05 07:35:10 +00:00
Depth = float.MinValue;
2016-09-30 09:45:55 +00:00
Add(BackgroundSprite = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.DarkGray
});
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
BackgroundSprite.Texture = textures.Get(textureName);
}
2016-09-30 09:45:55 +00:00
protected override void Update()
{
base.Update();
BackgroundSprite.Scale = new Vector2(Math.Max(DrawSize.X / BackgroundSprite.DrawSize.X, DrawSize.Y / BackgroundSprite.DrawSize.Y));
2016-09-30 09:45:55 +00:00
}
}
}