Jump to content

setTexture() of Sprite not called


LordPayso
 Share

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.

Link to comment
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'));
Link to comment
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...