Jump to content

How to set a duration for particles that are emitted? And its possible to make a particles of a container to move randomly?


drking100
 Share

Recommended Posts

Hey! 

I have to make some particles to only "run" for like 2 seconds. The problem is that i dont know how to set the duration of it. Do i have to use tickers? Can i have ticker for every particle? 

And i found out that i can use containners to place particles in a group. Can i still move them one by one? 

My goal is to do something like this but for like 2 seconds and i cant find out how to make the particles to be up for that period of time 

 

Link to comment
Share on other sites

3 hours ago, Exca said:

Are you using some particle engine or using sprites inside a container with selfmade movement/spawning logic?

I am using sprites inside a container with selfmade movement/spawning logic

I also have another question if you could help me. I to implement those animations in some cordinates with negative values. The problem is that the canvas only have positive cordinate values. How do i place my cordinate axis ont he center of the canvas? 

Link to comment
Share on other sites

Then for timing logic I would keep a track of lifetime for each object (either ms or frames) and add tickers delta (or deltams) from that time in the loop that handles movement. Then calculate the current phase of the particle by simple currentTime/targetTime. If phase is over 1 then the animation is complete and particle can be removed. Otherwise calculate the position/alpha based on that phase value.

For the movement question. Every displayobject (be it sprite, text or container) in pixi has a position value and they indicate the position in relation to parent. So if you have a container in position 100,100 and under that you have your particles in positions 10,5 ; 11,-9 ; -5,5 then they would show on screen in positions 110,115 ; 111,101 and 95,105 assuming your container is a parent of stage container (or stage itself) and it has not been scaled/rotated.

And for the coordinate axis to be on the center you can just move your main container (or this might require additional, I cant remember if root containers position affects) to center of screen: container.x = app.renderer.screen.width/2.

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