Game Development Reference
In-Depth Information
You should be able to run the game now and see that the game over screen appears
after colliding with four enemies. Now we just need to create a new input action that
lets us know when the player taps the screen, so that we can call ResetGame to
start a new game. We already have most of the code in place for this, so we just
need to apply what we've learned in previous chapters and create a new action that
will handle this. Two input methods have been chosen for this action, a tap (or click
with the mouse) and the start button on the Xbox 360 controller. The following code
implements these inputs using our previously created input system:
_tapAction =
InputManager::GetInstance()->CreateAction();
auto tapTrigger =
_tapAction->CreateTrigger<PointerAxisBoundsTrigger>();
auto widthBounds = CreateAxisBounds(
0,
m_renderTargetSize.Width);
auto heightBounds = CreateAxisBounds(
0,
m_renderTargetSize.Height);
tapTrigger->SetData(
&widthBounds,
&heightBounds,
KeyState::JustReleased);
auto startTrigger =
_tapAction->CreateTrigger<GamepadButtonTrigger>();
startTrigger->SetData(
GamepadButtons::Start,
KeyState::JustReleased);
The only difference between this code and previous chapters is that I'm making use
of both the X and Y axis in PointerAxisBoundsTrigger . This allows me to speci-
fy the entire screen as a potential touch location, and KeyState::JustReleased
allows it to only trigger when the touch point (or mouse button) is lifted.
Search WWH ::




Custom Search