ElliePanda

Members
  • Content Count

    3
  • Joined

  • Last visited

About ElliePanda

  • Rank
    Newbie

Profile Information

  • Gender
    Female
  • Location
    Seattle, WA
  1. ElliePanda

    Star rain

    You're welcome! It was fun, I'm just starting out with PixiJS too so I learned a bit in the process ParticleContainers are fascinating; I ran up to 10,000 star sprites in the playground on my iPhone without any noticeable performance impact, and I have no idea how they do that...
  2. ElliePanda

    Star rain

    Since there are presumably a lot of stars and they'll all look the same, you might get some performance benefit using a ParticleContainer. Your code looks like you're re-generating all the stars every frame (if I'm parsing it right), but if you make each star a Sprite you don't need to! If it was me, what I would do is generate a bunch of star Sprites with random X, Y, and scale initially. I'd give them each a random .dy property to control how fast they move, and I'd add them all to the ParticleContainer. In the tick function, I'd loop through all the sprites in the ParticleContainer, adding each one's .dy to its Y position. If the new Y position is outside the visible area, I'd set its Y back to the top of the container and randomize its scale, X position, and .dy again. That way, you're reusing an existing bunch of Sprites instead of garbage collecting stuff. If you need to control the speed of the starfield as a whole, perhaps based on how fast your player is moving, you could factor that into the process by adding an overall speed adjustment something like this: "sprite.position.y = sprite.position.y + (sprite.dy * speedFactor)". That would also let you reverse the direction if you needed to. I coded this up in a playground to show you what it looks like: https://www.pixiplayground.com/#/edit/iWLHNxIENQwXhfOXtxN_S
  3. If you need a good simple example of using shaders with RenderTextures and meshes, this one posted on another thread has let me get my project up and running: https://codepen.io/ivanpopelyshev/pen/jOWLjKd