建档
This commit is contained in:
97
source_game/Actor/Object/BaseObject.cpp
Normal file
97
source_game/Actor/Object/BaseObject.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#include "BaseObject.h"
|
||||
|
||||
BaseObject::BaseObject()
|
||||
{
|
||||
Init(); // 调用了RenderBase的Init函数 对象才会被执行回调
|
||||
SetAnchor({0.5f, 0.5f});
|
||||
}
|
||||
|
||||
BaseObject::~BaseObject()
|
||||
{
|
||||
}
|
||||
|
||||
void BaseObject::SetPosition(VecFPos3 pos)
|
||||
{
|
||||
this->Position = pos;
|
||||
Actor::SetPos(VecFPos{this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
VecFPos3 BaseObject::GetPosition()
|
||||
{
|
||||
return this->Position;
|
||||
}
|
||||
|
||||
void BaseObject::SetXpos(float x)
|
||||
{
|
||||
this->Position.x = x;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
void BaseObject::SetYpos(float y)
|
||||
{
|
||||
this->Position.y = y;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
void BaseObject::SetZpos(float z)
|
||||
{
|
||||
this->Position.z = z;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
int BaseObject::GetXpos()
|
||||
{
|
||||
return this->Position.x;
|
||||
}
|
||||
|
||||
int BaseObject::GetYpos()
|
||||
{
|
||||
return this->Position.y;
|
||||
}
|
||||
|
||||
int BaseObject::GetZpos()
|
||||
{
|
||||
return this->Position.z;
|
||||
}
|
||||
|
||||
void BaseObject::MoveBy(VecFPos3 pos)
|
||||
{
|
||||
this->Position.x += pos.x;
|
||||
this->Position.y += pos.y;
|
||||
this->Position.z += pos.z;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
void BaseObject::MoveBy(float x, float y, float z)
|
||||
{
|
||||
this->Position.x += x;
|
||||
this->Position.y += y;
|
||||
this->Position.z += z;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
void BaseObject::SetDirection(int dir)
|
||||
{
|
||||
this->Direction = dir;
|
||||
VecFPos sc = GetScale();
|
||||
// 朝右
|
||||
if (dir == 0)
|
||||
{
|
||||
SetScale(VecFPos({SDL_fabsf(sc.x), sc.y}));
|
||||
}
|
||||
// 朝左
|
||||
else if (dir == 1)
|
||||
{
|
||||
SetScale(VecFPos({-SDL_fabsf(sc.x), sc.y}));
|
||||
}
|
||||
}
|
||||
|
||||
int BaseObject::GetDirection()
|
||||
{
|
||||
return this->Direction;
|
||||
}
|
||||
|
||||
ObjectVars &BaseObject::GetObjectVars()
|
||||
{
|
||||
return _ObjectVars;
|
||||
}
|
||||
Reference in New Issue
Block a user