修改OpenGl渲染底层之前
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "BaseObject.h"
|
||||
#include "Actor/Map/GameMap.h"
|
||||
#include "Actor/Map/GameMapCamera.h"
|
||||
|
||||
BaseObject::BaseObject()
|
||||
{
|
||||
Init(); // 调用了RenderBase的Init函数 对象才会被执行回调
|
||||
@@ -10,41 +12,50 @@ BaseObject::~BaseObject()
|
||||
{
|
||||
}
|
||||
|
||||
void BaseObject::SetPosition(VecFPos3 pos)
|
||||
void BaseObject::Update(float deltaTime)
|
||||
{
|
||||
if (_AffCamera != nullptr)
|
||||
{
|
||||
_AffCamera->SyncPos(deltaTime);
|
||||
}
|
||||
Actor::Update(deltaTime);
|
||||
}
|
||||
|
||||
void BaseObject::SetPosition(VecPos3 pos)
|
||||
{
|
||||
if (pos.y != this->Position.y)
|
||||
{
|
||||
SetRenderZOrder((int)(this->Position.y)); // 设置渲染顺序
|
||||
SetRenderZOrder(pos.y); // 设置渲染顺序
|
||||
}
|
||||
this->Position = pos;
|
||||
Actor::SetPos(VecFPos{this->Position.x, this->Position.y - this->Position.z});
|
||||
SetPos(VecFPos{this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
VecFPos3 BaseObject::GetPosition()
|
||||
VecPos3 BaseObject::GetPosition()
|
||||
{
|
||||
return this->Position;
|
||||
}
|
||||
|
||||
void BaseObject::SetXpos(float x)
|
||||
void BaseObject::SetXpos(int x)
|
||||
{
|
||||
this->Position.x = x;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
void BaseObject::SetYpos(float y)
|
||||
void BaseObject::SetYpos(int y)
|
||||
{
|
||||
if (y != this->Position.y)
|
||||
{
|
||||
SetRenderZOrder((int)(this->Position.y)); // 设置渲染顺序
|
||||
SetRenderZOrder(y); // 设置渲染顺序
|
||||
}
|
||||
this->Position.y = y;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
void BaseObject::SetZpos(float z)
|
||||
void BaseObject::SetZpos(int z)
|
||||
{
|
||||
this->Position.z = z;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
int BaseObject::GetXpos()
|
||||
@@ -62,28 +73,33 @@ int BaseObject::GetZpos()
|
||||
return this->Position.z;
|
||||
}
|
||||
|
||||
void BaseObject::MoveBy(VecFPos3 pos)
|
||||
void BaseObject::MoveBy(VecPos3 pos)
|
||||
{
|
||||
// 只有moveby移动时判断所在地图中是否能够这样移动
|
||||
VecFPos3 RealPos = this->_AffMap->CheckIsItMovable(GetPosition(), pos);
|
||||
if (pos.y != 0)
|
||||
VecPos3 RealPos = this->_AffMap->CheckIsItMovable(GetPosition(), pos);
|
||||
if (RealPos.y != this->Position.y)
|
||||
{
|
||||
SetRenderZOrder((int)(this->Position.y)); // 设置渲染顺序
|
||||
SetRenderZOrder(RealPos.y); // 设置渲染顺序
|
||||
}
|
||||
if (RealPos != this->Position){
|
||||
this->Position = RealPos;
|
||||
SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
this->Position = RealPos;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
void BaseObject::MoveBy(float x, float y, float z)
|
||||
void BaseObject::MoveBy(int x, int y, int z)
|
||||
{
|
||||
// 只有moveby移动时判断所在地图中是否能够这样移动
|
||||
VecFPos3 RealPos = this->_AffMap->CheckIsItMovable(GetPosition(), VecFPos3({x, y, z}));
|
||||
if (y != 0)
|
||||
VecPos3 RealPos = this->_AffMap->CheckIsItMovable(GetPosition(), VecPos3({x, y, z}));
|
||||
if (RealPos.y != this->Position.y)
|
||||
{
|
||||
SetRenderZOrder((int)(this->Position.y)); // 设置渲染顺序
|
||||
SetRenderZOrder(RealPos.y); // 设置渲染顺序
|
||||
}
|
||||
if (RealPos != this->Position)
|
||||
{
|
||||
this->Position = RealPos;
|
||||
SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
this->Position = RealPos;
|
||||
Actor::SetPos({this->Position.x, this->Position.y - this->Position.z});
|
||||
}
|
||||
|
||||
void BaseObject::SetDirection(int dir)
|
||||
|
||||
Reference in New Issue
Block a user