easyx_framework V1.0.0
基于easyx的c++游戏框架
 
载入中...
搜索中...
未找到
InputComponent类 参考

输入交互组件 更多...

#include <InputComponent.h>

类 InputComponent 继承关系图:
Component base

Public 成员函数

void SetMapping (std::string mappingName, int value)
 设置键值和名字的映射.
 
virtual void BeginPlay ()
 设置纯虚函数,把不能写在构造却需要优先实现的写在这.
 
template<typename T >
void BindAction (std::string ActionName, InputType type, T *obj, void(T::*func)())
 绑定函数和键值.
 
template<typename T >
void BindAction (std::string ActionName, int value, InputType type, T *obj, void(T::*func)())
 绑定函数和键值,
 
void BindAction (std::string ActionName, InputType type, std::function< void()>func)
 绑定按键事件映射.
 
void PeekInfo ()
 action.
 
void PeekInfo_ ()
 轴处理.
 
void MouseTick ()
 获取鼠标在绘图窗口坐标.
 
virtual void Update (float deltaTime) override
 
- Public 成员函数 继承自 Component
virtual void EndPlay ()
 把一些不能写在析构函数的一些操作写在这里
 
void SetOwner (class Object *owner)
 设置绑定对象.
 
virtual void Destruct ()
 解除物体绑定组件,并销毁组件
 
virtual void Activate ()
 激活组件
 
virtual void Deactivate ()
 停用组件
 
ObjectGetOwner () const
 获取绑定对象指针
 
- Public 成员函数 继承自 base
 base ()
 
virtual ~base ()
 
std::string GetName () const
 
void SetName (const std::string &name)
 

静态 Public 成员函数

static Vector2D GetMousePosition ()
 获取鼠标屏幕坐标 相对于画布位置.
 
static bool IsMouseButtonClick ()
 鼠标左键是否按下.
 
static void EnableInput (bool enable)
 激活输入输出.
 

Private 属性

std::map< std::string, int > mappings
 实现键值和名字的映射 [名字,虚拟值]
 
std::map< std::string, KeyBindInfoactionCallbacks
 实现名字和函数功能绑定 [名字,按键需要的信息]
 
ExMessage msg
 是否启用交互
 

静态 Private 属性

static Vector2D mousePos = {}
 鼠标在绘图窗口坐标
 
static bool bActive = true
 

额外继承的成员函数

- Protected 属性 继承自 Component
class ObjectpOwner = nullptr
 处理控制逻辑 有对象物体的指针才能进行控制
 
bool bIsEnabled = true
 是否激活
 

详细描述

输入交互组件

输入输出键值控制映射.

成员函数说明

◆ BeginPlay()

virtual void InputComponent::BeginPlay ( )
inlinevirtual

设置纯虚函数,把不能写在构造却需要优先实现的写在这.

重载 Component .

◆ BindAction() [1/3]

void InputComponent::BindAction ( std::string ActionName,
InputType type,
std::function< void()> func )

绑定按键事件映射.

备注
可以不需要类对象 直接函数映射
参数
[in]ActionName键名
[in]type按键信号类型
[in]funclambda函数

◆ BindAction() [2/3]

template<typename T >
void InputComponent::BindAction ( std::string ActionName,
InputType type,
T * obj,
void(T::* func )() )
inline

绑定函数和键值.

参数
[in]ActionName键名
[in]type按键信号类型
[in]obj类对象
[in]func成员函数

◆ BindAction() [3/3]

template<typename T >
void InputComponent::BindAction ( std::string ActionName,
int value,
InputType type,
T * obj,
void(T::* func )() )
inline

绑定函数和键值,

备注
没有映射mapping就直接进行键位映射.
参数
[in]ActionName键名
[in]value虚拟键值
[in]type按键信号类型
[in]obj类对象
[in]func成员函数

◆ EnableInput()

void InputComponent::EnableInput ( bool enable)
static

激活输入输出.

参数
[in]enable是否激活输入输出

◆ GetMousePosition()

Vector2D InputComponent::GetMousePosition ( )
static

获取鼠标屏幕坐标 相对于画布位置.

返回
相对于(0,0)点

◆ IsMouseButtonClick()

bool InputComponent::IsMouseButtonClick ( )
static

鼠标左键是否按下.

返回
是否按下鼠标

◆ MouseTick()

void InputComponent::MouseTick ( )

获取鼠标在绘图窗口坐标.

◆ PeekInfo()

void InputComponent::PeekInfo ( )

action.

备注
(瞬时触发,触发频率受帧率影响)

◆ PeekInfo_()

void InputComponent::PeekInfo_ ( )

轴处理.

固定频率执行

◆ SetMapping()

void InputComponent::SetMapping ( std::string mappingName,
int value )

设置键值和名字的映射.

参数
[in]mappingName键名
[in]value虚拟值

◆ Update()

void InputComponent::Update ( float deltaTime)
overridevirtual

重载 Component .

类成员变量说明

◆ actionCallbacks

std::map<std::string, KeyBindInfo> InputComponent::actionCallbacks
private

实现名字和函数功能绑定 [名字,按键需要的信息]

◆ bActive

bool InputComponent::bActive = true
staticprivate

◆ mappings

std::map<std::string, int> InputComponent::mappings
private

实现键值和名字的映射 [名字,虚拟值]

◆ mousePos

Vector2D InputComponent::mousePos = {}
staticprivate

鼠标在绘图窗口坐标

◆ msg

ExMessage InputComponent::msg
private

是否启用交互