1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 16:22:57 +08:00
osu-lazer/osu.Game/Graphics/Containers/ParallaxContainer.cs

47 lines
1.2 KiB
C#
Raw Normal View History

2016-09-30 17:45:55 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Input;
using OpenTK;
2016-10-10 16:17:26 +08:00
using osu.Framework;
2016-09-30 17:45:55 +08:00
namespace osu.Game.Graphics.Containers
{
class ParallaxContainer : Container
2016-09-30 17:45:55 +08:00
{
public float ParallaxAmount = 0.02f;
public override bool Contains(Vector2 screenSpacePos) => true;
public ParallaxContainer()
2016-09-30 17:45:55 +08:00
{
RelativeSizeAxes = Axes.Both;
AddInternal(content = new Container()
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
});
}
private Container content;
2016-09-30 17:45:55 +08:00
protected override Container Content => content;
2016-09-30 17:45:55 +08:00
2016-11-01 22:24:14 +08:00
protected 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
}
protected override bool OnMouseMove(InputState state)
{
content.Position = (state.Mouse.Position - DrawSize / 2) * ParallaxAmount;
2016-09-30 17:45:55 +08:00
return base.OnMouseMove(state);
}
protected override void Update()
{
base.Update();
content.Scale = new Vector2(1 + ParallaxAmount);
}
}
}