Answer the question
In order to leave comments, you need to log in
Passing values from object class to handler class
Hello. There was a need to transfer to make the transfer of information from one class to another.
The 'Character' class has variables: Double Health Double Strength.
The task is to pass objects of this class (in our case, two objects) to the Event class, process them there, and return them back. Requires this for the same attack class/function.
The option with the Attack(Character & obj) function seemed to me not very flexible (most likely, Event will process more events than one attack)
Thank you in advance.
Answer the question
In order to leave comments, you need to log in
If the Event class is your own and you are going to build game mechanics on events in general, then if I were you, I would create several event classes for different actions (AttackEvent, MovementEvent, TradeEvent, etc.) and add a field in each ( or a set of fields - for example std::map) in which the data for the event will be stored. In your case - strength and health.
It is better to inherit events from the base Event class so as not to bother with processing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question