Jump to content
  • Advertisement
Sign in to follow this  
Coleco

[.net] vb.net managing textures

This topic is 4906 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 am writing a map editor that will have multiple textures to pick from. My texture class works well but what I am having trouble with is managing multiple texture classes. basically, I am doing:
dim Col as Collection
Col = new Collection
...
dim tex as clsTexture    'texture class is "clsTexture"
tex = new clsTexture
tex.ChangeName("grass")
tex.LoadTexture("grass.png")

Col.Add(tex)

That works. However, if I have many textures in the collection, I can't seem to access any of them...for example, how would I scan through the collection looking for a texture named "grass" or "water"? The collection seems to only have "Add", "Remove", "Count", etc. Hope I am making sense...oh, and yes, I googled but to no avail. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Use a Hashtable instead and loop through the Keys collection to list the names or use col(name) to retrieve a texture by name. You add them using col(name, tex)

Cheers

Share this post


Link to post
Share on other sites
Thanks...but now I am stumped on this.

I would like to do something like:



w = col("grass").GetTextureWidth



"GetTextureWidth" is a member of the clsTexture.

Does that make sense?

thanks!!

Share this post


Link to post
Share on other sites
Well, a collection contains things of the Object type. (At least for now) So you will have to convert/cast the elements to the right type like this:

w = CType(col("grass"), clsTexture).GetTextureWidth

or (more readable):

Dim tex As clsTexture
tex = CType(col("grass"), clsTexture)
w = tex.GetTextureWidth()

Cheers

BTW: stop prefixing your classes with cls. Check out FxCop on www.gotdotnet.com for naming/coding rules.

Share this post


Link to post
Share on other sites
Hey!

Thanks a bunch dude...that is what I needed!

New to the .NET stuff.

Also, I will check into that FXCop....I guess old habbits die hard. But then again, I've always worked as a one-man programming team at my job and play so my naming schemes have always worked. :-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!