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!
[.net] vb.net managing textures
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:
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
Cheers
Thanks...but now I am stumped on this.
I would like to do something like:
"GetTextureWidth" is a member of the clsTexture.
Does that make sense?
thanks!!
I would like to do something like:
w = col("grass").GetTextureWidth
"GetTextureWidth" is a member of the clsTexture.
Does that make sense?
thanks!!
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement