Skip to content
Discussion options

You must be logged in to vote

Hi,

Generally we have a GameData class that we convert it to JSON with RapidJSON and save to some place, locally, remote, UserDefault, etc and method that save/load it to/from JSON.

Sample code:

// GameData.h
#pragma once

// keep includes minimal and portable
#include <string>
#include <vector>
#include <unordered_map>
#include <fstream>
#include <sstream>

// rapidjson
#include <rapidjson/document.h>
#include <rapidjson/writer.h>
#include <rapidjson/prettywriter.h>
#include <rapidjson/stringbuffer.h>

// axmol
#include "base/UserDefault.h"
#include "platform/FileUtils.h"

namespace ax
{
    class GameData
    {
    public:
        // basic game state
        int coins = 0;
        int l…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@antn9x
Comment options

@AlexandreK38
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by antn9x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants