HugoLuc Posted February 28, 2016 Share Posted February 28, 2016 Hi everyone.I have been trying to make a prototype for a game and I'm wondering if there is any way to switch between sprite animation using MovieClip. var frames = []; for (var i = 0; i < 4; i++) { var val = i < 10 ? '0' + i : i; // magically works since the spritesheet was loaded with the pixi loader frames.push(PIXI.Texture.fromFrame('ladyBug_Walk-0' + (i+1) + '.png')); } this.sprites.ladybugWalk = frames //load frames with:(repeat for ladubugfly and ladybugWalk) var frames = []; var sprites = {}; for (var i = 0; i < 4; i++) { // magically works since the spritesheet was loaded with the pixi loader frames.push(PIXI.Texture.fromFrame('ladyBug_Walk-0' + (i+1) + '.png')); } sprites.ladybugWalk = frames; //create movie clip with: animation02 = new PIXI.extras.MovieClip(assets.sprites.ladybugFly); animation01 = new PIXI.extras.MovieClip(assets.sprites.ladybugWalk); //switch with: aniamtion01.sprite = sprites.animation02; If I do that I get this error: TypeError: undefined is not an object (evaluating 'value.baseTexture.hasLoaded') I've seen the example on the PIXI website in which it changes the sprite on click, but it was a single sprite and not a movie clip. Is there any way to switch the whole animation? If Not, what's the best way to do it? create a new MovieClip, kill the old one, and position it in the same place? Thank you! Quote Link to comment Share on other sites More sharing options...
fire7side Posted February 28, 2016 Share Posted February 28, 2016 I haven't gotten to this yet, but have some thoughts. One thought is to put 4 movieclips in a container and turn one visible and the last one not visible. They would all take the position of the container that way so should stay aligned. Haven't tried it though. Another is this code written by kittyKat:https://gist.github.com/kittykatattack/13a53d0dbc32ce2a0a17 You could use it as is, or just look at his code for getting a sequence and displaying it. Quote Link to comment Share on other sites More sharing options...
HugoLuc Posted February 28, 2016 Author Share Posted February 28, 2016 Quote One thought is to put 4 movieclips in a container and turn one visible and the last one not visible Thank! That was helpful! How would you make it invisible tho? Quote Link to comment Share on other sites More sharing options...
HugoLuc Posted February 28, 2016 Author Share Posted February 28, 2016 Ups! Just found out that the MovieClip has alpha! =p Thanks again! Quote Link to comment Share on other sites More sharing options...
fire7side Posted February 28, 2016 Share Posted February 28, 2016 You could use alpha, or it has a visible property, so just clip.visible = false; and then it won't render. HugoLuc 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 28, 2016 Share Posted February 28, 2016 clip.renderable = false; works too and it has different behaviour than "visible" HugoLuc 1 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.