-
Notifications
You must be signed in to change notification settings - Fork 25
Scene2D
This is how gdx-vfx
and LibGDX's Scene2D can live together.
This one is simple. If you want to process the entire Stage
scene, you should just wrap Stage#draw()
with VfxManager
's capture and apply effects chain.
Here is how it may look:
Stage stage;
VfxManager manager;
void draw(float delta) {
stage.act(delta);
manager.update(delta);
manager.beginCapture();
stage.draw();
manager.endCapture();
manager.render();
}
This one is a bit more complicated as you cannot intercept specific Actor
's render method to capture rendering and apply effects, unless you wrap it into a parent Group
and override Group#render()
to put required gdx-vfx
code here.
And for sake of this case, the library has a solution...
It does exactly what described above, it extends WidgetGroup
and applies the chain of effects to all of its children.
Also, it comes with a couple of goodies packed it:
- You don't have to manage
VfxManager
manually (create/dispose it).VfxWidgetGroup
does it internally when it gets added or removed from theStage
. - Internal
VfxManager
will be resized when needed to match theVfxWidgetGroup
's size at all times. - Internal
VfxManager
is accessible throughVfxWidgetGroup#getVfxManager()
. This is how it can be configured and supplied with the Effects. - By default, internal
VfxManager
will render into the frame buffer that matches the screen resolution (in proportion to theVfxWidgetGroup
's size). If you need the effect buffer to be of the actualVfxWidgetGroup
's size (virtual Scene2D viewport units), just callVfxWidgetGroup#setMatchWidgetSize(boolean)
.
Let's have look at a simple setup, where we want to have two Group
s, where gdx-vfx
effects will be applied only to the first one.
Stage stage;
VfxWidgetGroup vfxGroup;
WidgetGroup widgetGroup;
void create() {
stage = new Stage();
// Create a `gdx-vfx` group, where effects will be applied to its children actor hierarchy.
vfxGroup = new VfxWidgetGroup(...);
vfxGroup.setFillParent(true); // Let the group fill entire stage.
stage.addActor();
// Create a regular group, where any actors should be rendered as usual.
widgetGroup = new WidgetGroup();
widgetGroup.setFillParent(true); // Let the group fill entire stage.
stage.addActor(widgetGroup);
// From now on we have two root scene groups.
// * Any actors added to vfxGroup will be affected by the `gdx-vfx` effects.
// * Any actors added to widgetGroup will be rendered unaffected on top of processed vfxGroup.
// Here's how effects can be added:
vfxGroup.getVfxManager().addEffect(...);
}
void draw(float delta) {
// No any extra code required for the rendering.
stage.act(delta);
stage.draw();
}
- Library Overview
- Connect the Library
- Use the Library
- VFX Frame Buffer
- Built-in Effects
- Changelog