public bool Collides(clsSprite otherSprite) { // Check if two sprites collide if (this.position.X + this.size.X > otherSprite.position.X && this.position.X < otherSprite.position.X + otherSprite.size.X && this.position.Y + this.size.Y > otherSprite.position.Y && this.position.Y < otherSprite.position.Y + otherSprite.size.Y) return true; else return false; }
protected override void LoadContent() { mySprite1 = new clsSprite(Content.Load<Texture2D>("ball"), new Vector2(0f, 0f), new Vector2(64f, 64f),graphics.PreferredBackBufferWidth,graphics.PreferredBackBufferHeight); mySprite1.velocity = new Vector2(1, 1); mySprite2 = new clsSprite(Content.Load<Texture2D>("ball"), new Vector2(218f, 118f), new Vector2(64f, 64f), graphics.PreferredBackBufferWidth,graphics.PreferredBackBufferHeight); mySprite2.velocity = new Vector2(3, -3); spriteBatch = new SpriteBatch(GraphicsDevice); }