-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File naming #4
Comments
Hello file in TexturePackParser.java:151 is the name of the texture image (PNG/BMP/PVR/etc) file referenced inside the XML file in the texture tag - myGFX.xml in your example. When you create the TexturePackLoader, you pass it a TextureManager (quite likely the one from your BaseActivity). This TextureManager instance is what checks a hash map whether a particular image has already been loaded as a texture. The hash map uses the texture file name as the key (without the base path - "gfx/chapter1/" and "gfx/chapter2/" - that you provide TexturePackLoader which is passed on further to TexturePackParser). This hasMappedTexture plus getMappedTexture optimization will lead to quicker loading and saved memory in case multiple assets (XMLs) reference the same image file. If one does not wish to use unique names for their image files, a possible "fix", may be to start including the base path in the key part of the TextureManager's mTexturesMapped hash map. This would mean appending the base path to the pID parameter of all calls to TextureManager's hasMappedTexture, getMappedTexture and addMappedTexture (Calls made in TextureManager and TexturePackParser in the parts of the project I used).
|
Yeah you are right. I meant that the images should not have the same name. Obviously the solution is changing the way the texture get's mapped. Mapping the texture by it's texture file name could lead to issues in case you have textures with the same file names, but stored in different locations. Sorry for the confusion. |
If you have a TexturePack and want to change its texture the asset filename must not be the same or it won't change the texture.
For example:
I have a texture pack ( myTexturePack ) and I want to change it for different chapters.
At this point we would aspect to have the graphics from chapter 2 loaded, but this doesn't happen because of the check made in the parser.
The string should contain the whole path not just the filename or there should be a reference somewhere saying that the names of the files must be different.
~korn3l
The text was updated successfully, but these errors were encountered: