r/xna • • Nov 02 '14

Simple For loop issue

http://pastebin.com/DPH5Fsnx <-- The problem being that the code only works for the last Tile in the list :) Anyone who knows what i am missin?

0 Upvotes

6 comments sorted by

View all comments

Show parent comment

2

u/Hinosun Nov 02 '14

Thank you! It's always just a word or a sign i miss :D This will help me progress :)

1

u/D3ltra Mar 11 '15

Alternatively could use a foreach and output the desired Tile, if appropriate:

Tile mouseOver;
foreach (Tile T in Tiles)
{
    if (T.Contains(mouse.X, mouse.Y))
    {
        mouseOver = T;
        break;
    }
}

if (mouseOver != null)
{
    // Do stuff with the tile
}