Im looking to store and call information about a character.
This information contains a little 2d image of him and then stats like HP,DMG,REP,XP.
I need the info to display like my crude drawing below
| | HP: 200 DMG: 30 REP: 12 XP:15
|_____|
Im not looking for code but just a method for doing this. Can I use an one array to store all of this inofrmation? It will contain a texture and intergers.
Then the second part is calling it display the way that I have posted above?
Any help would be great as I cant get my head around this. I think im too close to it!
Edit: The display above is meant to be a box like an image and then the stats to the right
Im just trying to store the characters information locally and then displaying it on the GUI.
The general idea is that I will have loads of characters stored with all their information and then display them in a list so the player can see them and select them.
usually you would put all attributes belonging to a character into a class, then instantiate this class for each character and fill in the values (or change them).
for displaying images you can use the gui.label.
if there are not too much character icons you can put them into an array and drag them in the inspector into the elemts of that array. your player then stores the index of the image in that array. there are also more advanced ways achieving this with filenames etc and dynamically loading from asset bundles or www class but make it work the easy way first.
Storing values in variables is fairly fundamental to programming, without wishing to seem rude I would run through some tutorials until you are happy with these principals.
variables and classes (as ex mentions above) to start with.
I have been teaching myself javascript just to get by. I do know how to store values as varibles i didn’t mean to give off that impression, don’t get me wrong I am by no means a programmer but I think I have the basics covered.
What was getting at me was an easy way of storing them so I can display them in the GUI. At the moment I am storing all the character values in an array. Except the image. I am then storing all the character images in a huge separate array. which I have to call separately to the stats. I was just wondering if there was a better way to do this.
So at the moment.
Each character has his own array with his stats (intergers)
Then I have another array that stores all the character images(Textures)
So to display just one characters info at the moment I will have to display the array with stats and then display the correct member of the array that contains the images just to get the correct info for one character. Is there an easier way I can get this in all one? Like linking the first array to the specific image that relates to in the second array?
let the character know which index in the image array belongs to it.
so you could have a class character with following members (pseudocode as i dont use javascript):
int strength
int hp
int damage
int imageindex
then you create an instance of that player class:
character char1;
char1.imageindex = 1; // arrayindeices tsart at 0!
in ongui you display the image:
gui.label(arrayofallimages[char1.imageindex], Rect(position));
but thats “bad” code unless several characters share the same image. if every char has a unique image which is used often better store it in the character class directly (via texture2d for example).