LibGDX - How to create a rain and cloud? (Using "Particle")

How to create the effect of rain?
How to create the effect of cloud across the map?
Note: If using Particle possible!

Below is the full code that generates these particles on the screen.
Did you do the rainfall and cloud moving horizontally alert Particle if possible.

Otherwise what would be another outlet for this problem?


package project.parallax;

import project.parallax.actor.Hero;
import box2dLight.PointLight;
import box2dLight.RayHandler;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.ParticleEmitter;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
import com.badlogic.gdx.utils.Array;

public class LightRenderer {
  private RayHandler rayHandler;
  private OrthographicCamera camera;
  private PointLight playerLight;
  private Hero player;
  private ParticleEffect effect;
  private Vector2 positionLight = new Vector2();
  private BodyDef tileBodyDef;
  private World lightWorld;
  private FixtureDef fixtureDef;
  private PolygonShape tileShape;


  public LightRenderer(OrthographicCamera camera, Hero player) {
    this.camera = camera;
    this.player = player;

    lightWorld = new com.badlogic.gdx.physics.box2d.World(new Vector2(), true);

    RayHandler.useDiffuseLight(true);
    this.rayHandler = new RayHandler(lightWorld);
    this.rayHandler.setCombinedMatrix(this.camera.combined);
    
    int distanceLight = 96;
    playerLight = new PointLight(rayHandler, 128, new Color(0.8f,0.8f,0.8f,0.6f), distanceLight, 510, 385);
    
    // Create a shape that casts a shadow
    PolygonShape tileShape = new PolygonShape();
    tileShape.setAsBox(5.5f, 5.5f);

    tileBodyDef = new BodyDef();
    tileBodyDef.type = BodyType.StaticBody;

    fixtureDef = new FixtureDef();
    fixtureDef.shape = tileShape;
    fixtureDef.filter.groupIndex = 0;

    tileBodyDef.position.set(510, 385);
    effect = new ParticleEffect();
    effect.load(Gdx.files.internal("data/test.p"),Gdx.files.internal("data/"));
    Array<ParticleEmitter> emitters = new Array<ParticleEmitter>(effect.getEmitters());
    effect.getEmitters().clear();
    effect.getEmitters().add(emitters.get(3));    
    effect.start();
    //tileShape.dispose();
  }
  
  SpriteBatch sb = new SpriteBatch();
  public void drawBlasts(){
	  
	  effect.setPosition(300, 300);
	  sb.begin();
	  effect.draw(sb, Gdx.app.getGraphics().getDeltaTime());
	  sb.end();
	}  
  
  /**
   * Cria uma so~mbra,como se estivesse segurando uma vela.
   */
  public void addEffectShadow(){
    Body tileBody = lightWorld.createBody(tileBodyDef);
    tileBody.createFixture(fixtureDef);
  }

  public void setAmbient(Color color) {
    this.rayHandler.setAmbientLight(color);
  }

  public void render() {
	this.positionLight.set(this.player.getX(), this.player.getY());
    this.playerLight.setPosition(positionLight);
    this.rayHandler.setCombinedMatrix(this.camera.combined);
    this.rayHandler.updateAndRender();
  }

  public void dispose() {
    rayHandler.dispose();
    tileShape.dispose();
  }

	public PointLight getPlayerLight() {
		return playerLight;
	}
	
	public void setPlayerLight(PointLight playerLight) {
		this.playerLight = playerLight;
	}
   
}

Test.p


