drking100 Posted March 20, 2022 Share Posted March 20, 2022 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 : Quote Link to comment Share on other sites More sharing options...
Exca Posted March 21, 2022 Share Posted March 21, 2022 Are you using some particle engine or using sprites inside a container with selfmade movement/spawning logic? Quote Link to comment Share on other sites More sharing options...
drking100 Posted March 21, 2022 Author Share Posted March 21, 2022 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? Quote Link to comment Share on other sites More sharing options...
Exca Posted March 21, 2022 Share Posted March 21, 2022 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. 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.