Jump to content

Repeating Texture and Animation


pdiddles03
 Share

Recommended Posts

First off, Pixi.js is awesome.  A current dream of mine is to start a small Javascript game company and put games into app stores and all that. Not necessarily to make a living off of it but just to have fun and make a few extra bucks.  Pixi.js is enabling me to make the 2d "retro type" games I have always wanted to make. THANK YOU! 

 

Anyway...New question.

 

Is there is there some kind of function to make an animated repeating texture? Much like a movie clip but have the image repeat?

Link to comment
Share on other sites

Oh, by repeat you don't mean repeat the animation. You mean tile the texture.

 

No there is no animated TilingSprite, but you can create only pretty easily by changing the texture of the tiling sprite just like movieclip does for a sprite.

That is what I figure I'd have to do.  I was just curious if anything was built into pixi for that. 

 

One quick question for you xerver.  How would you switch graphics, would you set an interval using "setInterval" or would you create a counter that switches it once it reaches a certain number?

Link to comment
Share on other sites

 I was just curious if anything was built into pixi for that. 

Yes, just create a TilingSprite (PIXI.extras.TilingSprite) and then change the `tilePosition.x` and `tilePosition.y` properties inside your game loop.

Something like this:

function gameLoop(){  requestAnimationFrame(gameLoop);  tilingSprite.tilePosition.x += 1;  tilingSprite.tilePosition.x += 1;}

If your tilingSprite is a seamless pattern, you easily create an infinite scrolling background like this.

Link to comment
Share on other sites

Yes, just create a TilingSprite (PIXI.extras.TilingSprite) and then change the `tilePosition.x` and `tilePosition.y` properties inside your game loop.

Something like this:

function gameLoop(){  requestAnimationFrame(gameLoop);  tilingSprite.tilePosition.x += 1;  tilingSprite.tilePosition.x += 1;}

If your tilingSprite is a seamless pattern, you easily create an infinite scrolling background like this.

Thanks for your reply but I need to change the entire texture to show animation, not just scroll the image.

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