smoke
- Delay -
active: false
- Duration -
lowMin: 1.0
lowMax: 1.0
- Count -
min: 0
max: 1000
- Emission -
lowMin: 0.0
lowMax: 0.0
highMin: 3.0
highMax: 3.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life -
lowMin: 0.0
lowMax: 0.0
highMin: 3000.0
highMax: 3000.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life Offset -
active: false
- X Offset -
active: false
- Y Offset -
active: false
- Spawn Shape -
shape: square
- Spawn Width -
lowMin: 0.0
lowMax: 0.0
highMin: 180.0
highMax: 800.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height -
lowMin: 0.0
lowMax: 0.0
highMin: 110.0
highMax: 6000.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Scale -
lowMin: 0.0
lowMax: 0.0
highMin: 256.0
highMax: 256.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Velocity -
active: true
lowMin: -25.0
lowMax: -25.0
highMin: 25.0
highMax: 25.0
relative: false
scalingCount: 2
scaling0: 0.0
scaling1: 1.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Angle -
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 360.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Rotation -
active: true
lowMin: 1.0
lowMax: 360.0
highMin: -30.0
highMax: 30.0
relative: true
scalingCount: 2
scaling0: 0.0
scaling1: 1.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Wind -
active: false
- Gravity -
active: false
- Tint -
colorsCount: 6
colors0: 1.0
colors1: 0.0
colors2: 0.0
colors3: 1.0
colors4: 0.9843137
colors5: 0.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Transparency -
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 3
scaling0: 0.0
scaling1: 0.49122807
scaling2: 0.0
timelineCount: 3
timeline0: 0.0
timeline1: 0.5068493
timeline2: 1.0
- Options -
attached: false
continuous: true
aligned: false
additive: true
behind: false
- Image Path -
particle-cloud.png

effect rain:

Sorry, but what is your question?

How to create the effect of rain?
How to create the effect of cloud across the map?
Note: If using Particle possible!

Ok, this is way too broad of a question. What you need to do is start off with basic particles and work your way up. No one is going to just give you pages upon pages of code.

The question was straightforward and simple!
And there’s also simple and direct answer.

But as I’m redoing the project in LibGDX, like intelligent and straightforward opinions on the subject.
If possible show with code or ready examples would be wonderful! (And I particularly like other would be grateful).

My project, and free and open-source (source-forge), then all progress on the project and directly passed on to the community.

There are several ways to do this until I talked to the guys here a long time ago.
See Link:

So why not follow those tutorials if you already have the answer?

Like I said, no one is going to just give you code without more explanation of your problem, or you telling us what you’ve already done.

Good, let’s start.

I was going to rain as follows:
Various actors in a “Stage” falling vertically, being drawn randomly on the screen. (But it has a higher cost in processing and memory)

I made a simple example with particle (to whom I sent screen and full class code in the 1st post), and I realized that maybe used for particle effects:
rain
Cloud passing horizontally
mist
Sandstorm
thunder

Particles would be more interesting with, so I decided to just ask about the rain and it aparti have mold to see how would the other effects.

Obviously this is a terrible idea because of the reasons you mentioned; the lesson is that generally you should use whatever libgdx provides you (and it provides you with a lot). You don’t necessarily need a particle emitter for a cloud, can’t you just use a cloud image? Same with the sandstorm, unless you want a particle for each grain of sand (even simplified, I’m not really seeing it here). For lightning, unless you want it to be truly random/particle behavior, you’re probably better off using an animation. Rain is a good use for particles, but you don’t necessarily need them: http://gamedev.stackexchange.com/questions/35415/how-to-create-a-raining-effectparticles-on-android - first answer provides a link to a good method.

I had seen this link, but did not quite understand his explanation.

As I understand it creates 10 images on the screen and stretches them vertically. Then back to normal size and keep doing that for a while, my understanding is correct? or it just toggles between visible (true and false), creating an optical illusion (Giving the idea that they are falling)?

Any link or picture with something similar to that to think about the effect of cloud and Sandstorm?

Rain falls to fast to see individual particles, so just drawing a line like that in 2d actually works fairly well; you just draw it at random angles and locations within a threshold.

The video below is version 2.0 of my project, jumps to the 01:00 time +, there has the following effects:

  1. Cloud moving horizontally.
  2. Sandstorm.
  3. Rain.

Item 1 and 2 I made a giant image that moves vertically to a point and restarts again.
Note: Would have any idea or better and performative suggestion for items 1 and 2?

Item 3 I draw several rectangles and let falling (Alternate only the expessura of it)

2vc7KPJJZ00

Do you know a website with pre particles ready? (You may also pay site).