Jump to content

  • Log In with Google      Sign In   
  • Create Account

Textures for a tile-based game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Havsmonstret   Members   -  Reputation: 464

Like
0Likes
Like

Posted 02 November 2012 - 03:22 PM

Hello,

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!
Havsmonstret

Sponsor:

#2 CJ_COIMBRA   Crossbones+   -  Reputation: 798

Like
2Likes
Like

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS