Skip to content

Dedicated library for using Effekseer particle tools in libGDX

Notifications You must be signed in to change notification settings

SrJohnathan/gdx-effekseer

Repository files navigation

LibGDX + Effekseer

Dedicated library for using Effekseer particle tools in libGDX

Alt text

outras libs

LibGDX Water (in development) https://github.com/SrJohnathan/libgdx-water

https://effekseer.github.io/en/

https://libgdx.badlogicgames.com/

Supported platforms

Android, Windows and Linux

sourceCompatibility = 1.8

Core

Maven Central

api 'io.github.srjohnathan:gdx-effekseer:2.1'

Desktop

Maven Central

api 'io.github.srjohnathan:gdx-effekseer-desktop:2.1'

Android

Maven Central

natives 'io.github.srjohnathan:gdx-effekseer-android:2.1'

build.gradle :android

task copyEffekseerNatives {
    doFirst {
        configurations.natives.copy().files.each { jar ->
                                                        // 2.1-SNAPSHOT - version snapshot
            if (jar.name.endsWith("gdx-effekseer-android-2.2.1.jar")){

                zipTree(jar).files.each {file  ->
                    if( file.path.contains("arm64-v8a") ){
                        copy {
                            from file.path
                            into "${projectDir}/libs/arm64-v8a"
                            include "*.so"
                        }
                    }

                    if( file.path.contains("armeabi-v7a") ){
                        copy {
                            from file.path
                            into "${projectDir}/libs/armeabi-v7a"
                            include "*.so"
                        }
                    }
                    if( file.path.contains("x86") ){
                        copy {
                            from file.path
                            into "${projectDir}/libs/x86"
                            include "*.so"
                        }
                    }
                }
            }

        }
    }
}

run copyEffekseerNatives

Starting

3D Effects perspectiveCamera

// Effekseer start
EffekseerGdx.init()
        
AssetManager assetManager = new AssetManager(fileHandleResolver);

ModelBatch modelBatch = new ModelBatch();
RenderContext renderContext = modelBatch.getRenderContext();

// set Loader
assetManager.setLoader(EffekseerParticleSubAssetLoader.Result.class, null, new EffekseerParticleSubAssetLoader(fileHandleResolver));
assetManager.setLoader(EffekseerParticleAssetLoader.Result.class, null, new EffekseerParticleAssetLoader(fileHandleResolver));
    
PerspectiveCamera  perspectiveCamera = new PerspectiveCamera(67, 1280f, 720);

// Create a new manager for the particles
if (Gdx.app.type == Application.ApplicationType.Android) {
    manager = EffekseerManager(perspectiveCamera, EffekseerCore.TypeOpenGL.OPEN_GLES2, 600);
    --OR--
    manager = EffekseerManager(perspectiveCamera, EffekseerCore.TypeOpenGL.OPEN_GLES2, 600, renderContext);
}
else {
    manager = EffekseerManager(perspectiveCamera, EffekseerCore.TypeOpenGL.OPEN_GL2, 1000);
    --OR--
    manager = EffekseerManager(perspectiveCamera, EffekseerCore.TypeOpenGL.OPEN_GL2, 1000, renderContext);
}
// create a new particle
effekseer = new EffekseerParticle(manager);
effekseer.setMagnification(20f);
try {
    effekseer.syncLoad(assetManager, "data/tu.efk");
} catch (Exception e) {
    e.printStackTrace();
}

effekseer.play();

Loading Effects

effekseer = new EffekseerParticle(manager);

// Ideally use an AssetManager that implements DirectAssetAdder for faster loading such as the provided class: AssetManagerWithDirectAssetAdder
AssetManager assetManager = new AssetManagerWithDirectAssetAdder(fileHandleResolver);
-- OR --
AssetManager assetManager = new AssetManager(fileHandleResolver);

// Register the following asset loaders for the asset manager instance once before any loading is executed
assetManager.setLoader(EffekseerParticleSubAssetLoader.Result.class, null, new EffekseerParticleSubAssetLoader(fileHandleResolver));
assetManager.setLoader(EffekseerParticleAssetLoader.Result.class, null, new EffekseerParticleAssetLoader(fileHandleResolver));

// Pass in an instance of EffekseerIsMipMapEnabledDecider to override if an effect texture should use mimaps. By default all textures use mipmaps. 
new EffekseerParticleSubAssetLoader(fileHandleResolver, new EffekseerIsMipMapEnabledDecider() {
    @Override
    public void isMipMapEnabledForTextureFile() {
        ...
    }
});


// For immediate loading
effekseer.syncLoad(assetManager, "data/tu.efk", false);
// For asynchronous loading
effekseer.asyncLoad(assetManager, "data/tu.efk", false, new LoadedListener() {
    @Override
    public void onEffectLoaded() {
        ...
    }
});

Render function

@Override
public void render() {

    ...

    manager.draw(Gdx.graphics.getDeltaTime());
    --OR--
    manager.update(Gdx.graphics.getDeltaTime());
    
    // Can call this draw as many times as needed. For example one draw for post-processing and then the normal draw.
    manager.drawAfterUpdate();
} 

Dispose function

@Override
public void dispose() {
    // Dispose a single effect
    effekseerParticle.dispose();
    
    // Dispose entire manager
    manager.dispose();
} 

2D Effects orthographicCamera

  OrthographicCamera  orthographicCamera = new OrthographicCamera(1280f,720f);
  EffekseerManager  manager = new EffekseerManager(orthographicCamera);

Animation functions

effekseer = new EffekseerParticle(manager);


try {
    effekseer.syncLoad("data/ring.efk",true);
} catch (Exception e) {
    e.printStackTrace();
}

effekseer.play();

// Following is a subset of the methods in EffekseerParticle

effekseer.play();
effekseer.pause();
effekseer.resume();
effekseer.stop();
effekseer.setOnAnimationComplete();

effekseer.setTranslation();
effekseer.translate();
effekseer.setRotation();
effekseer.roatate();
effekseer.setScale();
effekseer.scale();
effekseer.getTransform(); // For direct access for transformation

effekseer.getNodeCount();
effekseer.getRootNode();


        
// The following are the supported node classes for accessing/modification.

EffekseerNode // The base node class for all node classes below
EffekseerNodeRoot // The root node of an effect
EffekseerNodeSprite
EffekseerNodeRibbon
EffekseerNodeTrack
EffekseerNodeRing
EffekseerNodeModel

paypal

Contributors:

License

About

Dedicated library for using Effekseer particle tools in libGDX

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published