As a level initializes, the engine preloads resources using the following: cc.TextureCache.getInstance().addImageAsync(tx_player, this, this.textureLoadedCallback);
I expected the texture to be available as the callback method was invoked, but its “texture” property is empty until a sprite is created:
textureLoadedCallback:function () {
var tc = cc.TextureCache.getInstance();
console.log(tc.textures); // outputs Object {}
Finally found what my mistake was:
I used the following:
cc.TextureCache.getInstance().addImageAsync(tx_player, this, this.textureLoadedCallback(tx_player));
-> this exectues the textureLoadedCallback since I make a function call isntead of a function definition… Wrapping it with function(){} solved my issues.