Jump to content

Is it possible to tile a PIXI.MovieClip


Recommended Posts

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?

Link to comment
Share on other sites

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



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



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.

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.

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.


  • Recently Browsing   0 members

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