So I have a TileSprite
class that makes a TileSprite
object with a collision box in it named bCollisionRect
:
public TileSprite(Texture2D textureImage, Vector2 position, Point frameSize, Point currentFrame)
: base (textureImage, position, frameSize, currentFrame)
{
bCollisionRect = new Rectangle((int)position.X + collisionOffSet, (int)position.Y + collisionOffSet, frameSize.X - (collisionOffSet * 2), frameSize.Y - (collisionOffSet * 2));
}
But when I try to draw the collision boxes (to test collision detection), it doesn't draw the box. I tried using this:
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
// This is what I tried:
spriteBatch.Draw(textureImage, bCollisionRect, Color.White);
// base.Draw draws the texture (.Draw method from another abstract class)
base.Draw(gameTime, spriteBatch);
}
I use this line of code in another class to draw my tiles (pure for testing!):
tilename.Draw(gameTime, spriteBatch);
textureImage
but that just draws the tile again(I saw this when I used your values, because I saw a little tile, the same as the tile I drew). So do I need to use a texture for the collision box astextureImage
? \$\endgroup\$ – Jelle Nov 4 '15 at 17:38