I am using this library to create a rain effect.
Now I wanted to identify when the image reaches the edge of the screen to add the effect of hitting the ground. How could I identify when the image reaches the bottom of the screen? Thanks.
My class :
public class MainActivity extends AppCompatActivity{
private Button button1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new ParticleSystem(MainActivity.this, 150, R.drawable.lluvia, 10000)
.setSpeedByComponentsRange(0f, 0f, 0.5f, 1f)
.setAcceleration(0.00005f, 90)
.emitWithGravity(findViewById(R.id.emiter_bottom), Gravity.BOTTOM, 20);
}
});
}
Hello at runtime you can find out like this, it will return the Width & Height
In a view you need to do something like this:
If it has worked for you, remember to give it up, otherwise comment what the result was to continue helping you.
Cheers!!
EDITION
I initially thought you just needed to know the bounds of the screen and clearly I was wrong about what you needed.
About the bookstore I have no experience but I feel committed to supporting you.
Investigate the code of the library and it does not have a method that returns the array of Images, in the library they are called "Particles" or particles. There is for every particle an image. But the Particle class does return the X and Y.
Look at this sample code:
The Logcat shows the following:
In the code, what I basically programmed is that a single particle falls every second.
As you can see, X = 181.0 and Y varies and increases until it dies and another particle with the same X appears.
What I recommend is that you download the GitHub library and implement the necessary methods in the Particle class to define "existence" limits based on the properties
mCurrentX
andmCurrentY
, that is, if it reaches a certain point on the screen, it changes animation and then disappears .I hope I have complemented my answer better.