建档
This commit is contained in:
57
source_game/Actor/Object/CharacterObject.cpp
Normal file
57
source_game/Actor/Object/CharacterObject.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "CharacterObject.h"
|
||||
#include "Asset/Squirrel/SquirrelManager.h"
|
||||
|
||||
CharacterObject::~CharacterObject()
|
||||
{
|
||||
}
|
||||
|
||||
void CharacterObject::Update(float deltaTime)
|
||||
{
|
||||
ActiveObject::Update(deltaTime);
|
||||
}
|
||||
|
||||
void CharacterObject::Render()
|
||||
{
|
||||
ActiveObject::Render();
|
||||
}
|
||||
|
||||
void CharacterObject::Construction(int job)
|
||||
{
|
||||
// 创建装备管理器
|
||||
_EquipmentManager = new Chr_Equipment();
|
||||
_EquipmentManager->Init(this);
|
||||
// 创建动画管理器(一定要先创建装备管理器再创建动画管理器 因为需要读取身上的装备)
|
||||
_AnimationManager = new Chr_Animation();
|
||||
_AnimationManager->Init(this);
|
||||
// 创建状态机
|
||||
_StateMachine = new Chr_StateMachine();
|
||||
_StateMachine->Init(this);
|
||||
|
||||
// 开启控制器
|
||||
EnableController();
|
||||
}
|
||||
|
||||
void CharacterObject::EnableController()
|
||||
{
|
||||
this->_Controller = new Chr_Controller();
|
||||
_Controller->Init(this);
|
||||
AddChild(_Controller);
|
||||
}
|
||||
|
||||
void CharacterObject::DisableController()
|
||||
{
|
||||
this->RemoveChild(_Controller);
|
||||
this->_Controller = nullptr;
|
||||
}
|
||||
|
||||
void CharacterObject::ControllerMsg(CONTROLLER_MSG_TYPE msgType, void *msgData)
|
||||
{
|
||||
// 摇杆移动(左)
|
||||
if (msgType == CONTROLLER_MSG_TYPE::CONTROLLER_MSG_TYPE_LEFT_JOYSTICK_MOVE)
|
||||
{
|
||||
VecFPos *pos = (VecFPos *)msgData;
|
||||
std::vector<float> movedata = {pos->x, pos->y};
|
||||
this->GetObjectVars().SetArray("_move_data_", movedata);
|
||||
this->_StateMachine->ChangeState(BASE_STATE::MOVE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user