What would be the best way to handle multiple statistics values for the player, such as HP, level, and EXP? I'm talking a moderately large number of stats, and in a RPG game I'm helping with; I counted and it's around +20 or so.
I prefer using instance variable. It greatly helps with picking and is way more readable than simple array indexes. Also it's more in the logic of OOP. To keep these data through layouts, I would make the object global. To save/retrieve these data with webstorage or server database it could be interesting to have an action for serializing/unserializing these data into an XML or whatever string easily saveable. @Ashley has some ideas maybe.
Yanns right instance vars are the way to go. You dont really have to make a bunch of global objects tho (unless you just need to) you can make 1 or 2 global objects that are solely for handling the task of data storage between layouts then relate whatever needed data to the new instances of the objects they belong to.
Ive used this approach for years and ended up callin em Controller Objects
Well the better solution is a mix of both. Store your initial values for player/NPCs/whatever in arrays, and on creation of said instance, fill the instance variables with the value out of the array. For the value you want to keep from an iteration to another, store them on death of the player in global variables, or an array which values are meant to change over time and apply them to the "newly" created player instance.
Stuff like score, numbers of kills/death, etc... can be stored in global variables. Assuming you only have one player which is scoring/killing/dying.