Indigo

Indigo

  • Blog
  • Guides
  • Docs
  • APIs
  • Tools
  • GitHub

›Platform & Publishing

Indigo

  • Indigo's Development Status

Getting started

  • Setup & Configuration
  • Hello, Indigo!
  • Examples
  • Mill & SBT Game Templates

Organising your game

  • Boot & Start Up
  • Game Entry Points
  • Scenes & Scene Management
  • SubSystems

The game loop

  • Events
  • Frame context
  • Outcome Type

Presentation

  • Animation
  • Audio
  • Boundaries
  • Cameras
  • Clones & Mutants
  • Depth
  • Layers
  • Lighting
  • Materials
  • Primitives & Building Blocks
  • SceneUpdateFragment
  • Shapes
  • Text & Fonts

UI Components

  • Overview
  • Buttons
  • Hit Area
  • Input Field
  • Radio Button

Shaders

  • Shaders Overview
  • Shader Constants, Variables, and Outputs
  • Blending
  • Premultiplied Alpha

Working with Time

  • Signals & Signal Functions
  • Time Varying Values

Platform & Publishing

  • Assets & Asset Loading
  • Cross Platform Publishing
  • File Format Importers
  • User Input Handling
  • Loading & Saving Data
  • Logging
  • Networking

Other information

  • Alternatives to Indigo
  • Glossary
  • Key Concepts
  • Model, ViewModel, & View
  • Anti-Patterns
  • Motivation & Constraints
  • Performance
  • Prior Art
  • Rendering Technology

Loading & Saving Data

Sooner or later, you're probably going to need to load data into your game or save user data.

Dealing with save games

When you think of loading and saving, probably the first thing that comes to mind is save games.

Currently Indigo's local storage options are a bit limited, but what you can do is storage events.

Storage events use your browsers local storage, which you can think of like a key value store. You process might be:

  1. Organise save data into a case class
  2. Convert the data to JSON
  3. Fire off a Save("save game 1", json) event to stash it away against a key.
  4. Then to reload, fire a Load("save game 1") event.
  5. Eventually (normally 1 frame later) you'll get a Loaded(json) event.
  6. Deserialise the JSON into your case class and apply it to your model.

Loading local data

You can always load data in plain text format (that could be JSON or CSV for example), by using making use of the asset loading functionality. This allows you to dynamically load a data file at any time, process it, and apply it to you model.

Loading and saving over a network

The other way to load and save data might be over a network, please see the networking page for details.

Similar to the save game flow, you might do something like:

  1. Organise save data into a case class
  2. Convert the data to JSON
  3. Fire off a POST event to send it to a server over HTTP.
  4. Then to reload, fire a GET event.
  5. Eventually you'll get a HttpResponse event.
  6. Deserialise the body of the response into your case class and apply it to your model.
← User Input HandlingLogging →
Indigo
Getting Started
Setup & Configuration Guide"Hello, Indigo!" TutorialLinks to examplesProject templates
Community
DiscordGitHub DiscussonsTwitter
Sponsor us!
GitHub SponsorsPatreon