libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
Graphics effects

libscratchcpp provides API for adding custom graphics effects. No effects are included with libscratchcpp and must be implemented by the project player.

Adding a custom graphics effect

To add a graphics effect that libscratchcpp doesn't support, subclass IGraphicsEffect and override all of the methods.

It's recommended to use the libscratchcpp namespace like this in your class:

using namespace libscratchcpp;
The main namespace of the library.
Definition asset.h:10

The name() method should return the name of the effect which is used by the set and change effect blocks, for example ghost or fisheye.

Registering the graphics effect

To register the graphics effect, use ScratchConfiguration::registerGraphicsEffect() .

static void registerGraphicsEffect(std::shared_ptr< IGraphicsEffect > effect)
Definition scratchconfiguration.cpp:30

Why should effects be registered?

Effects in Scratch are usually identified by their name (ghost, brightness, etc.), but this isn't effective when it comes to running projects. Those "names" are therefore replaced by IGraphicsEffect pointers which makes working with effects faster.