Jump to content

Remove texture from button


v_nastey
 Share

Recommended Posts

I'm new into pixi, and what I have is a button that has a texture and a movieclip. On a click on the button, I want to remove the texture and to have the moveclip.
 

In other words i have this:
 
var back = PIXI.Texture.fromFrame("image.png");var mc = new PIXI.MovieClip(someAssets);mc.setTexture(back);
 
What I need to do is when I click the mc button, to remove the texture and preview just the movieclip. How can i do it?
Link to comment
Share on other sites

I'm new into pixi, and what I have is a button that has a texture and a movieclip. On a click on the button, I want to remove the texture and to have the moveclip.

 

In other words i have this:

 

var back = PIXI.Texture.fromFrame("image.png");var mc = new PIXI.MovieClip(someAssets);mc.setTexture(back);
 

What I need to do is when I click the mc button, to remove the texture and preview just the movieclip. How can i do it?

I don't get what you are trying to do. Can you show the code of your "button"?

Or could you provide an better example?

To toggle the visibility of elements, you can just do:

buttonSprite.click = function() {

backSprite.visible = false;

movieClip.visible = true;

};

Link to comment
Share on other sites

Basicly the movieclip is the button. the movieclip contains a array of images that are displayed. So for start what i want to do is to put a texture over the movieclip and when i click on the movieclip, to remove the texture and gave the original image that has the movieclip itself.

Link to comment
Share on other sites

You could try this:

var textures = [ back, other, other, ... ];var mc = new PIXI.MovieClip(textures);mc.interactive = true;mc.click = function() {   if(mc.textures[0] === back) {     mc.textures.shift(); // remove first element     mc.gotoAndPlay(0);  }};
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...