using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Content; namespace FaceOff { class SubmitButton : GameObject { Texture2D button; Texture2D pushed; //the bounding box for collision private BoundingBox collisionBox; public BoundingBox CollisionBox { get { return collisionBox; } set { collisionBox = value; } } //bool that is true when the button is clicked private bool isClicked; public bool Clicked { get { return isClicked; } set { isClicked = value; } } public void initialize() { isClicked = false; } public void SetPosition(float x, float y) { Position = new Vector2(x, y); collisionBox = new BoundingBox(new Vector3(x, y, 0), new Vector3((x + Texture.Width), (y + Texture.Height), 0)); } public void LoadContent(ContentManager content) { button = content.Load(@"Texture\Submit_Button"); pushed = content.Load(@"Texture\Submit_Pressed"); Texture = button; } /// /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// /// Provides a snapshot of timing values. public void Update(GameTime gameTime) { if (isClicked == true) { Texture = pushed; } else { Texture = button; } } public void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch) { spriteBatch.Draw(Texture, Position, null, Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 1.0f); } } }