• 12
• 12
• 9
• 10
• 13

Texture not drawing

This topic is 1279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have two different types of items in two different slots. I've already determined that the texture is being loaded correctly, theyre not draw over each other, and the item type of the slot being drawn in is correct. When I pick up an item, the texture of the item is drawn in the first slot. When I pick up the second item, nothing is drawn in the slot, but the number counter increments by 1 showing that I have indeed picked up the item. I'm stumped.

        public void DrawInventoryItems(SpriteBatch sb)
{
foreach(InventorySlot slot in itemSlots)
{
/*if (slot.item is Twig)
{
sb.Draw(slot.item.Texture, Position, slot.SlotRectangle, Color.White);
}

if (slot.item is Rock)
{
sb.Draw(slot.item.Texture, Position, slot.SlotRectangle, Color.White);
}*/
if (slot.IsSlotOpen == false)
{
sb.Draw(slot.item.Texture, Position, slot.SlotRectangle, Color.White);
}
}
}


Commented code is there to look pretty I guess.

Position is the position of the inventory texture, which is pretty much just 5 outlines of boxes.

                itemSlots[i].SlotRectangle = new Rectangle((int)Position.X + i * 64, (int)Position.Y, 64, 64);


The slot rectangles just tell me where to start the next slot. So my item in the second slot has a vector 2 of (64, 0) and 3 with (128, 0) and so on.

Share on other sites

Are you trying to draw two different areas of the texture next to each other?  If so, are you changing the Position parameter between the Draw calls so that both sprites appear at different positions?