bool SpriteSheet::loadData(const JSONReader& loader) { int categories[256]; int num = loader.get_categories(categories, 256); for (int i = 0; i < num; ++i) { Rect r; loader.get(categories[i], "rect", &r); const char* sn = loader.get_string(categories[i], "name"); add(sn, r); } return true; }
bool SpriteSheet::reloadData(const JSONReader& loader) { int categories[256]; int num = loader.get_categories(categories, 256); for (int i = 0; i < num; ++i) { Rect r; loader.get(categories[i], "rect", &r); const char* sn = loader.get_string(categories[i], "name"); int idx = findIndex(sn); if (idx == -1) { add(sn, r); } else { SheetEntry& se = _entries[idx]; se.texture = Texture(r); } } return true; }