/
MenuItem.cs
67 lines (61 loc) · 1.77 KB
/
MenuItem.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
namespace Glider
{
class MenuItem
{
#region Declarations
private Rectangle frame; //location of the menu item on the screen
#endregion
#region Constructor
/// <summary>
/// Creates a new menu item.
/// </summary>
/// <param name="frame">Location of the menu item on the screen.</param>
public MenuItem(Rectangle frame)
{
this.frame = frame;
}
#endregion
#region Menu Item Properties
/// <summary>
/// Gets the center of the menu item.
/// </summary>
public Vector2 Center
{
get { return new Vector2(frame.X + (Width / 2), frame.Y + (Height / 2)); }
}
/// <summary>
/// Gets the width of the menu item.
/// </summary>
public float Width
{
get { return frame.Width; }
}
/// <summary>
/// Gets the height of the menu item.
/// </summary>
public float Height
{
get { return frame.Height; }
}
/// <summary>
/// Gets the bounds of the menu item for touching purposes.
/// </summary>
public Rectangle HitBounds
{
get
{
Rectangle bounds = new Rectangle((int)(Center.X - Width / 2),
(int)(Center.Y - Height / 2),
(int)Width,
(int)Height);
return bounds;
}
}
#endregion
}
}