public ClickableBase(Game game, Rectangle rectangle, ScreenAllocation allocation = ScreenAllocation.TopLeft, Action action = null) : base(game) { _rectangle = rectangle; _allocation = allocation; _action = action; }
protected Vector2 GetScreenPosition(Vector2 offset, ScreenAllocation allocation) { Vector2 result = Vector2.Zero; float Width = GraphicsDevice.Viewport.Width; float HalfWidth = GraphicsDevice.Viewport.Width / 2; float Height = GraphicsDevice.Viewport.Height; float HalfHeight = GraphicsDevice.Viewport.Height / 2; switch (allocation) { case ScreenAllocation.Top: result = new Vector2(HalfWidth, offset.Y); break; case ScreenAllocation.TopRight: result = new Vector2(Width - offset.X, offset.Y); break; case ScreenAllocation.Right: result = new Vector2(Width - offset.X, HalfHeight); break; case ScreenAllocation.BottomRight: result = new Vector2(Width - offset.X, Height - offset.Y); break; case ScreenAllocation.Bottom: result = new Vector2(HalfWidth, Height - offset.Y); break; case ScreenAllocation.BottomLeft: result = new Vector2(offset.X, Height - offset.Y); break; case ScreenAllocation.Left: result = new Vector2(offset.X, HalfHeight); break; case ScreenAllocation.TopLeft: result = new Vector2(offset.X, offset.Y); break; } return(result); }
public Button(Game game, string textureName, Rectangle rectangle, ScreenAllocation allocation, Action action) : base(game, rectangle, allocation, action) { _textureName = textureName; }