Gamedev Framework (gf)  0.8.0 A C++14 framework for 2D games
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

Add a mouse button 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.

An action can be continuous or instantaneous. A continuous action is an action that is active as long as the user do not desactivate it. An instantaneous action is an action that is triggered only once when it is active. By default, the action is instantaneous.

gf::Control

## ◆ Action() [1/2]

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

Construct an action with a name.

Parameters
 name the name of the action.

## ◆ Action() [2/2]

 gf::Action::Action ( const Action & )
delete

Deleted copy constructor.

## Member Function Documentation

CloseControl

 void gf::Action::addControl ( Control & control )

Parameters
 control The control

Parameters
 id the id of the gamepad. axis the axis of the gamepad. dir the direction of the axis of the gamepad.

Parameters
 id the id of the gamepad. button the button of the gamepad

 void gf::Action::addKeycodeKeyControl ( Keycode code )

Parameters
 code the keycode of the key
KeycodeKeyControl

 void gf::Action::addMouseButtonControl ( MouseButton button )

Parameters
 button the button of the mouse.
MouseButtonControl

 void gf::Action::addScancodeKeyControl ( Scancode code )

Parameters
 code the scancode of the key
ScancodeKeyControl

## ◆ getName()

 const std::string& gf::Action::getName ( ) const
inline

Get the name of the action.

Returns
the name of the action.

## ◆ isActive()

 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.
Control::isActive()

## ◆ isContinuous()

 bool gf::Action::isContinuous ( ) const

Check if the action is continuous.

Returns
true if the action is continuous.

## ◆ isInstantaneous()

 bool gf::Action::isInstantaneous ( ) const

Check if the action is instantaneous.

Returns
true if the action is instantaneous.

## ◆ operator=()

 Action& gf::Action::operator= ( const Action & )
delete

Deleted copy assignment.

## ◆ processEvent()

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

Update the state of the action thanks to an event.

Parameters
 event the event to update the action.
Control::processEvent()

## ◆ reset()

 void gf::Action::reset ( )

Reset the state of the action.

This function depends of the type of the action.

setContinuous(), setInstantaneous(), Control::reset()

## ◆ setContinuous()

 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.