-
Notifications
You must be signed in to change notification settings - Fork 114
other JSON
Adrian Papari edited this page Sep 6, 2015
·
16 revisions
The module is the recommended serializer when you do not (want to) use LibGDX and you do not want to port your game to browsers. It has no extra benefit over the LibGDX serializer, while lacking some default serializers for libgdx classes.
- Include
artemis-odb-serializer-json
module in your gradle/maven configuration. - Add the required manager and configure a backend:
final WorldSerializationManager worldSerializationManager
= new WorldSerializationManager();
new World(new WorldConfiguration().setManager(manager));
worldSerializationManager.setSerializer(new JsonArtemisSerializer(world))
final InputStream is = AnyClass.class.getResourceAsStream("level.json");
manager.load(is, SaveFileFormat.class);
final StringWriter writer = new StringWriter();
manager.save(writer, new SaveFileFormat(entities));
String json = writer.toString();
entities
is an IntBag with entity IDs defining the scope of the save operation.
final PrintWriter writer = new PrintWriter("level.json", "UTF-8");
manager.save(writer, new SaveFileFormat(entities));
writer.close();
- Overview
- Concepts
- Getting Started
- Using
- More guides
- Plugins
- Game Gallery
- Tools and Frameworks
- API reference