rolyataylor2 Posted February 23, 2014 Share Posted February 23, 2014 Is it possible to tile a frame texture in a movie clip object.So in otherwords can I make a animated MovieClip act like a Tiling sprite and change the width and height but have the textures just repeat infinitely instead of stretching? OR can I use a tiling sprite like a MovieClip and have the texture be updated to do animations? Or do i have to create a bunch of MovieClip Objects next to eachother? Quote Link to comment Share on other sites More sharing options...
xerver Posted February 23, 2014 Share Posted February 23, 2014 Either of those second ones should work fine. You can use the `setTexture` method to update the texture of a TilingSprite, which is all MovieClip does under the hood anyway. Quote Link to comment Share on other sites More sharing options...
rolyataylor2 Posted February 24, 2014 Author Share Posted February 24, 2014 OK so i created all the frame textures just like i did for the MovieClip.Then instead of doing this: var sprite = new PIXI.MovieClip(textureArray); which works and animates. I did this instead:var i = 0;var sprite = new PIXI.TilingSprite(textureArray[0],640,640); Now i have a Tiling sprite that draws a 640x640 square of tiled textures (which works fine) then every 100ms I do this:setInterval(function() { i += 0.5; if ( i > textureArray.length) i = 0; sprite.setTexture( textureArray[ Math.floor(i) ]);},100); Now i am not out of bounds on the texture array and all the textures appear to be valid ( console.log(textureArray[ Math.floor(i) ]) Gives me the textures one at a time) BUT the texture does not update for drawing, It is stuck at frame 1 and draws the same as if I were not even calling the 'setTexture' method. I checked and method is getting called tho. I also tried this:var i = 0;var texture = new PIXI.Texture.fromImage('img/u/o/tester.png');var sprite = new PIXI.TilingSprite( texture,640,640);setInterval(function() { i += 0.5; if (i > 31) i = 0; texture.setFrame(new PIXI.Rectangle(Math.floor(i)*32,0,32,32));},100); and that didnt work either, it results in the same thing, just a TilingSprite that is 640x640 with no animation. If i do any of the above with a PIXI.Sprite as opposed to a PIXI.TilingSprite it animates just like the MovieClip. 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.