1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 11:12:55 +08:00
osu-lazer/osu.Game/Graphics/Background/Background.cs
Thomas Müller 68476eafb9 Use DrawSize instead of Size whereever Size was previously read due to framework changes.
Note, that this was just stupid replacement. Many components will likely want to actually read Size and not DrawSize. We may want to do a pass over this at some point, but for now everything is working like this. (Old behavior.)
2016-10-18 18:53:31 +02:00

48 lines
1.3 KiB
C#

//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;
using osu.Framework;
namespace osu.Game.Graphics.Background
{
class Background : Container
{
protected Sprite BackgroundSprite;
string textureName;
public Background(string textureName = @"Backgrounds/bg1")
{
this.textureName = textureName;
RelativeSizeAxes = Axes.Both;
Depth = float.MinValue;
}
public override void Load(BaseGame game)
{
base.Load(game);
Add(BackgroundSprite = new Sprite
{
Texture = game.Textures.Get(textureName),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.DarkGray
});
}
protected override void Update()
{
base.Update();
BackgroundSprite.Scale = new Vector2(Math.Max(DrawSize.X / BackgroundSprite.DrawSize.X, DrawSize.Y / BackgroundSprite.DrawSize.Y));
}
}
}