Game Development Reference
In-Depth Information
Note
As an exercise, how would you implement a trigger to check for input on the
GamePad thumbsticks?
Now that we have all of this, let's put it to use by adding in the input control for the
player. Begin by defining two actions within Player.h :
Action *_actionMoveUp;
Action *_actionMoveDown;
Now we can move to the BindInput method in Player.cpp to build up these ac-
tions using the triggers we created.
Note
This code is missing some parts for size. Just implement the full set of triggers
based on the pattern provided. A reference implementation can be found in the
sample code for this chapter ( Player.cpp ).
auto im = InputManager::GetInstance();
auto halfScreen = screenHeight / 2.0f;
AxisBounds downBounds =
CreateAxisBounds(halfScreen, screenHeight);
AxisBounds upBounds = CreateAxisBounds(0,
halfScreen);
We start by getting a reference to the InputManager , and then determining the size
of the screen so that we can specify the bounds for the Y axis.
_actionMoveDown = im->CreateAction();
auto downPtrTrigger =
_actionMoveDown->CreateTrigger<PointerAxisBoundsTrigger>();
Search WWH ::




Custom Search