Звучит больше как проблема дизайна, чем проблема реализации. По сути, вам нужна идея, чтобы вы начали. Я не слишком знаком с WP7, но покажу вам базовый дизайн, который вы можете использовать; с некоторым кодом sudo, который вы можете заполнить позже.
class Button
{
private Point CellSize;
public Point Position {get; set;}
private Texture2D buttonSheet;
public Button (Texture2D texture, Point CellSize)
{
this.buttonSheet = texture;
this.CellSize = CellSize;
}
public bool isPressed {get; private set;}
public void Update (bool isPressed)
{
this.isPressed = isPressed;
}
public void Draw (SpriteBatch sb)
{
Rectangle Source = new Rectangle (0,0,CellSize.X,CellSize.Y);
if (this.isPressed)
Source = new Rectangle (CellSize.X * 1, CellSize.Y * 1, CellSize.X, CellSize.Y);
sb.Draw (this.buttonSheet, new Rectangle(this.Position.X,this.Position.Y,CellSize.X,CellSize.Y), Source, Color.White);
}
}
А затем использовать его:
class Game1
{
Button Start = new Button(new Texture2D() /*load and include your texture here*/, new Point (100, 50) /* 100 wide, 50 tall cells */);
public Update (GameTime gt)
{
bool clicked = false /* Put code here to check if the button is pressed */;
Start.Update(clicked);
}
public Draw (SpriteBatch spriteBatch)
{
Start.Draw(spriteBatch);
}
}
(заметка не проверяла этот код)
Надеюсь, что это поможет вам начать, не стесняйтесь уточнять, если вам нужна дополнительная информация по конкретной части.
Max