Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6617501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:42:44+00:00 2026-05-25T20:42:44+00:00

Ok I have a particle system going in Android. Right now I use 500

  • 0

Ok I have a particle system going in Android.

Right now I use 500 or so particles and they randomly move around the screen. I set it so that on touch (actually motion right now). that all the particles would approach your finger. Problem being is that they’re approaching at a static angle (not taking into the angle they are from the touch point).

Anyone have the algorithm to determine how to evenly approach a point? My attempt to get the angle in randians.. then convert etc.. got really messy. This simple approach showed that I move at the right pace.. but it’s a simple 45 angle approach. (keep in mind on android there are no negative x,y coordinates.. and top left is 0,0.. bottom right is (max,max). the functions takes the ontouch (x,y) coordinates. b.x, b.y are the particle coordiantes.

public void moveParticles(float x, float y) {
    for (Particle b : Particles)
        {
         if (x <= b.x)
             b.x = b.x -1;
         else b.x = b.x +1;

          if (y <= b.y)
            b.y = b.y -1;
          else b.y = b.y +1;
         }          
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:42:45+00:00Added an answer on May 25, 2026 at 8:42 pm

    Naive code that assumes touch is in the centre of the screen:

    public void moveParticles(float x, float y) {
        for (Particle b : Particles) {
          b.x += ((b.x-x)/(x/2))*speedmodifier;
          b.y += ((b.y-y)/(y/2))*speedmodifier;
        }
    }
    

    Code with normalised speeds each side of the touch axis:

    public void moveParticles(float x, float y) {
        for (Particle b : Particles) {
          height_difference = screenheight-x;
          width_difference = screenwidth-y;
          height_ratio = (b.x < x) ? screen_height-height_difference : height_diffrence;
          width_ratio = (b.y < y) ? screenwidth-width_difference : width_difference;
    
          b.x += ((b.x-x)/height_ratio)*speedmodifier;
          b.y += ((b.y-y)/width_ratio)*speedmodifier;
        }
    }
    

    Steps to make this code:
    You need to get the ratio of the screen above and below the x and y axis, so as to normalise the speed of the particles from 0 to 1 no matter where the touch is:

    height_difference = screenheight-x;
    width_difference = screenwidth-y;
    height_ratio = (b.x < x) ? screen_height-height_difference : height_diffrence;
    width_ratio = (b.y < y) ? screenwidth-width_difference : width_difference;
    

    Once we have that normalisation information we can use it to normalise the particle speeds:

    b.x += ((b.x-x)/height_ratio)*speedmodifier;
    b.y += ((b.y-y)/width_ratio)*speedmodifier;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we have a particle detector hard-wired to use 16-bit and 8-bit buffers. Every now
I have a particle system using basic spritebatch, where the particles are being created
I have a particle system with X particles. Each particle tests for collision with
I need to create a particle system and retain the created particles. I need
I have a system that generates particles from sources and updates their positions. Currently,
I'm working on a particle system and point sprites would be nice to use.
If you have a script that creates a particle system and then delete the
im developing a very simple particle system in AS3, i have the particle (a
I would like to use AndEngine's particle system to create a splash(as in splashing
I have a particle system where the positions and various properties are stored in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.