LibGDX json storage for game items -
i have class named item in have more fields of ints , floats attributes damage, level requirement , other stuff. wanted maintain predefined items in json file , when need new item set of attributes take out name json file. let's want sword , bow:
//json illustration file -- isn't proper file //this preview of { godly_sword {damage: 45, level: 10}, normal_bow {damage: 4, level: 3} }
i want able take these json name , create new object attributes this:
//creating new item has preset of attributes assigned name godly_sword item weapon = json.fromjson(item.class, "godly_sword");
i tried playing in different ways load 1 preset:
//proper json file { class: game.item, damage: 45, level: 10 }
this works isn't much of help, because don't want create json file every item predefined. advice helpful.
keys should in quotes.
{ "godly_sword" {"damage": 45, "level": 10}, "normal_bow" {"damage": 4, "level": 3} }
you consider defining weapons in array, using square brackets [].
take @ tutorial on parsing json in libgdx. if you're new json, explains things in much clearer terms libgdx wiki.
json libgdx filehandle
No comments:
Post a Comment