Subclasses?

Get help using Construct 2

Post » Sat Aug 25, 2012 6:52 am

Hi,

you got to give a player an amount of fictional objects inside a class of objects?

For example, i want to give the the player an item he can achieve in a sub-game, and can only use it in another (sub-)menu.

So the player itself needs a family of objects he can achieve, with a specific amount.

I cant find a good solution for this, and dont want to define every catchable object single as an instance variable.

hope you understand my problem, any ideas are welcome :)

Thanks :)xeed2012-08-25 07:20:56
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Sat Aug 25, 2012 7:18 am

Hi Xeed,

Do you mean mini games within 1 game? Or 1 game that could save information and be loaded in a seperate one?

If you mean mini games in 1 game then you could use global variables to keep track of any stats you would like and apply them to other mini games as you would like.GenkiGenga2012-08-25 07:19:15
ImageImage
B
72
S
16
G
6
Posts: 1,038
Reputation: 10,448

Post » Sat Aug 25, 2012 7:22 am

thanks for your answer...yes i mean minigames, which are available in situation during the main game.

i would also go the other way, that an object is "linked" to a player in a specific amount. but i dont know how to solute this in c2, since every object needs to be something like a sprite etc.

But i guess you need a better example. Maybe a player (object) made a subgame, and catched some TV's for later sell. But he does not sell, he joins the subgame twice and this time he got some prized Handys in his "bag". When he walks to the dealer, he can sell both, or pieces of these objects.

So, All this stuff you can earn should have its own class (family). So the question is, how to define that the player has an amount of a selected item inside the class or family?

Could this be currently made in c2?xeed2012-08-25 07:40:00
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Sat Aug 25, 2012 7:25 pm

You mean like an inventory?

You could use a "Dictionary" object to store what objects you have.
For example say you have a game where you collect bananas among other things and like you said you don't want to add an instance variable per object type. When you collect a banana add it with an action like this:

Dictionary: Add key "bananas" with value self.Get("bananas")+1
B
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

Post » Sun Aug 26, 2012 6:11 pm

thanks for your suggestion rojohound :)

i got multiple players, it is a round based game. can i assign an array or a dictionary object directly to a player object?
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Mon Aug 27, 2012 1:08 am

You can create multiple instances of the array and dictionary objects. If you save the uid of a dictionary instance to a sprite instance variable you can use that to associate the objects together and pick them with events.
B
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

Post » Mon Aug 27, 2012 3:26 am

ok, i think i am gonna use this solution :)

many thanks!
B
15
S
3
G
5
Posts: 396
Reputation: 4,977


Return to How do I....?

Who is online

Users browsing this forum: anty21ro, badmoodtaylor and 13 guests