I am making a game using XNA and a part of the game involves collecting drops. I have this code below that detects intersection between the character and the item:
//Intersection Code, If the character intersects with the item while the item is showing, run below
if (alive && charRange.Intersects(itemRect))
{
alive = false; //stop showing the item
Inv.ItemGot(); //Call the ItemGot class, which adds the item to the inventory screen
}
Another class contains the ItemGot()
method, and the code for that is below:
public void ItemGot()
{ // Called from the ItemList class...
// Sets the background color to black when called
btnItems[0] = new Panel();
btnItems[0].BackColor = Color.Black;
}
Basically, when the character intersects with the item rectangle, the color of btnItems[0]
should turn from CornflowerBlue
(which I set up earlier) to Black
. However, the color does not change when the method is called and I don't know why. My code seems to be correct and I've had peers confirm that for me.