Members - Reputation: 683
Posted 02 November 2012 - 03:22 PM
I've worked on a tile-based on and off for a while. I have three classes, TileManager, TileLayer and Tile. The first one contains a list of TileLayers and really only handles the layers (add, remove, deactivate etc). The TileLayer contains a 2-dimensional array of Tile. The Tile class is abstract and other classes inherit from it.
Now, the first way I did this was that each class that inherits from the Tile class has a Vector2 which contains the position of its texture in a spritesheet. The TileManager together with the TileLayer class handeled the drawing of the classes. To structure this a little more I now want each tile to have its own Texture2D. And my question is how do I get the Tiles to load the textures on its own?
I don't want any code examples I just want to know in which way you would have done this. Should I pass the ContentManager down to the Tile in order for it to load the texture? Should I have another class (TileManager I suppose) load all the textures and then pass it to the Tiles?
Maybe I shouldn't even go this way and keep the old way? What do you think is the best way to solve this?
Thanks in advance!
Crossbones+ - Reputation: 965
Posted 02 November 2012 - 06:37 PM
Should I pass the ContentManager down to the Tile in order for it to load the texture? Should I have another class (TileManager I suppose) load all the textures and then pass it to the Tiles?
I always pass my "ResourceManager" down to level that need to access some resource or exchange it at some point. I think it´s a good way to do it.
Chesster - the ultimate match-3/puzzle game!