Best way to handle multiple stats?

Get help using Construct 2

Post » Thu Apr 19, 2012 5:46 am

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.
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

Post » Thu Apr 19, 2012 6:08 am

I personally like to use an array, and set it to be global. Of course, you need to document the XY coordinates for each stat, but if you plot it out right you can streamline it quite well.
B
58
S
20
G
7
Posts: 305
Reputation: 8,804

Post » Thu Apr 19, 2012 9:52 am

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.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Apr 19, 2012 10:19 am

In CC I'd use an .INI or Hashtable. In C2...I dunno lol. I used to use arrays but tying a value with x,y coordinates is silly and I quickly learned there are better ways to go about this.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Thu Apr 19, 2012 4:22 pm

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
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Thu Apr 19, 2012 11:36 pm

What do I do about stats that I do not want to reset if the player is destroyed?
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581

Post » Fri Apr 20, 2012 1:42 am

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Tue Apr 24, 2012 9:08 pm

Okay, I think I have it down but I'm encountering a visual glitch when I test it out. Project
I only want the meter to empty out from the right side, and yet it's emptying out from both sides.


Nevermind, fixed. It was the hotspot/origin point that was causing it.LaDestitute2012-04-26 00:32:24
Zelda Gamekit (my project)

Example capxs I have made:
Zelda-Style Inventory
Zelda Hearts System

The unwritten "How do I" capx etiquette! Nearly always provide a capx of the problem you have, and try to isolate the problem and/or no capx above 10 MB. :)
B
38
S
19
G
26
Posts: 438
Reputation: 16,581


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 27 guests