Sign in to follow this  

setTexture() of Sprite not called

Recommended Posts

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.

Share this post

Link to post
Share on other sites

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'));

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

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.



Share this post

Link to post
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.