libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
Getting started

libscratchcpp doesn't have any GUI support, but sprites and the stage can be easily implemented using the IStageHandler and ISpriteHandler interfaces.

They can be subclassed for listening to events such as when the X and Y coordinates of a sprite change.

CLI-only example

int main(int argc, char **argv) {
libscratchcpp::Project p("/path/to/project.sb3");
bool ret = p.load();
if (!ret)
return 1;
p.run();
return 0;
}
The Project class provides API for reading and running Scratch projects.
Definition project.h:25

The run() method runs an event loop which stops after all scripts finish.

For CLI project players, using run() is enough. If you are developing a GUI project player and need to receive input events such as key presses, you'll need to use step() for ticks and start() and stop()