Sign in to follow this  

Texture not drawing

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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?

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this