3.0 alpha Texture2D addImage adds image with a weird key


#1

Hy guys!

Just made it to the latest cocos2d-x and found a trouble. Which I was able to resolve only by hacking cocos2d-x code.

When SpriteFrameCache adds a plist it calls Texture2D~~>addImage. Which in previous versions was setting a key for texture to “path” and since 3.0 alpha it is setting “fullpath” for a key, which is bad.
Why bad?~~ after I loaded frames I want to create a SpriteBatchNode with the texture, and I was always able to get it from TextureCache with a know name. But not anymore.

I modified addImage in Texture2D to resolve that, but thats not the way to do it. Maybe I’m missing something?


#2

So, now textures “Resources/Textures/Heros/NINJA/body.png” and “Resources/Textures/Heros/ROBOT/body.png” are distinct? I believe it’s an advantage, not a drawback.


#3

It might be if you could extract that path with some convenient method. (Thinking about it, i can create my own method to generate path and add filename, yet still its not too good)
And having texture files differ only by its pass but be similar by name is a bad practice whatever the way you are looking at it. ninja_body.png anf robor_body.png or something similar is the way to go in my opinion.
Whats troubling is that you can’t influence texture keys when they are created by SpriteFrame without hacking it so I have no other choice I know of.