Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Public Member Functions | List of all members
gf::Action Class Reference

An action that can be triggered by different controls. More...

#include <gf/Action.h>

Public Member Functions

 Action (std::string name)
 Construct an action with a name. More...
 
 Action (const Action &)=delete
 Deleted copy constructor. More...
 
Actionoperator= (const Action &)=delete
 Deleted copy assignment. More...
 
const std::string & getName () const
 Get the name of the action. More...
 
Type of the action
void setContinuous ()
 Set the action continuous. More...
 
bool isContinuous () const
 Check if the action is continuous. More...
 
void setInstantaneous ()
 Set the action instantaneous. More...
 
bool isInstantaneous () const
 Check if the action is instantaneous. More...
 
Controls for the action
void addKeycodeKeyControl (Keycode code)
 Add a key control. More...
 
void addScancodeKeyControl (Scancode code)
 Add a key control. More...
 
void addMouseButtonControl (MouseButton button)
 Add a mouse button control. More...
 
void addGamepadButtonControl (GamepadId id, GamepadButton button)
 Add a gamepad button control. More...
 
void addGamepadAxisControl (GamepadId id, GamepadAxis axis, GamepadAxisDirection dir)
 Add a gamepad axis control. More...
 
void addCloseControl ()
 Add a close control. More...
 
State of the action
void processEvent (const Event &event)
 Update the state of the action thanks to an event. More...
 
bool isActive ()
 Check if the action is active. More...
 
void reset ()
 Reset the state of the action. More...
 

Detailed Description

An action that can be triggered by different controls.

Constructor & Destructor Documentation

gf::Action::Action ( std::string  name)

Construct an action with a name.

Parameters
namethe name of the action.
gf::Action::Action ( const Action )
delete

Deleted copy constructor.

Member Function Documentation

void gf::Action::addCloseControl ( )

Add a close control.

See also
CloseControl
void gf::Action::addGamepadAxisControl ( GamepadId  id,
GamepadAxis  axis,
GamepadAxisDirection  dir 
)

Add a gamepad axis control.

Parameters
idthe id of the gamepad.
axisthe axis of the gamepad.
dirthe direction of the axis of the gamepad.
See also
GamepadAxisControl
void gf::Action::addGamepadButtonControl ( GamepadId  id,
GamepadButton  button 
)

Add a gamepad button control.

Parameters
idthe id of the gamepad.
buttonthe button of the gamepad
See also
GamepadButtonControl
void gf::Action::addKeycodeKeyControl ( Keycode  code)

Add a key control.

Parameters
codethe keycode of the key
See also
KeycodeKeyControl
void gf::Action::addMouseButtonControl ( MouseButton  button)

Add a mouse button control.

Parameters
buttonthe button of the mouse.
See also
MouseButtonControl
void gf::Action::addScancodeKeyControl ( Scancode  code)

Add a key control.

Parameters
codethe scancode of the key
See also
ScancodeKeyControl
const std::string& gf::Action::getName ( ) const
inline

Get the name of the action.

Returns
the name of the action.
bool gf::Action::isActive ( )

Check if the action is active.

An action is active if at least one of its control is active.

Returns
true if the action is active.
See also
Control::isActive()
bool gf::Action::isContinuous ( ) const

Check if the action is continuous.

Returns
true if the action is continuous.
bool gf::Action::isInstantaneous ( ) const

Check if the action is instantaneous.

Returns
true if the action is instantaneous.
Action& gf::Action::operator= ( const Action )
delete

Deleted copy assignment.

void gf::Action::processEvent ( const Event event)

Update the state of the action thanks to an event.

Parameters
eventthe event to update the action.
See also
Control::processEvent()
void gf::Action::reset ( )

Reset the state of the action.

This function depends of the type of the action.

See also
setContinuous(), setInstantaneous(), Control::reset()
void gf::Action::setContinuous ( )

Set the action continuous.

A continuous action is an action that is active as long as the user do not desactivate it. A reset() call does not desactivate the action.

See also
reset(), setInstantaneous()
void gf::Action::setInstantaneous ( )

Set the action instantaneous.

An instantaneous action is an action that is active until the next reset() call.

See also
reset(), setContinuous()