Skip to content

Instantly share code, notes, and snippets.

@piotr-j
Created February 2, 2017 12:58
Show Gist options
  • Save piotr-j/ef8baa3f12bb6e39490109dc96d9f4ef to your computer and use it in GitHub Desktop.
Save piotr-j/ef8baa3f12bb6e39490109dc96d9f4ef to your computer and use it in GitHub Desktop.
Particle effect problem with packed, whitespace stripped assets
fire
- Delay -
active: false
- Duration -
lowMin: 3000.0
lowMax: 3000.0
- Count -
min: 0
max: 200
- Emission -
lowMin: 0.0
lowMax: 0.0
highMin: 250.0
highMax: 250.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life -
lowMin: 0.0
lowMax: 0.0
highMin: 500.0
highMax: 1000.0
relative: false
scalingCount: 3
scaling0: 1.0
scaling1: 1.0
scaling2: 0.3
timelineCount: 3
timeline0: 0.0
timeline1: 0.66
timeline2: 1.0
- Life Offset -
active: false
- X Offset -
active: false
- Y Offset -
active: false
- Spawn Shape -
shape: point
- Spawn Width -
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height -
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Scale -
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Velocity -
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 0.1
highMax: 0.3
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Angle -
active: true
lowMin: 90.0
lowMax: 90.0
highMin: 0.0
highMax: 360.0
relative: false
scalingCount: 2
scaling0: 1.0
scaling1: 1.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Rotation -
active: false
- Wind -
active: false
- Gravity -
active: false
- Tint -
colorsCount: 3
colors0: 1.0
colors1: 0.12156863
colors2: 0.047058824
timelineCount: 1
timeline0: 0.0
- Transparency -
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
- Options -
attached: false
continuous: true
aligned: false
additive: true
behind: false
premultipliedAlpha: false
- Image Path -
particle.png
fire
- Delay -
active: false
- Duration -
lowMin: 3000.0
lowMax: 3000.0
- Count -
min: 0
max: 200
- Emission -
lowMin: 0.0
lowMax: 0.0
highMin: 250.0
highMax: 250.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life -
lowMin: 0.0
lowMax: 0.0
highMin: 500.0
highMax: 1000.0
relative: false
scalingCount: 3
scaling0: 1.0
scaling1: 1.0
scaling2: 0.3
timelineCount: 3
timeline0: 0.0
timeline1: 0.66
timeline2: 1.0
- Life Offset -
active: false
- X Offset -
active: false
- Y Offset -
active: false
- Spawn Shape -
shape: point
- Spawn Width -
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height -
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Scale -
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Velocity -
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 0.1
highMax: 0.3
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Angle -
active: true
lowMin: 90.0
lowMax: 90.0
highMin: 0.0
highMax: 360.0
relative: false
scalingCount: 2
scaling0: 1.0
scaling1: 1.0
timelineCount: 2
timeline0: 0.0
timeline1: 1.0
- Rotation -
active: false
- Wind -
active: false
- Gravity -
active: false
- Tint -
colorsCount: 3
colors0: 1.0
colors1: 0.12156863
colors2: 0.047058824
timelineCount: 1
timeline0: 0.0
- Transparency -
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
- Options -
attached: false
continuous: true
aligned: false
additive: true
behind: false
premultipliedAlpha: false
- Image Path -
particle-extended.png
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
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.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.utils.viewport.ExtendViewport;
public class ParticleEffectAtlasBug extends ApplicationAdapter {
public final static float SCALE = 128f;
public final static float INV_SCALE = 1.f/SCALE;
public final static float VP_WIDTH = 1280 * INV_SCALE;
public final static float VP_HEIGHT = 720 * INV_SCALE;
private OrthographicCamera camera;
private ExtendViewport viewport;
private ShapeRenderer shapes;
private SpriteBatch batch;
private TextureAtlas atlas;
private ParticleEffect normal;
private ParticleEffect stripped;
@Override public void create () {
camera = new OrthographicCamera();
viewport = new ExtendViewport(VP_WIDTH, VP_HEIGHT, camera);
// TODO dispose stuff
shapes = new ShapeRenderer();
batch = new SpriteBatch();
atlas = new TextureAtlas(Gdx.files.internal("particles.atlas"));
normal = new ParticleEffect();
normal.load(Gdx.files.internal("fire-normal.p"), atlas);
normal.setPosition(-2.5f, 0);
stripped = new ParticleEffect();
stripped.load(Gdx.files.internal("fire-packed.p"), atlas);
stripped.setPosition(2.5f, 0);
}
@Override public void render () {
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
float delta = Gdx.graphics.getDeltaTime();
batch.setProjectionMatrix(camera.combined);
batch.begin();
normal.draw(batch, delta);
// offset by 2,2, same as offset in atlas
stripped.draw(batch, delta);
batch.end();
shapes.setProjectionMatrix(camera.combined);
shapes.begin(ShapeRenderer.ShapeType.Filled);
shapes.setColor(Color.CYAN);
ParticleEmitter normalEmitter = normal.getEmitters().get(0);
shapes.circle(normalEmitter.getX(), normalEmitter.getY(), .1f, 16);
ParticleEmitter strippedEmitter = stripped.getEmitters().get(0);
shapes.circle(strippedEmitter.getX(), strippedEmitter.getY(), .1f, 16);
shapes.end();
}
@Override public void resize (int width, int height) {
viewport.update(width, height, false);
}
public static void main (String[] arg) {
new LwjglApplication(new ParticleEffectAtlasBug());
}
}
particle.png // this is default gdx particle.png, get it from https://github.com/libgdx/libgdx/raw/master/tests/gdx-tests-android/assets/data/particle.png
size: 32,32
format: RGBA8888
filter: Nearest,Nearest
repeat: none
particle
rotate: false
xy: 2, 2
size: 32, 31
orig: 32, 32
offset: 0, 0
index: -1
particle-extended
rotate: false
xy: 2, 2
size: 32, 31
orig: 36, 36
offset: 2, 2
index: -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment