SrJohnathan / gdx-effekseer

Dedicated library for using Effekseer particle tools in libGDX
12 stars 2 forks source link

Unable to Render Animations Made with Effekseer v1.62e #3

Open SevenDayCandle opened 2 years ago

SevenDayCandle commented 2 years ago

While I've been able to load and play animation files, I have been having trouble actually having the effects show up on my screen.

I had been testing out the library with a fresh libgdx project (version 1.10.0, desktop build, no other extensions/libraries added besides this project's libraries). I have tried tweaking around various parameters (i.e. using both an OrthographicCamera and a PerspectiveCamera, changing the TypeOpenGL core type, and applying transformations to the ParticleEffekseer). However, my program always only shows a black screen.

The effect files I have been using to test this were efk files built from the sample effects included with Effekseer 1.62.

I had tried logging the IsPlaing function on my Manager and I saw that the effect was indeed supposed to be playing, however.

If it helps, this is the code I am using for my helper class:

`

package com.mygdx.game;

import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.PerspectiveCamera; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.FrameBuffer; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import io.github.srjohnathan.gdx.effekseer.core.EffekseerGdx; import io.github.srjohnathan.gdx.effekseer.core.EffekseerManager; import io.github.srjohnathan.gdx.effekseer.core.ParticleEffekseer;

import java.util.HashMap;

import static io.github.srjohnathan.gdx.effekseer.core.EffekseerCore.TypeOpenGL.OPEN_GL2; import static io.github.srjohnathan.gdx.effekseer.core.EffekseerCore.TypeOpenGL.OPEN_GL3;

public class EffekseerHelper { public static OrthographicCamera Camera; protected static EffekseerManager Manager; protected static final HashMap<String, ParticleEffekseer> ParticleEffects = new HashMap<>(); protected static ParticleEffekseer Current; protected static FrameBuffer Buffer; protected static Vector2 DrawPos;

public static void Initialize() {
    EffekseerGdx.init();
    Camera = new OrthographicCamera(1280, 720);
    Manager = new EffekseerManager(Camera, OPEN_GL2);
    Buffer = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth() / 4, Gdx.graphics.getHeight() / 4, false, false);
}

public static boolean Play(String key, Vector2 position) {
    return Play(key, position, null, null, null);
}

public static boolean Play(String key, Vector2 position, Vector3 rotationAxis, Float rotationAngle, Float scale) {
    ParticleEffekseer e = Start(key);
    if (e != null) {
        e.setMagnification(20f);
        DrawPos = position;
        Current = e;
        return true;
    }
    return false;
}

public static void Render(SpriteBatch sb) {
    Manager.draw(Gdx.graphics.getDeltaTime());
}

public static void Reset() {
    Manager.dispose();
    Initialize();
}

protected static ParticleEffekseer Start(String key) {
    try {
        if (Manager == null) {
            Initialize();
        }
        ParticleEffekseer e = ParticleEffects.get(key);
        if (e == null) {
            e = new ParticleEffekseer(Manager);
            e.load(key,true);
            ParticleEffects.put(key, e);
        }
        e.play();
        return e;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

public static class EFK {
    public static final String SWORD1 = "effects/Sword01.efk";
    public static final String TEST = "effects/Test.efk";
    public static final String TEST2 = "effects/test.efkpkg";
}

}

`

And this is my main application file: ` public class MyGdxGame extends ApplicationAdapter { SpriteBatch batch; Texture img;

@Override
public void create () {
    batch = new SpriteBatch();
    img = new Texture("badlogic.jpg");
    EffekseerHelper.Play(EffekseerHelper.EFK.TEST, new Vector2(0,0));
}

@Override
public void render () {
    EffekseerHelper.Render(batch);
}

@Override
public void dispose () {
    batch.dispose();
    img.dispose();
}

} `

SevenDayCandle commented 2 years ago

For what it's worth, I also tried using efk files created from version 1.61e of Effekseeker, as well as using Libgdx 1.9.5, and I wasn't able to render images in those cases either.

SrJohnathan commented 2 years ago

forgot it public static void Render(SpriteBatch sb) { Gdx.gl.glClearColor(0.0f, 0f, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT|GL20.GL_DEPTH_BUFFER_BIT); Manager.draw(Gdx.graphics.getDeltaTime());

}
SevenDayCandle commented 2 years ago

This worked! Thank you!

SrJohnathan commented 2 years ago

today I will release a version of lib 2.2, with new features and fixes

SevenDayCandle commented 2 years ago

Does this library work when run with older versions of Libgdx (e.g. 1.9.5)?

SrJohnathan commented 2 years ago

no, later 1.10 as it was compiled with this version of libgdx