Attaching right mouse click to cast spell
The right mouse click will have to go through quite a few function calls before calling the avatar's CastSpell
method. The call graph would look something like the following screenshot:
A few things happen between right click and spell cast. They are as follows:
- As we saw before, all user mouse and keyboard interactions are routed through the
Avatar
object. When theAvatar
object detects a right-click, it will pass the click event toHUD
throughAAvatar::MouseRightClicked()
. - Recall from Chapter 10, Inventory System and Pickup Items where we used a
struct Widget
class to keep track of the items the player had picked up.struct Widget
only had three members:struct Widget { Icon icon; FVector2D pos, size; ///.. and some member functions };
We will need to add an extra property for
struct Widget
class to remember the spell it casts.The
HUD
will determine if the click event was insideWidget
inAMyHUD::MouseRightClicked()
. - If the click was on...