LordPayso Posted September 6, 2013 Share Posted September 6, 2013 I am updating the texture of a sprite when it is rotated to reflect different shading like so: d.updateDaggerShade = function(dagger, color, pos) { var prefix; (color === 'white') ? prefix = 'w' : prefix = 'b'; dagger.setTexture(PIXI.TextureCache[prefix + dagger.number.toString() + (pos + 1).toString()]); console.log(dagger.texture.baseTexture.source.src); return; };Where d is the sprite object. All the textures have been cached also. This works fine on desktop, iPhone but not Android. We are using Cordova to wrap the web code to deploy as an app. Would using a sprite sheet be a more robust alternative? I do not need to animate the textures, just change them when the rotation has finished. Quote Link to comment Share on other sites More sharing options...
LordPayso Posted September 9, 2013 Author Share Posted September 9, 2013 Is there anyway to clear a texture prior to applying a new one? Have added a spritesheet to no avail like so: var loader = new PIXI.AssetLoader(['images/daggers/sprDagger.json']); loader.onComplete = function(elm){ console.dir(PIXI.TextureCache); }; loader.load();And then call the frame:dagger.setTexture(PIXI.Texture.fromFrame(prefix + dagger.number.toString() + '0.png')); Quote Link to comment Share on other sites More sharing options...
LordPayso Posted September 9, 2013 Author Share Posted September 9, 2013 REally cannot think of a way around this apart from using a display object container and then removing/adding sprites as appropriate. Quote Link to comment Share on other sites More sharing options...
xerver Posted September 9, 2013 Share Posted September 9, 2013 I'm not sure what "not working" means, `setTexture` will change the texture of a sprite. What exactly is the problem? Quote Link to comment Share on other sites More sharing options...
LordPayso Posted September 10, 2013 Author Share Posted September 10, 2013 On our Android 4.1.* devices the seTexture method is called but the texture does not change/update. I can see this visibly and when I log out the value of the sprite's texture source, it remains the texture that it was initially set to. Quote Link to comment Share on other sites More sharing options...
xerver Posted September 10, 2013 Share Posted September 10, 2013 Is this using the default browser? Are there any errors printed to the console? Quote Link to comment Share on other sites More sharing options...
LordPayso Posted September 10, 2013 Author Share Posted September 10, 2013 No errors printed to the console. It is in the WebView browser used for Cordova. Quote Link to comment Share on other sites More sharing options...
LordPayso Posted September 11, 2013 Author Share Posted September 11, 2013 Ok. SO i accidentally figured this out. Initially we were setting the texture of our Sprites with the fromImage() method. I then re-factored the initial setting to use the fromFrame() method and now it is working. Apologies for not being clear form the start. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.