parent
349ddedb3c
commit
02ccbff4eb
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\eaction.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
e2d::Action::Action()
|
||||
: m_bRunning(false)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
e2d::ActionDelay::ActionDelay(double duration)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
e2d::ActionFunc::ActionFunc(Function func) :
|
||||
m_Callback(func)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
e2d::ActionGradual::ActionGradual(double duration)
|
||||
: m_fRateOfProgress(0)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\eaction.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
e2d::ActionLoop::ActionLoop(Action * action, int times /* = -1 */)
|
||||
: m_pAction(action)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
|
||||
e2d::ActionMoveBy::ActionMoveBy(double duration, Vector vector) :
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
e2d::ActionMoveTo::ActionMoveTo(double duration, Point pos) :
|
||||
ActionMoveBy(duration, Vector())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
|
||||
e2d::ActionOpacityBy::ActionOpacityBy(double duration, double opacity) :
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
|
||||
e2d::ActionOpacityTo::ActionOpacityTo(double duration, double opacity) :
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
|
||||
e2d::ActionRotateBy::ActionRotateBy(double duration, double rotation) :
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
|
||||
e2d::ActionRotateTo::ActionRotateTo(double duration, double rotation) :
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
|
||||
e2d::ActionScaleBy::ActionScaleBy(double duration, double scale)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
e2d::ActionScaleTo::ActionScaleTo(double duration, double scale)
|
||||
: ActionScaleBy(duration, 0, 0)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
e2d::ActionSequence::ActionSequence()
|
||||
: m_nActionIndex(0)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
e2d::ActionTwo::ActionTwo(Action * pActionFirst, Action * pActionSecond, bool bAtSameTime/* = false*/)
|
||||
: m_pFirstAction(pActionFirst)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\eactions.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
e2d::Animation::Animation()
|
||||
: m_nFrameIndex(0)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\ebase.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
|
||||
// ¿ØÖÆÓÎÏ·ÖÕÖ¹
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "..\ebase.h"
|
||||
#include "..\etools.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\etool.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
#pragma comment(lib, "dinput8.lib")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\ebase.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
static ID2D1Factory * s_pDirect2dFactory = nullptr;
|
||||
static ID2D1HwndRenderTarget * s_pRenderTarget = nullptr;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\ebase.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\emanager.h"
|
||||
#include <imm.h>
|
||||
#pragma comment (lib ,"imm32.lib")
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
#include "..\ecollider.h"
|
||||
#include "..\emanager.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::Collider::Collider()
|
||||
: m_bIsVisiable(true)
|
||||
, m_nColor(Color::RED)
|
||||
, m_fOpacity(1)
|
||||
, m_pParentNode(nullptr)
|
||||
, m_pTransformedGeometry(nullptr)
|
||||
, m_bEnable(true)
|
||||
, m_bAutoResize(true)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Collider::~Collider()
|
||||
{
|
||||
SafeReleaseInterface(&m_pTransformedGeometry);
|
||||
}
|
||||
|
||||
e2d::Node * e2d::Collider::getParentNode() const
|
||||
{
|
||||
return m_pParentNode;
|
||||
}
|
||||
|
||||
void e2d::Collider::setEnable(bool bEnable)
|
||||
{
|
||||
m_bEnable = bEnable;
|
||||
}
|
||||
|
||||
void e2d::Collider::setVisiable(bool bVisiable)
|
||||
{
|
||||
m_bIsVisiable = bVisiable;
|
||||
}
|
||||
|
||||
void e2d::Collider::setColor(UINT32 color)
|
||||
{
|
||||
m_nColor = color;
|
||||
}
|
||||
|
||||
void e2d::Collider::setOpacity(double opacity)
|
||||
{
|
||||
m_fOpacity = min(max(static_cast<float>(opacity), 0), 1);
|
||||
}
|
||||
|
||||
void e2d::Collider::setAutoResize(bool bEnable)
|
||||
{
|
||||
m_bAutoResize = bEnable;
|
||||
}
|
||||
|
||||
void e2d::Collider::_render()
|
||||
{
|
||||
if (m_pTransformedGeometry && m_bEnable)
|
||||
{
|
||||
ID2D1SolidColorBrush * pBrush = Renderer::getSolidColorBrush();
|
||||
// 눼쉔뺌岬
|
||||
Renderer::getRenderTarget()->CreateSolidColorBrush(
|
||||
D2D1::ColorF(
|
||||
m_nColor,
|
||||
m_fOpacity),
|
||||
&pBrush
|
||||
);
|
||||
// 삥齡섯부툭旒竟
|
||||
Renderer::getRenderTarget()->DrawGeometry(m_pTransformedGeometry, pBrush);
|
||||
}
|
||||
}
|
||||
|
||||
int e2d::Collider::getRelationWith(Collider * pCollider) const
|
||||
{
|
||||
if (m_pTransformedGeometry && pCollider->m_pTransformedGeometry)
|
||||
{
|
||||
if (m_bEnable && pCollider->m_bEnable)
|
||||
{
|
||||
D2D1_GEOMETRY_RELATION relation;
|
||||
|
||||
m_pTransformedGeometry->CompareWithGeometry(
|
||||
pCollider->m_pTransformedGeometry,
|
||||
D2D1::Matrix3x2F::Identity(),
|
||||
&relation
|
||||
);
|
||||
|
||||
return relation;
|
||||
}
|
||||
}
|
||||
return Relation::UNKNOWN;
|
||||
}
|
||||
|
||||
void e2d::Collider::_transform()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
{
|
||||
if (m_bAutoResize)
|
||||
{
|
||||
this->_resize();
|
||||
}
|
||||
|
||||
// 姦렴覩툭旒竟
|
||||
SafeReleaseInterface(&m_pTransformedGeometry);
|
||||
|
||||
// 몽앴만쌘듐瘻뻣섯부暠近
|
||||
Renderer::getID2D1Factory()->CreateTransformedGeometry(
|
||||
getD2dGeometry(),
|
||||
m_pParentNode->m_MatriFinal,
|
||||
&m_pTransformedGeometry
|
||||
);
|
||||
|
||||
ColliderManager::__updateCollider(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
#include "..\eshape.h"
|
||||
#include "..\enodes.h"
|
||||
#include "..\ecollider.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::ShapeCircle::ShapeCircle()
|
||||
e2d::ColliderCircle::ColliderCircle()
|
||||
: m_pD2dCircle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ShapeCircle::ShapeCircle(Point center, double radius)
|
||||
e2d::ColliderCircle::ColliderCircle(Point center, double radius)
|
||||
: m_pD2dCircle(nullptr)
|
||||
{
|
||||
this->setCircle(center, radius);
|
||||
}
|
||||
|
||||
e2d::ShapeCircle::ShapeCircle(Node * node)
|
||||
e2d::ColliderCircle::ColliderCircle(Node * node)
|
||||
: m_pD2dCircle(nullptr)
|
||||
{
|
||||
double minSide = min(node->getRealWidth(), node->getRealHeight());
|
||||
|
|
@ -25,12 +25,12 @@ e2d::ShapeCircle::ShapeCircle(Node * node)
|
|||
);
|
||||
}
|
||||
|
||||
e2d::ShapeCircle::~ShapeCircle()
|
||||
e2d::ColliderCircle::~ColliderCircle()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dCircle);
|
||||
}
|
||||
|
||||
void e2d::ShapeCircle::setCircle(Point center, double radius)
|
||||
void e2d::ColliderCircle::setCircle(Point center, double radius)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dCircle);
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ void e2d::ShapeCircle::setCircle(Point center, double radius)
|
|||
);
|
||||
}
|
||||
|
||||
void e2d::ShapeCircle::_resize()
|
||||
void e2d::ColliderCircle::_resize()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
{
|
||||
|
|
@ -60,7 +60,7 @@ void e2d::ShapeCircle::_resize()
|
|||
}
|
||||
}
|
||||
|
||||
ID2D1EllipseGeometry * e2d::ShapeCircle::getD2dGeometry() const
|
||||
ID2D1EllipseGeometry * e2d::ColliderCircle::getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dCircle;
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
#include "..\eshape.h"
|
||||
#include "..\enodes.h"
|
||||
#include "..\ecollider.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::ShapeEllipse::ShapeEllipse()
|
||||
e2d::ColliderEllipse::ColliderEllipse()
|
||||
: m_pD2dEllipse(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ShapeEllipse::ShapeEllipse(Point center, double radiusX, double radiusY)
|
||||
e2d::ColliderEllipse::ColliderEllipse(Point center, double radiusX, double radiusY)
|
||||
: m_pD2dEllipse(nullptr)
|
||||
{
|
||||
this->setEllipse(center, radiusX, radiusY);
|
||||
}
|
||||
|
||||
e2d::ShapeEllipse::ShapeEllipse(Node * node)
|
||||
e2d::ColliderEllipse::ColliderEllipse(Node * node)
|
||||
: m_pD2dEllipse(nullptr)
|
||||
{
|
||||
this->setEllipse(
|
||||
|
|
@ -25,12 +25,12 @@ e2d::ShapeEllipse::ShapeEllipse(Node * node)
|
|||
);
|
||||
}
|
||||
|
||||
e2d::ShapeEllipse::~ShapeEllipse()
|
||||
e2d::ColliderEllipse::~ColliderEllipse()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dEllipse);
|
||||
}
|
||||
|
||||
void e2d::ShapeEllipse::setEllipse(Point center, double radiusX, double radiusY)
|
||||
void e2d::ColliderEllipse::setEllipse(Point center, double radiusX, double radiusY)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dEllipse);
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ void e2d::ShapeEllipse::setEllipse(Point center, double radiusX, double radiusY)
|
|||
);
|
||||
}
|
||||
|
||||
void e2d::ShapeEllipse::_resize()
|
||||
void e2d::ColliderEllipse::_resize()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
{
|
||||
|
|
@ -60,7 +60,7 @@ void e2d::ShapeEllipse::_resize()
|
|||
}
|
||||
}
|
||||
|
||||
ID2D1EllipseGeometry * e2d::ShapeEllipse::getD2dGeometry() const
|
||||
ID2D1EllipseGeometry * e2d::ColliderEllipse::getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dEllipse;
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#include "..\ecollider.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::ColliderRect::ColliderRect()
|
||||
: m_pD2dRectangle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ColliderRect::ColliderRect(double x, double y, double width, double height)
|
||||
: m_pD2dRectangle(nullptr)
|
||||
{
|
||||
this->setRect(x, y, x + width, y + height);
|
||||
}
|
||||
|
||||
e2d::ColliderRect::ColliderRect(Node * node)
|
||||
: m_pD2dRectangle(nullptr)
|
||||
{
|
||||
this->setRect(0, 0, node->getRealWidth(), node->getRealHeight());
|
||||
}
|
||||
|
||||
e2d::ColliderRect::~ColliderRect()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dRectangle);
|
||||
}
|
||||
|
||||
void e2d::ColliderRect::setRect(double left, double top, double right, double bottom)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dRectangle);
|
||||
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
D2D1::RectF(
|
||||
static_cast<float>(left),
|
||||
static_cast<float>(top),
|
||||
static_cast<float>(right),
|
||||
static_cast<float>(bottom)),
|
||||
&m_pD2dRectangle
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::ColliderRect::_resize()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
{
|
||||
this->setRect( 0, 0, m_pParentNode->getRealWidth(), m_pParentNode->getRealHeight());
|
||||
}
|
||||
}
|
||||
|
||||
ID2D1RectangleGeometry * e2d::ColliderRect::getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dRectangle;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::Font::Font()
|
||||
: fontFamily("")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\enode.h"
|
||||
#include <map>
|
||||
|
||||
static std::map<size_t, ID2D1Bitmap*> s_mBitmapsFromFile;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\ebase.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
e2d::Object::Object()
|
||||
: m_nRefCount(0)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
#include "..\ebase.h"
|
||||
#include "..\enodes.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\enode.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
e2d::Scene::Scene()
|
||||
: m_bWillSave(true)
|
||||
, m_bAutoUpdate(true)
|
||||
, m_bSortNeeded(false)
|
||||
, m_bShapeVisiable(false)
|
||||
, m_bColliderVisiable(false)
|
||||
, m_pRoot(new Node())
|
||||
{
|
||||
m_pRoot->retain();
|
||||
|
|
@ -23,12 +23,12 @@ void e2d::Scene::_render()
|
|||
{
|
||||
m_pRoot->_render();
|
||||
|
||||
if (m_bShapeVisiable)
|
||||
if (m_bColliderVisiable)
|
||||
{
|
||||
// 恢复矩阵转换
|
||||
Renderer::getRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
// 绘制所有几何图形
|
||||
m_pRoot->_drawShape();
|
||||
m_pRoot->_drawCollider();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ e2d::Node * e2d::Scene::getRoot() const
|
|||
return m_pRoot;
|
||||
}
|
||||
|
||||
void e2d::Scene::showOutline(bool visiable)
|
||||
void e2d::Scene::showCollider(bool visiable)
|
||||
{
|
||||
m_bShapeVisiable = visiable;
|
||||
m_bColliderVisiable = visiable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,17 @@ e2d::String e2d::String::parse(int value)
|
|||
return std::move(tmp);
|
||||
}
|
||||
|
||||
e2d::String e2d::String::parse(unsigned int value)
|
||||
{
|
||||
String tmp;
|
||||
#if HIGHER_THAN_VS2010
|
||||
tmp.m_str = std::to_wstring(value);
|
||||
#else
|
||||
tmp.m_str = std::to_wstring(static_cast<long long>(value));
|
||||
#endif
|
||||
return std::move(tmp);
|
||||
}
|
||||
|
||||
e2d::String e2d::String::parse(float value)
|
||||
{
|
||||
String tmp;
|
||||
|
|
@ -303,6 +314,12 @@ e2d::String & e2d::String::operator<<(int value)
|
|||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator<<(unsigned int value)
|
||||
{
|
||||
(*this) += String::parse(value);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
e2d::String & e2d::String::operator<<(float value)
|
||||
{
|
||||
(*this) += String::parse(value);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\eactions.h"
|
||||
#include "..\emanager.h"
|
||||
#include "..\eaction.h"
|
||||
|
||||
static std::vector<e2d::Action*> s_vActions;
|
||||
static std::vector<e2d::Action*> s_vRunningActions;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\enodes.h"
|
||||
#include "..\eshape.h"
|
||||
#include "..\etools.h"
|
||||
#include "..\emanager.h"
|
||||
#include "..\enode.h"
|
||||
#include "..\ecollider.h"
|
||||
#include "..\etool.h"
|
||||
|
||||
// 形状集合
|
||||
static std::vector<e2d::ShapeBase*> s_vShapes;
|
||||
// 碰撞体集合
|
||||
static std::vector<e2d::Collider*> s_vColliders;
|
||||
// 监听器容器
|
||||
static std::vector<e2d::CollisionListener*> s_vListeners;
|
||||
// 碰撞触发状态
|
||||
|
|
@ -14,12 +14,12 @@ static e2d::Node * s_pActiveNode = nullptr;
|
|||
static e2d::Node * s_pPassiveNode = nullptr;
|
||||
|
||||
|
||||
void e2d::CollisionManager::setEnable(bool bEnable)
|
||||
void e2d::ColliderManager::setEnable(bool bEnable)
|
||||
{
|
||||
s_bCollisionEnable = bEnable;
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::__update()
|
||||
void e2d::ColliderManager::__update()
|
||||
{
|
||||
if (s_vListeners.size() == 0)
|
||||
return;
|
||||
|
|
@ -40,28 +40,28 @@ void e2d::CollisionManager::__update()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::__updateShape(e2d::ShapeBase * pActiveShape)
|
||||
void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
|
||||
{
|
||||
// 判断碰撞触发是否打开
|
||||
if (!s_bCollisionEnable)
|
||||
return;
|
||||
|
||||
Node* pActiveNode = pActiveShape->m_pParentNode;
|
||||
Node* pActiveNode = pActiveCollider->m_pParentNode;
|
||||
if (pActiveNode)
|
||||
{
|
||||
// 获取节点所在场景
|
||||
Scene* pCurrentScene = pActiveNode->getParentScene();
|
||||
|
||||
// 判断与其他形状的交集情况
|
||||
for (size_t i = 0; i < s_vShapes.size(); i++)
|
||||
// 判断与其他碰撞体的交集情况
|
||||
for (size_t i = 0; i < s_vColliders.size(); i++)
|
||||
{
|
||||
auto pPassiveShape = s_vShapes[i];
|
||||
// 判断两个形状是否是同一个对象
|
||||
if (pActiveShape == pPassiveShape)
|
||||
auto pPassiveCollider = s_vColliders[i];
|
||||
// 判断两个碰撞体是否是同一个对象
|
||||
if (pActiveCollider == pPassiveCollider)
|
||||
continue;
|
||||
|
||||
// 获取被碰撞节点
|
||||
Node* pPassiveNode = pPassiveShape->m_pParentNode;
|
||||
Node* pPassiveNode = pPassiveCollider->m_pParentNode;
|
||||
// 判断两节点是否处于同一场景中
|
||||
if (pPassiveNode &&
|
||||
pPassiveNode->getParentScene() == pCurrentScene)
|
||||
|
|
@ -77,8 +77,8 @@ void e2d::CollisionManager::__updateShape(e2d::ShapeBase * pActiveShape)
|
|||
|
||||
if (IsCollideWith(pActiveNode, pPassiveNode->getHashName()))
|
||||
{
|
||||
// 判断两形状交集情况
|
||||
int relation = pActiveShape->getRelationWith(pPassiveShape);
|
||||
// 判断两碰撞体交集情况
|
||||
int relation = pActiveCollider->getRelationWith(pPassiveCollider);
|
||||
// 忽略 UNKNOWN 和 DISJOINT 情况
|
||||
if (relation != Relation::UNKNOWN && relation != Relation::DISJOINT)
|
||||
{
|
||||
|
|
@ -86,8 +86,8 @@ void e2d::CollisionManager::__updateShape(e2d::ShapeBase * pActiveShape)
|
|||
s_pPassiveNode = pPassiveNode;
|
||||
pActiveNode->onCollide(pPassiveNode);
|
||||
pPassiveNode->onCollide(pActiveNode);
|
||||
pCurrentScene->onCollide();
|
||||
CollisionManager::__update();
|
||||
pCurrentScene->onCollide(pActiveNode, pPassiveNode);
|
||||
ColliderManager::__update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ void e2d::CollisionManager::__updateShape(e2d::ShapeBase * pActiveShape)
|
|||
s_pPassiveNode = nullptr;
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::__add(CollisionListener * pListener)
|
||||
void e2d::ColliderManager::__add(CollisionListener * pListener)
|
||||
{
|
||||
WARN_IF(pListener == nullptr, "CollisionListener NULL pointer exception!");
|
||||
|
||||
|
|
@ -126,12 +126,12 @@ void e2d::CollisionManager::__add(CollisionListener * pListener)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::add(Function func, String name)
|
||||
void e2d::ColliderManager::add(Function func, String name)
|
||||
{
|
||||
(new CollisionListener(func, name))->start();
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::start(String name)
|
||||
void e2d::ColliderManager::start(String name)
|
||||
{
|
||||
FOR_LOOP(pListener, s_vListeners)
|
||||
{
|
||||
|
|
@ -142,7 +142,7 @@ void e2d::CollisionManager::start(String name)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::stop(String name)
|
||||
void e2d::ColliderManager::stop(String name)
|
||||
{
|
||||
FOR_LOOP(pListener, s_vListeners)
|
||||
{
|
||||
|
|
@ -153,7 +153,7 @@ void e2d::CollisionManager::stop(String name)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::clear(String name)
|
||||
void e2d::ColliderManager::clear(String name)
|
||||
{
|
||||
FOR_LOOP(pListener, s_vListeners)
|
||||
{
|
||||
|
|
@ -164,7 +164,7 @@ void e2d::CollisionManager::clear(String name)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::startAll()
|
||||
void e2d::ColliderManager::startAll()
|
||||
{
|
||||
FOR_LOOP(pListener, s_vListeners)
|
||||
{
|
||||
|
|
@ -172,7 +172,7 @@ void e2d::CollisionManager::startAll()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::stopAll()
|
||||
void e2d::ColliderManager::stopAll()
|
||||
{
|
||||
FOR_LOOP(pListener, s_vListeners)
|
||||
{
|
||||
|
|
@ -180,7 +180,7 @@ void e2d::CollisionManager::stopAll()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::clearAll()
|
||||
void e2d::ColliderManager::clearAll()
|
||||
{
|
||||
FOR_LOOP(pListener, s_vListeners)
|
||||
{
|
||||
|
|
@ -188,7 +188,7 @@ void e2d::CollisionManager::clearAll()
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<e2d::CollisionListener*> e2d::CollisionManager::get(String name)
|
||||
std::vector<e2d::CollisionListener*> e2d::ColliderManager::get(String name)
|
||||
{
|
||||
std::vector<CollisionListener*> vListeners;
|
||||
FOR_LOOP(pListener, s_vListeners)
|
||||
|
|
@ -201,12 +201,22 @@ std::vector<e2d::CollisionListener*> e2d::CollisionManager::get(String name)
|
|||
return std::move(vListeners);
|
||||
}
|
||||
|
||||
std::vector<e2d::CollisionListener*> e2d::CollisionManager::getAll()
|
||||
std::vector<e2d::CollisionListener*> e2d::ColliderManager::getAll()
|
||||
{
|
||||
return s_vListeners;
|
||||
}
|
||||
|
||||
e2d::Node* e2d::CollisionManager::isCausedBy(Node * pNode)
|
||||
e2d::Node * e2d::ColliderManager::getActiveNode()
|
||||
{
|
||||
return s_pActiveNode;
|
||||
}
|
||||
|
||||
e2d::Node * e2d::ColliderManager::getPassiveNode()
|
||||
{
|
||||
return s_pPassiveNode;
|
||||
}
|
||||
|
||||
e2d::Node* e2d::ColliderManager::isCausedBy(Node * pNode)
|
||||
{
|
||||
if (s_pActiveNode == pNode)
|
||||
return s_pPassiveNode;
|
||||
|
|
@ -215,7 +225,7 @@ e2d::Node* e2d::CollisionManager::isCausedBy(Node * pNode)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
e2d::Node* e2d::CollisionManager::isCausedBy(String name)
|
||||
e2d::Node* e2d::ColliderManager::isCausedBy(String name)
|
||||
{
|
||||
if (s_pActiveNode->getName() == name)
|
||||
return s_pActiveNode;
|
||||
|
|
@ -224,30 +234,30 @@ e2d::Node* e2d::CollisionManager::isCausedBy(String name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::__addShape(ShapeBase * pShape)
|
||||
void e2d::ColliderManager::__addCollider(Collider * pCollider)
|
||||
{
|
||||
if (pShape)
|
||||
if (pCollider)
|
||||
{
|
||||
if (pShape->m_pParentNode)
|
||||
if (pCollider->m_pParentNode)
|
||||
{
|
||||
WARN_IF(true, "CollisionManager::__add Failed! The shape is already added.");
|
||||
WARN_IF(true, "ColliderManager::__add Failed! The shape is already added.");
|
||||
return;
|
||||
}
|
||||
pShape->retain();
|
||||
s_vShapes.push_back(pShape);
|
||||
pCollider->retain();
|
||||
s_vColliders.push_back(pCollider);
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::CollisionManager::__removeShape(ShapeBase * pShape)
|
||||
void e2d::ColliderManager::__removeCollider(Collider * pCollider)
|
||||
{
|
||||
if (pShape)
|
||||
if (pCollider)
|
||||
{
|
||||
for (size_t i = 0; i < s_vShapes.size(); i++)
|
||||
for (size_t i = 0; i < s_vColliders.size(); i++)
|
||||
{
|
||||
if (s_vShapes[i] == pShape)
|
||||
if (s_vColliders[i] == pCollider)
|
||||
{
|
||||
SafeRelease(&pShape);
|
||||
s_vShapes.erase(s_vShapes.begin() + i);
|
||||
SafeRelease(&pCollider);
|
||||
s_vColliders.erase(s_vColliders.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\etools.h"
|
||||
#include "..\emanager.h"
|
||||
#include "..\etool.h"
|
||||
|
||||
// 监听器容器
|
||||
static std::vector<e2d::InputListener*> s_vListeners;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\etools.h"
|
||||
#include "..\emanager.h"
|
||||
#include "..\etool.h"
|
||||
#include <map>
|
||||
|
||||
#if HIGHER_THAN_VS2010
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\emanager.h"
|
||||
#include "..\ebase.h"
|
||||
|
||||
// ObjectManager 释放池的实现机制:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\emanager.h"
|
||||
#include "..\ebase.h"
|
||||
#include "..\etransitions.h"
|
||||
#include "..\etransition.h"
|
||||
|
||||
static e2d::Scene * s_pCurrentScene = nullptr;
|
||||
static e2d::Scene * s_pNextScene = nullptr;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "..\emanagers.h"
|
||||
#include "..\etools.h"
|
||||
#include "..\enodes.h"
|
||||
#include "..\emanager.h"
|
||||
#include "..\etool.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
static std::vector<e2d::Timer*> s_vTimers;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\enode.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
#define SAFE_SETTER(pointer, func, ...) if (pointer) { pointer->##func(__VA_ARGS__); }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::ButtonToggle::ButtonToggle()
|
||||
: Button()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,22 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::Menu::Menu()
|
||||
: m_bEnable(true)
|
||||
{
|
||||
}
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
e2d::Menu::Menu(const InitList<Button*>& vButtons)
|
||||
: m_bEnable(true)
|
||||
{
|
||||
FOR_LOOP(button, vButtons)
|
||||
{
|
||||
this->addButton(button);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
e2d::Menu::Menu(int number, Button * button1, ...)
|
||||
: m_bEnable(true)
|
||||
{
|
||||
|
|
@ -17,6 +29,7 @@ e2d::Menu::Menu(int number, Button * button1, ...)
|
|||
number--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool e2d::Menu::isEnable() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\etools.h"
|
||||
#include "..\eactions.h"
|
||||
#include "..\eshape.h"
|
||||
#include "..\enode.h"
|
||||
#include "..\emanager.h"
|
||||
#include "..\etool.h"
|
||||
#include "..\eaction.h"
|
||||
#include "..\ecollider.h"
|
||||
#include <algorithm>
|
||||
|
||||
// 默认中心点位置
|
||||
static float s_fDefaultPiovtX = 0;
|
||||
static float s_fDefaultPiovtY = 0;
|
||||
static bool s_fDefaultShapeEnabled = true;
|
||||
static bool s_fDefaultColliderEnabled = true;
|
||||
|
||||
e2d::Node::Node()
|
||||
: m_nOrder(0)
|
||||
|
|
@ -29,7 +29,7 @@ e2d::Node::Node()
|
|||
, m_MatriFinal(D2D1::Matrix3x2F::Identity())
|
||||
, m_bVisiable(true)
|
||||
, m_bDisplayedInScene(false)
|
||||
, m_pShape(nullptr)
|
||||
, m_pCollider(nullptr)
|
||||
, m_pParent(nullptr)
|
||||
, m_pParentScene(nullptr)
|
||||
, m_nHashName(0)
|
||||
|
|
@ -37,17 +37,17 @@ e2d::Node::Node()
|
|||
, m_bTransformNeeded(false)
|
||||
, m_bAutoUpdate(true)
|
||||
{
|
||||
if (s_fDefaultShapeEnabled)
|
||||
if (s_fDefaultColliderEnabled)
|
||||
{
|
||||
auto rect = new ShapeRectangle(this);
|
||||
this->setShape(rect);
|
||||
auto rect = new ColliderRect(this);
|
||||
this->setCollider(rect);
|
||||
}
|
||||
}
|
||||
|
||||
e2d::Node::~Node()
|
||||
{
|
||||
ActionManager::__clearAllBindedWith(this);
|
||||
CollisionManager::__removeShape(m_pShape);
|
||||
ColliderManager::__removeCollider(m_pCollider);
|
||||
FOR_LOOP(child, m_vChildren)
|
||||
{
|
||||
SafeRelease(&child);
|
||||
|
|
@ -165,18 +165,18 @@ void e2d::Node::_render()
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::Node::_drawShape()
|
||||
void e2d::Node::_drawCollider()
|
||||
{
|
||||
// 绘制自身的几何形状
|
||||
if (m_pShape && m_pShape->m_bIsVisiable)
|
||||
// 绘制自身的几何碰撞体
|
||||
if (m_pCollider && m_pCollider->m_bIsVisiable)
|
||||
{
|
||||
m_pShape->_render();
|
||||
m_pCollider->_render();
|
||||
}
|
||||
|
||||
// 绘制所有子节点的几何形状
|
||||
// 绘制所有子节点的几何碰撞体
|
||||
FOR_LOOP(child, m_vChildren)
|
||||
{
|
||||
child->_drawShape();
|
||||
child->_drawCollider();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -250,10 +250,10 @@ void e2d::Node::_updateTransform(Node * node)
|
|||
{
|
||||
// 计算自身的转换矩阵
|
||||
node->_updateTransform();
|
||||
// 绑定于自身的形状也进行相应转换
|
||||
if (node->m_pShape)
|
||||
// 绑定于自身的碰撞体也进行相应转换
|
||||
if (node->m_pCollider)
|
||||
{
|
||||
node->m_pShape->_transform();
|
||||
node->m_pCollider->_transform();
|
||||
}
|
||||
// 遍历子节点下的所有节点
|
||||
node->_updateChildrenTransform();
|
||||
|
|
@ -378,9 +378,9 @@ double e2d::Node::getOpacity() const
|
|||
return m_fRealOpacity;
|
||||
}
|
||||
|
||||
e2d::ShapeBase * e2d::Node::getShape() const
|
||||
e2d::Collider * e2d::Node::getCollider() const
|
||||
{
|
||||
return m_pShape;
|
||||
return m_pCollider;
|
||||
}
|
||||
|
||||
int e2d::Node::getOrder() const
|
||||
|
|
@ -547,28 +547,28 @@ void e2d::Node::setSize(Size size)
|
|||
this->setSize(size.width, size.height);
|
||||
}
|
||||
|
||||
void e2d::Node::setShape(int type)
|
||||
void e2d::Node::setCollider(int nColliderType)
|
||||
{
|
||||
switch (type)
|
||||
switch (nColliderType)
|
||||
{
|
||||
case Shape::RECTANGLE:
|
||||
case ColliderType::RECT:
|
||||
{
|
||||
auto rect = new ShapeRectangle(this);
|
||||
this->setShape(rect);
|
||||
auto rect = new ColliderRect(this);
|
||||
this->setCollider(rect);
|
||||
break;
|
||||
}
|
||||
|
||||
case Shape::CIRCLE:
|
||||
case ColliderType::CIRCLE:
|
||||
{
|
||||
auto rect = new ShapeCircle(this);
|
||||
this->setShape(rect);
|
||||
auto rect = new ColliderCircle(this);
|
||||
this->setCollider(rect);
|
||||
break;
|
||||
}
|
||||
|
||||
case Shape::ELLIPSE:
|
||||
case ColliderType::ELLIPSE:
|
||||
{
|
||||
auto rect = new ShapeEllipse(this);
|
||||
this->setShape(rect);
|
||||
auto rect = new ColliderEllipse(this);
|
||||
this->setCollider(rect);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -577,42 +577,42 @@ void e2d::Node::setShape(int type)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::Node::setShape(ShapeBase * pShape)
|
||||
void e2d::Node::setCollider(Collider * pCollider)
|
||||
{
|
||||
// 删除旧的形状
|
||||
CollisionManager::__removeShape(m_pShape);
|
||||
// 添加新的形状
|
||||
CollisionManager::__addShape(pShape);
|
||||
// 删除旧的碰撞体
|
||||
ColliderManager::__removeCollider(m_pCollider);
|
||||
// 添加新的碰撞体
|
||||
ColliderManager::__addCollider(pCollider);
|
||||
|
||||
if (pShape)
|
||||
if (pCollider)
|
||||
{
|
||||
// 双向绑定
|
||||
this->m_pShape = pShape;
|
||||
pShape->m_pParentNode = this;
|
||||
this->m_pCollider = pCollider;
|
||||
pCollider->m_pParentNode = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_pShape = nullptr;
|
||||
this->m_pCollider = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void e2d::Node::addCollider(String collliderName)
|
||||
void e2d::Node::addColliableName(String collliderName)
|
||||
{
|
||||
unsigned int hash = collliderName.getHashCode();
|
||||
m_vColliders.insert(hash);
|
||||
}
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
void e2d::Node::addCollider(const InitList<String>& vCollliderName)
|
||||
void e2d::Node::addColliableName(const InitList<String>& vCollliderName)
|
||||
{
|
||||
for (const auto &name : vCollliderName)
|
||||
{
|
||||
this->addCollider(name);
|
||||
this->addColliableName(name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void e2d::Node::removeCollider(String collliderName)
|
||||
void e2d::Node::removeColliableName(String collliderName)
|
||||
{
|
||||
unsigned int hash = collliderName.getHashCode();
|
||||
m_vColliders.erase(hash);
|
||||
|
|
@ -887,10 +887,10 @@ std::vector<e2d::Action*> e2d::Node::getActions(String strActionName)
|
|||
bool e2d::Node::isPointIn(Point point) const
|
||||
{
|
||||
BOOL ret = 0;
|
||||
// 如果存在形状,用形状判断
|
||||
if (m_pShape)
|
||||
// 如果存在碰撞体,用碰撞体判断
|
||||
if (m_pCollider)
|
||||
{
|
||||
m_pShape->getD2dGeometry()->FillContainsPoint(
|
||||
m_pCollider->getD2dGeometry()->FillContainsPoint(
|
||||
D2D1::Point2F(
|
||||
static_cast<float>(point.x),
|
||||
static_cast<float>(point.y)),
|
||||
|
|
@ -900,13 +900,13 @@ bool e2d::Node::isPointIn(Point point) const
|
|||
}
|
||||
else
|
||||
{
|
||||
// 为节点创建一个临时形状
|
||||
// 为节点创建一个临时碰撞体
|
||||
ID2D1RectangleGeometry * rect;
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
D2D1::RectF(0, 0, m_fWidth, m_fHeight),
|
||||
&rect
|
||||
);
|
||||
// 判断点是否在形状内
|
||||
// 判断点是否在碰撞体内
|
||||
rect->FillContainsPoint(
|
||||
D2D1::Point2F(
|
||||
static_cast<float>(point.x),
|
||||
|
|
@ -914,7 +914,7 @@ bool e2d::Node::isPointIn(Point point) const
|
|||
m_MatriFinal,
|
||||
&ret
|
||||
);
|
||||
// 删除临时创建的形状
|
||||
// 删除临时创建的碰撞体
|
||||
SafeReleaseInterface(&rect);
|
||||
}
|
||||
|
||||
|
|
@ -933,10 +933,10 @@ bool e2d::Node::isPointIn(Point point) const
|
|||
|
||||
bool e2d::Node::isIntersectWith(const Node * pNode) const
|
||||
{
|
||||
// 如果存在形状,用形状判断
|
||||
if (this->m_pShape && pNode->m_pShape)
|
||||
// 如果存在碰撞体,用碰撞体判断
|
||||
if (this->m_pCollider && pNode->m_pCollider)
|
||||
{
|
||||
int relation = this->m_pShape->getRelationWith(pNode->m_pShape);
|
||||
int relation = this->m_pCollider->getRelationWith(pNode->m_pCollider);
|
||||
if ((relation != Relation::UNKNOWN) &&
|
||||
(relation != Relation::DISJOINT))
|
||||
{
|
||||
|
|
@ -945,10 +945,10 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const
|
|||
}
|
||||
else
|
||||
{
|
||||
// 为节点创建一个临时形状
|
||||
// 为节点创建一个临时碰撞体
|
||||
ID2D1RectangleGeometry * pRect1;
|
||||
ID2D1RectangleGeometry * pRect2;
|
||||
ID2D1TransformedGeometry * pShape;
|
||||
ID2D1TransformedGeometry * pCollider;
|
||||
D2D1_GEOMETRY_RELATION relation;
|
||||
|
||||
// 根据自身大小位置创建矩形
|
||||
|
|
@ -960,7 +960,7 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const
|
|||
Renderer::getID2D1Factory()->CreateTransformedGeometry(
|
||||
pRect1,
|
||||
m_MatriFinal,
|
||||
&pShape
|
||||
&pCollider
|
||||
);
|
||||
// 根据相比较节点的大小位置创建矩形
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
|
|
@ -968,15 +968,15 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const
|
|||
&pRect2
|
||||
);
|
||||
// 获取相交状态
|
||||
pShape->CompareWithGeometry(
|
||||
pCollider->CompareWithGeometry(
|
||||
pRect2,
|
||||
pNode->m_MatriFinal,
|
||||
&relation
|
||||
);
|
||||
// 删除临时创建的形状
|
||||
// 删除临时创建的碰撞体
|
||||
SafeReleaseInterface(&pRect1);
|
||||
SafeReleaseInterface(&pRect2);
|
||||
SafeReleaseInterface(&pShape);
|
||||
SafeReleaseInterface(&pCollider);
|
||||
if ((relation != D2D1_GEOMETRY_RELATION_UNKNOWN) &&
|
||||
(relation != D2D1_GEOMETRY_RELATION_DISJOINT))
|
||||
{
|
||||
|
|
@ -1009,9 +1009,9 @@ void e2d::Node::setDefaultPiovt(double defaultPiovtX, double defaultPiovtY)
|
|||
s_fDefaultPiovtY = min(max(static_cast<float>(defaultPiovtY), 0), 1);
|
||||
}
|
||||
|
||||
void e2d::Node::setDefaultShapeEnable(bool bEnable)
|
||||
void e2d::Node::setDefaultColliderEnable(bool bEnable)
|
||||
{
|
||||
s_fDefaultShapeEnabled = bEnable;
|
||||
s_fDefaultColliderEnabled = bEnable;
|
||||
}
|
||||
|
||||
void e2d::Node::resumeAllActions()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
#include "..\..\eshape.h"
|
||||
|
||||
e2d::Circle::Circle()
|
||||
: m_fRadius(0)
|
||||
{
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
||||
e2d::Circle::Circle(double radius)
|
||||
{
|
||||
this->setRadius(radius);
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
||||
e2d::Circle::Circle(Point center, double radius)
|
||||
{
|
||||
this->setRadius(radius);
|
||||
this->setPos(center);
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
||||
e2d::Circle::Circle(double centerX, double centerY, double radius)
|
||||
{
|
||||
this->setRadius(radius);
|
||||
this->setPos(centerX, centerY);
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
||||
e2d::Circle::~Circle()
|
||||
{
|
||||
}
|
||||
|
||||
double e2d::Circle::getRadius() const
|
||||
{
|
||||
return m_fRadius;
|
||||
}
|
||||
|
||||
void e2d::Circle::setRadius(double radius)
|
||||
{
|
||||
m_fRadius = static_cast<float>(radius);
|
||||
Node::setSize(radius * 2, radius * 2);
|
||||
}
|
||||
|
||||
void e2d::Circle::_renderLine()
|
||||
{
|
||||
Renderer::getRenderTarget()->DrawEllipse(
|
||||
D2D1::Ellipse(D2D1::Point2F(m_fRadius, m_fRadius), m_fRadius, m_fRadius),
|
||||
Renderer::getSolidColorBrush(),
|
||||
m_fStrokeWidth
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::Circle::_renderFill()
|
||||
{
|
||||
Renderer::getRenderTarget()->FillEllipse(
|
||||
D2D1::Ellipse(D2D1::Point2F(m_fRadius, m_fRadius), m_fRadius, m_fRadius),
|
||||
Renderer::getSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
#include "..\..\eshape.h"
|
||||
|
||||
e2d::Ellipse::Ellipse()
|
||||
: m_fRadiusX(0)
|
||||
, m_fRadiusY(0)
|
||||
{
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
||||
e2d::Ellipse::Ellipse(double radiusX, double radiusY)
|
||||
{
|
||||
this->setRadiusX(radiusX);
|
||||
this->setRadiusY(radiusY);
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
||||
e2d::Ellipse::Ellipse(Point center, double radiusX, double radiusY)
|
||||
{
|
||||
this->setRadiusX(radiusX);
|
||||
this->setRadiusY(radiusY);
|
||||
this->setPos(center);
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
||||
e2d::Ellipse::Ellipse(double centerX, double centerY, double radiusX, double radiusY)
|
||||
{
|
||||
this->setRadiusX(radiusX);
|
||||
this->setRadiusY(radiusY);
|
||||
this->setPos(centerX, centerY);
|
||||
this->setPivot(0.5, 0.5);
|
||||
}
|
||||
|
||||
e2d::Ellipse::~Ellipse()
|
||||
{
|
||||
}
|
||||
|
||||
double e2d::Ellipse::getRadiusX() const
|
||||
{
|
||||
return m_fRadiusX;
|
||||
}
|
||||
|
||||
double e2d::Ellipse::getRadiusY() const
|
||||
{
|
||||
return m_fRadiusY;
|
||||
}
|
||||
|
||||
void e2d::Ellipse::setRadiusX(double radiusX)
|
||||
{
|
||||
m_fRadiusX = static_cast<float>(radiusX);
|
||||
Node::setWidth(radiusX * 2);
|
||||
}
|
||||
|
||||
void e2d::Ellipse::setRadiusY(double radiusY)
|
||||
{
|
||||
m_fRadiusY = static_cast<float>(radiusY);
|
||||
Node::setHeight(radiusY * 2);
|
||||
}
|
||||
|
||||
void e2d::Ellipse::_renderLine()
|
||||
{
|
||||
Renderer::getRenderTarget()->DrawEllipse(
|
||||
D2D1::Ellipse(D2D1::Point2F(m_fRadiusX, m_fRadiusY), m_fRadiusX, m_fRadiusY),
|
||||
Renderer::getSolidColorBrush(),
|
||||
m_fStrokeWidth
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::Ellipse::_renderFill()
|
||||
{
|
||||
Renderer::getRenderTarget()->FillEllipse(
|
||||
D2D1::Ellipse(D2D1::Point2F(m_fRadiusX, m_fRadiusY), m_fRadiusX, m_fRadiusY),
|
||||
Renderer::getSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#include "..\..\eshape.h"
|
||||
|
||||
e2d::Rect::Rect()
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Rect::Rect(double width, double height)
|
||||
{
|
||||
this->setSize(width, height);
|
||||
}
|
||||
|
||||
e2d::Rect::Rect(Size size)
|
||||
{
|
||||
this->setSize(size);
|
||||
}
|
||||
|
||||
e2d::Rect::Rect(double top, double left, double width, double height)
|
||||
{
|
||||
this->setPivot(0, 0);
|
||||
this->setPos(top, left);
|
||||
this->setSize(width, height);
|
||||
}
|
||||
|
||||
e2d::Rect::Rect(Point topLeft, Size size)
|
||||
{
|
||||
this->setPivot(0, 0);
|
||||
this->setPos(topLeft);
|
||||
this->setSize(size);
|
||||
}
|
||||
|
||||
e2d::Rect::~Rect()
|
||||
{
|
||||
}
|
||||
|
||||
void e2d::Rect::_renderLine()
|
||||
{
|
||||
Renderer::getRenderTarget()->DrawRectangle(
|
||||
D2D1::RectF(0, 0, m_fWidth, m_fHeight),
|
||||
Renderer::getSolidColorBrush(),
|
||||
m_fStrokeWidth
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::Rect::_renderFill()
|
||||
{
|
||||
Renderer::getRenderTarget()->FillRectangle(
|
||||
D2D1::RectF(0, 0, m_fWidth, m_fHeight),
|
||||
Renderer::getSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
#include "..\..\eshape.h"
|
||||
|
||||
e2d::RoundRect::RoundRect()
|
||||
: m_fRadiusX(0)
|
||||
, m_fRadiusY(0)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::RoundRect::RoundRect(double width, double height, double radiusX, double radiusY)
|
||||
: m_fRadiusX(static_cast<float>(radiusX))
|
||||
, m_fRadiusY(static_cast<float>(radiusY))
|
||||
{
|
||||
this->setSize(width, height);
|
||||
}
|
||||
|
||||
e2d::RoundRect::RoundRect(Size size, double radiusX, double radiusY)
|
||||
: m_fRadiusX(static_cast<float>(radiusX))
|
||||
, m_fRadiusY(static_cast<float>(radiusY))
|
||||
{
|
||||
this->setSize(size);
|
||||
}
|
||||
|
||||
e2d::RoundRect::RoundRect(double top, double left, double width, double height, double radiusX, double radiusY)
|
||||
: m_fRadiusX(static_cast<float>(radiusX))
|
||||
, m_fRadiusY(static_cast<float>(radiusY))
|
||||
{
|
||||
this->setPivot(0, 0);
|
||||
this->setPos(top, left);
|
||||
this->setSize(width, height);
|
||||
}
|
||||
|
||||
e2d::RoundRect::RoundRect(Point topLeft, Size size, double radiusX, double radiusY)
|
||||
: m_fRadiusX(static_cast<float>(radiusX))
|
||||
, m_fRadiusY(static_cast<float>(radiusY))
|
||||
{
|
||||
this->setPivot(0, 0);
|
||||
this->setPos(topLeft);
|
||||
this->setSize(size);
|
||||
}
|
||||
|
||||
e2d::RoundRect::~RoundRect()
|
||||
{
|
||||
}
|
||||
|
||||
double e2d::RoundRect::getRadiusX() const
|
||||
{
|
||||
return m_fRadiusX;
|
||||
}
|
||||
|
||||
double e2d::RoundRect::getRadiusY() const
|
||||
{
|
||||
return m_fRadiusY;
|
||||
}
|
||||
|
||||
void e2d::RoundRect::setRadiusX(double radiusX)
|
||||
{
|
||||
m_fRadiusX = static_cast<float>(radiusX);
|
||||
}
|
||||
|
||||
void e2d::RoundRect::setRadiusY(double radiusY)
|
||||
{
|
||||
m_fRadiusY = static_cast<float>(radiusY);
|
||||
}
|
||||
|
||||
void e2d::RoundRect::_renderLine()
|
||||
{
|
||||
Renderer::getRenderTarget()->DrawRoundedRectangle(
|
||||
D2D1::RoundedRect(D2D1::RectF(0, 0, m_fWidth, m_fHeight), m_fRadiusX, m_fRadiusY),
|
||||
Renderer::getSolidColorBrush(),
|
||||
m_fStrokeWidth
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::RoundRect::_renderFill()
|
||||
{
|
||||
Renderer::getRenderTarget()->FillRoundedRectangle(
|
||||
D2D1::RoundedRect(D2D1::RectF(0, 0, m_fWidth, m_fHeight), m_fRadiusX, m_fRadiusY),
|
||||
Renderer::getSolidColorBrush()
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
#include "..\..\eshape.h"
|
||||
|
||||
e2d::Shape::Shape()
|
||||
: m_nStyle(ShapeStyle::SOLID)
|
||||
, m_nFillColor(Color::WHITE)
|
||||
, m_nLineColor(Color::BLUE)
|
||||
, m_fStrokeWidth(1)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::Shape::~Shape()
|
||||
{
|
||||
}
|
||||
|
||||
void e2d::Shape::onRender()
|
||||
{
|
||||
switch (m_nStyle)
|
||||
{
|
||||
case ShapeStyle::FILL:
|
||||
{
|
||||
Renderer::getSolidColorBrush()->SetColor(D2D1::ColorF(m_nFillColor, m_fDisplayOpacity));
|
||||
this->_renderFill();
|
||||
|
||||
Renderer::getSolidColorBrush()->SetColor(D2D1::ColorF(m_nLineColor, m_fDisplayOpacity));
|
||||
this->_renderLine();
|
||||
break;
|
||||
}
|
||||
|
||||
case ShapeStyle::ROUND:
|
||||
{
|
||||
Renderer::getSolidColorBrush()->SetColor(D2D1::ColorF(m_nLineColor, m_fDisplayOpacity));
|
||||
this->_renderLine();
|
||||
break;
|
||||
}
|
||||
|
||||
case ShapeStyle::SOLID:
|
||||
{
|
||||
Renderer::getSolidColorBrush()->SetColor(D2D1::ColorF(m_nFillColor, m_fDisplayOpacity));
|
||||
this->_renderFill();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UINT32 e2d::Shape::getFillColor() const
|
||||
{
|
||||
return m_nFillColor;
|
||||
}
|
||||
|
||||
UINT32 e2d::Shape::getLineColor() const
|
||||
{
|
||||
return m_nLineColor;
|
||||
}
|
||||
|
||||
double e2d::Shape::getStrokeWidth() const
|
||||
{
|
||||
return m_fStrokeWidth;
|
||||
}
|
||||
|
||||
int e2d::Shape::getStyle() const
|
||||
{
|
||||
return m_nStyle;
|
||||
}
|
||||
|
||||
void e2d::Shape::setFillColor(UINT32 fillColor)
|
||||
{
|
||||
m_nFillColor = fillColor;
|
||||
}
|
||||
|
||||
void e2d::Shape::setLineColor(UINT32 lineColor)
|
||||
{
|
||||
m_nLineColor = lineColor;
|
||||
}
|
||||
|
||||
void e2d::Shape::setStrokeWidth(double strokeWidth)
|
||||
{
|
||||
m_fStrokeWidth = static_cast<float>(strokeWidth);
|
||||
}
|
||||
|
||||
void e2d::Shape::setStyle(int style)
|
||||
{
|
||||
m_nStyle = style;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
|
||||
e2d::Sprite::Sprite()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\enodes.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
|
||||
e2d::Text::Text()
|
||||
|
|
|
|||
|
|
@ -1,109 +0,0 @@
|
|||
#include "..\eshape.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
e2d::ShapeBase::ShapeBase()
|
||||
: m_bIsVisiable(true)
|
||||
, m_nColor(Color::RED)
|
||||
, m_fOpacity(1)
|
||||
, m_pParentNode(nullptr)
|
||||
, m_pTransformedShape(nullptr)
|
||||
, m_bEnable(true)
|
||||
, m_bAutoResize(true)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ShapeBase::~ShapeBase()
|
||||
{
|
||||
SafeReleaseInterface(&m_pTransformedShape);
|
||||
}
|
||||
|
||||
e2d::Node * e2d::ShapeBase::getParentNode() const
|
||||
{
|
||||
return m_pParentNode;
|
||||
}
|
||||
|
||||
void e2d::ShapeBase::setEnable(bool bEnable)
|
||||
{
|
||||
m_bEnable = bEnable;
|
||||
}
|
||||
|
||||
void e2d::ShapeBase::setVisiable(bool bVisiable)
|
||||
{
|
||||
m_bIsVisiable = bVisiable;
|
||||
}
|
||||
|
||||
void e2d::ShapeBase::setColor(UINT32 color)
|
||||
{
|
||||
m_nColor = color;
|
||||
}
|
||||
|
||||
void e2d::ShapeBase::setOpacity(double opacity)
|
||||
{
|
||||
m_fOpacity = min(max(static_cast<float>(opacity), 0), 1);
|
||||
}
|
||||
|
||||
void e2d::ShapeBase::setAutoResize(bool bEnable)
|
||||
{
|
||||
m_bAutoResize = bEnable;
|
||||
}
|
||||
|
||||
void e2d::ShapeBase::_render()
|
||||
{
|
||||
if (m_pTransformedShape && m_bEnable)
|
||||
{
|
||||
ID2D1SolidColorBrush * pBrush = Renderer::getSolidColorBrush();
|
||||
// 눼쉔뺌岬
|
||||
Renderer::getRenderTarget()->CreateSolidColorBrush(
|
||||
D2D1::ColorF(
|
||||
m_nColor,
|
||||
m_fOpacity),
|
||||
&pBrush
|
||||
);
|
||||
// 삥齡섯부近榴
|
||||
Renderer::getRenderTarget()->DrawGeometry(m_pTransformedShape, pBrush);
|
||||
}
|
||||
}
|
||||
|
||||
int e2d::ShapeBase::getRelationWith(ShapeBase * pShape) const
|
||||
{
|
||||
if (m_pTransformedShape && pShape->m_pTransformedShape)
|
||||
{
|
||||
if (m_bEnable && pShape->m_bEnable)
|
||||
{
|
||||
D2D1_GEOMETRY_RELATION relation;
|
||||
|
||||
m_pTransformedShape->CompareWithGeometry(
|
||||
pShape->m_pTransformedShape,
|
||||
D2D1::Matrix3x2F::Identity(),
|
||||
&relation
|
||||
);
|
||||
|
||||
return relation;
|
||||
}
|
||||
}
|
||||
return Relation::UNKNOWN;
|
||||
}
|
||||
|
||||
void e2d::ShapeBase::_transform()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
{
|
||||
if (m_bAutoResize)
|
||||
{
|
||||
this->_resize();
|
||||
}
|
||||
|
||||
// 姦렴覩近榴
|
||||
SafeReleaseInterface(&m_pTransformedShape);
|
||||
|
||||
// 몽앴만쌘듐瘻뻣섯부暠近
|
||||
Renderer::getID2D1Factory()->CreateTransformedGeometry(
|
||||
getD2dGeometry(),
|
||||
m_pParentNode->m_MatriFinal,
|
||||
&m_pTransformedShape
|
||||
);
|
||||
|
||||
CollisionManager::__updateShape(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#include "..\eshape.h"
|
||||
#include "..\enodes.h"
|
||||
|
||||
e2d::ShapeRectangle::ShapeRectangle()
|
||||
: m_pD2dRectangle(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
e2d::ShapeRectangle::ShapeRectangle(double x, double y, double width, double height)
|
||||
: m_pD2dRectangle(nullptr)
|
||||
{
|
||||
this->setRect(x, y, x + width, y + height);
|
||||
}
|
||||
|
||||
e2d::ShapeRectangle::ShapeRectangle(Node * node)
|
||||
: m_pD2dRectangle(nullptr)
|
||||
{
|
||||
this->setRect(
|
||||
0,
|
||||
0,
|
||||
node->getRealWidth(),
|
||||
node->getRealHeight()
|
||||
);
|
||||
}
|
||||
|
||||
e2d::ShapeRectangle::~ShapeRectangle()
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dRectangle);
|
||||
}
|
||||
|
||||
void e2d::ShapeRectangle::setRect(double left, double top, double right, double bottom)
|
||||
{
|
||||
SafeReleaseInterface(&m_pD2dRectangle);
|
||||
|
||||
Renderer::getID2D1Factory()->CreateRectangleGeometry(
|
||||
D2D1::RectF(
|
||||
static_cast<float>(left),
|
||||
static_cast<float>(top),
|
||||
static_cast<float>(right),
|
||||
static_cast<float>(bottom)),
|
||||
&m_pD2dRectangle
|
||||
);
|
||||
}
|
||||
|
||||
void e2d::ShapeRectangle::_resize()
|
||||
{
|
||||
if (m_pParentNode && m_bEnable)
|
||||
{
|
||||
this->setRect(
|
||||
0,
|
||||
0,
|
||||
m_pParentNode->getRealWidth(),
|
||||
m_pParentNode->getRealHeight()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ID2D1RectangleGeometry * e2d::ShapeRectangle::getD2dGeometry() const
|
||||
{
|
||||
return m_pD2dRectangle;
|
||||
}
|
||||
|
|
@ -1,24 +1,24 @@
|
|||
#include "..\etools.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\etool.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
e2d::CollisionListener::CollisionListener()
|
||||
: Listener()
|
||||
{
|
||||
CollisionManager::__add(this);
|
||||
ColliderManager::__add(this);
|
||||
}
|
||||
|
||||
e2d::CollisionListener::CollisionListener(Function func)
|
||||
: Listener()
|
||||
, m_callback(func)
|
||||
{
|
||||
CollisionManager::__add(this);
|
||||
ColliderManager::__add(this);
|
||||
}
|
||||
|
||||
e2d::CollisionListener::CollisionListener(Function func, String name)
|
||||
: Listener(name)
|
||||
, m_callback(func)
|
||||
{
|
||||
CollisionManager::__add(this);
|
||||
ColliderManager::__add(this);
|
||||
}
|
||||
|
||||
void e2d::CollisionListener::_update()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\etools.h"
|
||||
#include "..\etool.h"
|
||||
|
||||
static e2d::String s_sDefaultFileName = L"DefaultData.ini";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\etools.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\etool.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
e2d::InputListener::InputListener()
|
||||
: Listener()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\etools.h"
|
||||
#include "..\etool.h"
|
||||
|
||||
e2d::Listener::Listener()
|
||||
: m_bRunning(false)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\etools.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\etool.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
using namespace e2d;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\etools.h"
|
||||
#include "..\etool.h"
|
||||
#include <algorithm>
|
||||
#include <commdlg.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "..\etools.h"
|
||||
#include "..\etool.h"
|
||||
|
||||
std::default_random_engine &e2d::Random::getEngine()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "..\etools.h"
|
||||
#include "..\enodes.h"
|
||||
#include "..\emanagers.h"
|
||||
#include "..\etool.h"
|
||||
#include "..\enode.h"
|
||||
#include "..\emanager.h"
|
||||
|
||||
e2d::Timer::Timer(Function func, String name, double interval /* = 0 */, int updateTimes /* = -1 */, bool atOnce /* = false */, bool autoRelease /* = false */)
|
||||
: m_bRunning(false)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\ebase.h"
|
||||
#include "..\etransitions.h"
|
||||
#include "..\etransition.h"
|
||||
|
||||
e2d::Transition::Transition(double duration)
|
||||
: m_bEnd(false)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\etransitions.h"
|
||||
#include "..\enodes.h"
|
||||
#include "..\etransition.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::TransitionEmerge::TransitionEmerge(double duration)
|
||||
: Transition(duration)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\etransitions.h"
|
||||
#include "..\enodes.h"
|
||||
#include "..\etransition.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::TransitionFade::TransitionFade(double fadeOutDuration, double fadeInDuration)
|
||||
: Transition(0)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "..\etransitions.h"
|
||||
#include "..\enodes.h"
|
||||
#include "..\etransition.h"
|
||||
#include "..\enode.h"
|
||||
|
||||
e2d::TransitionMove::TransitionMove(double duration, MOVE_DIRECT direct)
|
||||
: Transition(duration)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#pragma once
|
||||
#include "enodes.h"
|
||||
#include "enode.h"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
|
|
@ -20,12 +20,13 @@
|
|||
#include "emacros.h"
|
||||
#include "ecommon.h"
|
||||
#include "ebase.h"
|
||||
#include "emanagers.h"
|
||||
#include "enodes.h"
|
||||
#include "etools.h"
|
||||
#include "eactions.h"
|
||||
#include "etransitions.h"
|
||||
#include "emanager.h"
|
||||
#include "enode.h"
|
||||
#include "eshape.h"
|
||||
#include "etool.h"
|
||||
#include "eaction.h"
|
||||
#include "etransition.h"
|
||||
#include "ecollider.h"
|
||||
|
||||
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,202 @@
|
|||
#pragma once
|
||||
#include "ebase.h"
|
||||
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
|
||||
|
||||
class ColliderManager;
|
||||
|
||||
// 碰撞体
|
||||
class Collider :
|
||||
public Object
|
||||
{
|
||||
friend ColliderManager;
|
||||
friend Node;
|
||||
|
||||
public:
|
||||
Collider();
|
||||
|
||||
virtual ~Collider();
|
||||
|
||||
// 判断两碰撞体的交集关系
|
||||
virtual int getRelationWith(
|
||||
Collider * pCollider
|
||||
) const;
|
||||
|
||||
// 获取父节点
|
||||
Node * getParentNode() const;
|
||||
|
||||
// 启用或关闭该碰撞体
|
||||
virtual void setEnable(
|
||||
bool bEnable
|
||||
);
|
||||
|
||||
// 设置碰撞体的可见性
|
||||
void setVisiable(
|
||||
bool bVisiable
|
||||
);
|
||||
|
||||
// 设置绘制颜色
|
||||
void setColor(
|
||||
UINT32 color
|
||||
);
|
||||
|
||||
// 设置绘制透明度
|
||||
void setOpacity(
|
||||
double opacity
|
||||
);
|
||||
|
||||
// 设置大小跟随
|
||||
void setAutoResize(
|
||||
bool bEnable
|
||||
);
|
||||
|
||||
// 获取 ID2D1Geometry 对象
|
||||
virtual ID2D1Geometry * getD2dGeometry() const = 0;
|
||||
|
||||
protected:
|
||||
// 转换碰撞体
|
||||
virtual void _transform();
|
||||
|
||||
// 重设大小
|
||||
virtual void _resize() = 0;
|
||||
|
||||
// 渲染碰撞体
|
||||
virtual void _render();
|
||||
|
||||
protected:
|
||||
bool m_bEnable;
|
||||
bool m_bIsVisiable;
|
||||
bool m_bAutoResize;
|
||||
UINT32 m_nColor;
|
||||
float m_fOpacity;
|
||||
Node * m_pParentNode;
|
||||
ID2D1TransformedGeometry * m_pTransformedGeometry;
|
||||
};
|
||||
|
||||
|
||||
// 矩形
|
||||
class ColliderRect :
|
||||
public Collider
|
||||
{
|
||||
public:
|
||||
// 创建一个默认矩形
|
||||
ColliderRect();
|
||||
|
||||
// 根据左上角坐标和宽高创建矩形
|
||||
ColliderRect(
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height
|
||||
);
|
||||
|
||||
// 创建一个和节点位置大小相同的矩形
|
||||
ColliderRect(
|
||||
Node * node
|
||||
);
|
||||
|
||||
virtual ~ColliderRect();
|
||||
|
||||
// 修改矩形大小
|
||||
void setRect(
|
||||
double left,
|
||||
double top,
|
||||
double right,
|
||||
double bottom
|
||||
);
|
||||
|
||||
// 获取 ID2D1Geometry 对象
|
||||
virtual ID2D1RectangleGeometry * getD2dGeometry() const override;
|
||||
|
||||
protected:
|
||||
// 重设大小
|
||||
virtual void _resize();
|
||||
|
||||
protected:
|
||||
ID2D1RectangleGeometry * m_pD2dRectangle;
|
||||
};
|
||||
|
||||
|
||||
// 圆形
|
||||
class ColliderCircle :
|
||||
public Collider
|
||||
{
|
||||
public:
|
||||
// 创建一个默认圆形
|
||||
ColliderCircle();
|
||||
|
||||
// 根据圆心和半径创建圆形
|
||||
ColliderCircle(
|
||||
Point center,
|
||||
double radius
|
||||
);
|
||||
|
||||
// 创建一个和节点位置大小相同的圆形
|
||||
ColliderCircle(
|
||||
Node * node
|
||||
);
|
||||
|
||||
virtual ~ColliderCircle();
|
||||
|
||||
// 修改圆形大小
|
||||
void setCircle(
|
||||
Point center,
|
||||
double radius
|
||||
);
|
||||
|
||||
// 获取 ID2D1Geometry 对象
|
||||
virtual ID2D1EllipseGeometry * getD2dGeometry() const override;
|
||||
|
||||
protected:
|
||||
// 重设大小
|
||||
virtual void _resize();
|
||||
|
||||
protected:
|
||||
ID2D1EllipseGeometry * m_pD2dCircle;
|
||||
};
|
||||
|
||||
|
||||
// 椭圆形
|
||||
class ColliderEllipse :
|
||||
public Collider
|
||||
{
|
||||
public:
|
||||
// 创建一个默认椭圆
|
||||
ColliderEllipse();
|
||||
|
||||
// 根据圆心和半径创建椭圆
|
||||
ColliderEllipse(
|
||||
Point center,
|
||||
double radiusX,
|
||||
double radiusY
|
||||
);
|
||||
|
||||
// 创建一个和节点位置大小相同的椭圆
|
||||
ColliderEllipse(
|
||||
Node * node
|
||||
);
|
||||
|
||||
virtual ~ColliderEllipse();
|
||||
|
||||
// 修改椭圆大小
|
||||
void setEllipse(
|
||||
Point center,
|
||||
double radiusX,
|
||||
double radiusY
|
||||
);
|
||||
|
||||
// 获取 ID2D1Geometry 对象
|
||||
virtual ID2D1EllipseGeometry * getD2dGeometry() const override;
|
||||
|
||||
protected:
|
||||
// 重设大小
|
||||
virtual void _resize();
|
||||
|
||||
protected:
|
||||
ID2D1EllipseGeometry * m_pD2dEllipse;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ struct Size
|
|||
|
||||
|
||||
// 字符串
|
||||
class String
|
||||
class String final
|
||||
{
|
||||
public:
|
||||
String();
|
||||
|
|
@ -137,6 +137,7 @@ public:
|
|||
|
||||
// 数字类型转字符串
|
||||
static String parse(int value);
|
||||
static String parse(unsigned int value);
|
||||
static String parse(float value);
|
||||
static String parse(double value);
|
||||
|
||||
|
|
@ -184,6 +185,7 @@ public:
|
|||
String& operator<< (const wchar_t *);
|
||||
String& operator<< (wchar_t *);
|
||||
String& operator<< (int value);
|
||||
String& operator<< (unsigned int value);
|
||||
String& operator<< (float value);
|
||||
String& operator<< (double value);
|
||||
|
||||
|
|
@ -379,7 +381,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
// 形状交集关系
|
||||
// 碰撞体交集关系
|
||||
class Relation
|
||||
{
|
||||
public:
|
||||
|
|
@ -394,13 +396,26 @@ public:
|
|||
};
|
||||
|
||||
|
||||
// 形状类别
|
||||
class Shape
|
||||
// 形状样式
|
||||
class ShapeStyle
|
||||
{
|
||||
public:
|
||||
enum : int
|
||||
{
|
||||
RECTANGLE, /* 矩形 */
|
||||
SOLID, /* 填充 */
|
||||
ROUND, /* 轮廓 */
|
||||
FILL, /* 轮廓 + 填充 */
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// 碰撞体类别
|
||||
class ColliderType
|
||||
{
|
||||
public:
|
||||
enum : int
|
||||
{
|
||||
RECT, /* 矩形 */
|
||||
CIRCLE, /* 圆形 */
|
||||
ELLIPSE /* 椭圆形 */
|
||||
};
|
||||
|
|
@ -565,7 +580,10 @@ public:
|
|||
virtual void onExit() {}
|
||||
|
||||
// 重写这个函数,它将在碰撞发生时自动执行
|
||||
virtual void onCollide() {}
|
||||
virtual void onCollide(
|
||||
Node* pActiveNode, /* 碰撞发生时的主动体 */
|
||||
Node* pPassiveNode /* 碰撞发生时的被动体 */
|
||||
) {}
|
||||
|
||||
// 重写这个函数,它将在关闭窗口时执行(返回 false 将阻止窗口关闭)
|
||||
virtual bool onCloseWindow() { return true; }
|
||||
|
|
@ -601,7 +619,7 @@ public:
|
|||
Node * getRoot() const;
|
||||
|
||||
// 开启或关闭节点轮廓渲染
|
||||
void showOutline(
|
||||
void showCollider(
|
||||
bool visiable = true
|
||||
);
|
||||
|
||||
|
|
@ -616,7 +634,7 @@ protected:
|
|||
bool m_bAutoUpdate;
|
||||
bool m_bSortNeeded;
|
||||
bool m_bWillSave;
|
||||
bool m_bShapeVisiable;
|
||||
bool m_bColliderVisiable;
|
||||
Node * m_pRoot;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ class Node;
|
|||
class Timer;
|
||||
class Action;
|
||||
class Music;
|
||||
class ShapeBase;
|
||||
class Collider;
|
||||
class Transition;
|
||||
class InputListener;
|
||||
class CollisionListener;
|
||||
|
||||
// 对象管理器
|
||||
class ObjectManager
|
||||
class ObjectManager final
|
||||
{
|
||||
friend Game;
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ private:
|
|||
|
||||
|
||||
// 场景管理器
|
||||
class SceneManager
|
||||
class SceneManager final
|
||||
{
|
||||
friend Game;
|
||||
friend Renderer;
|
||||
|
|
@ -87,7 +87,7 @@ private:
|
|||
|
||||
|
||||
// 定时器管理器
|
||||
class TimerManager
|
||||
class TimerManager final
|
||||
{
|
||||
friend Game;
|
||||
friend Node;
|
||||
|
|
@ -150,7 +150,7 @@ private:
|
|||
|
||||
|
||||
// 动作管理器
|
||||
class ActionManager
|
||||
class ActionManager final
|
||||
{
|
||||
friend Game;
|
||||
friend Node;
|
||||
|
|
@ -235,7 +235,7 @@ private:
|
|||
|
||||
|
||||
// 音乐管理工具
|
||||
class MusicManager
|
||||
class MusicManager final
|
||||
{
|
||||
friend Game;
|
||||
|
||||
|
|
@ -305,7 +305,7 @@ private:
|
|||
|
||||
|
||||
// 键盘和鼠标消息管理器
|
||||
class InputManager
|
||||
class InputManager final
|
||||
{
|
||||
friend Input;
|
||||
friend InputListener;
|
||||
|
|
@ -361,10 +361,10 @@ private:
|
|||
|
||||
|
||||
// 碰撞管理器
|
||||
class CollisionManager
|
||||
class ColliderManager final
|
||||
{
|
||||
friend Node;
|
||||
friend ShapeBase;
|
||||
friend Collider;
|
||||
friend CollisionListener;
|
||||
|
||||
public:
|
||||
|
|
@ -411,13 +411,19 @@ public:
|
|||
// 获取全部监听器
|
||||
static std::vector<CollisionListener*> getAll();
|
||||
|
||||
// 获取碰撞发生时的主动体
|
||||
static Node * getActiveNode();
|
||||
|
||||
// 获取碰撞发生时的被动体
|
||||
static Node * getPassiveNode();
|
||||
|
||||
// 判断碰撞是否由该节点引发(如果是,返回与其相撞的节点指针,否则返回空)
|
||||
static Node* isCausedBy(
|
||||
static Node * isCausedBy(
|
||||
Node * pNode
|
||||
);
|
||||
|
||||
// 判断发生碰撞的节点名称是否相同(若相同返回其指针,否则返回空)
|
||||
static Node* isCausedBy(
|
||||
static Node * isCausedBy(
|
||||
String name
|
||||
);
|
||||
|
||||
|
|
@ -430,19 +436,19 @@ private:
|
|||
// 更新监听器
|
||||
static void __update();
|
||||
|
||||
// 更新形状
|
||||
static void __updateShape(
|
||||
ShapeBase * pActiveShape
|
||||
// 更新碰撞体
|
||||
static void __updateCollider(
|
||||
Collider * pActiveCollider
|
||||
);
|
||||
|
||||
// 添加形状
|
||||
static void __addShape(
|
||||
ShapeBase * pShape
|
||||
// 添加碰撞体
|
||||
static void __addCollider(
|
||||
Collider * pCollider
|
||||
);
|
||||
|
||||
// 删除已绑定的形状
|
||||
static void __removeShape(
|
||||
ShapeBase * pShape
|
||||
// 删除已绑定的碰撞体
|
||||
static void __removeCollider(
|
||||
Collider * pCollider
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -7,16 +7,16 @@ namespace e2d
|
|||
|
||||
class Action;
|
||||
class Transition;
|
||||
class ShapeBase;
|
||||
class CollisionManager;
|
||||
class Collider;
|
||||
class ColliderManager;
|
||||
|
||||
class Node :
|
||||
public Object
|
||||
{
|
||||
friend Scene;
|
||||
friend ShapeBase;
|
||||
friend Collider;
|
||||
friend Transition;
|
||||
friend CollisionManager;
|
||||
friend ColliderManager;
|
||||
|
||||
public:
|
||||
Node();
|
||||
|
|
@ -116,8 +116,8 @@ public:
|
|||
// 获取节点透明度
|
||||
virtual double getOpacity() const;
|
||||
|
||||
// 获取节点形状
|
||||
virtual ShapeBase * getShape() const;
|
||||
// 获取节点碰撞体
|
||||
virtual Collider * getCollider() const;
|
||||
|
||||
// 获取父节点
|
||||
virtual Node * getParent() const;
|
||||
|
|
@ -291,50 +291,50 @@ public:
|
|||
);
|
||||
|
||||
// 修改节点宽度
|
||||
void setWidth(
|
||||
virtual void setWidth(
|
||||
double width
|
||||
);
|
||||
|
||||
// 修改节点高度
|
||||
void setHeight(
|
||||
virtual void setHeight(
|
||||
double height
|
||||
);
|
||||
|
||||
// 修改节点大小
|
||||
void setSize(
|
||||
virtual void setSize(
|
||||
double width,
|
||||
double height
|
||||
);
|
||||
|
||||
// 修改节点大小
|
||||
void setSize(
|
||||
virtual void setSize(
|
||||
Size size
|
||||
);
|
||||
|
||||
// 设置节点形状
|
||||
virtual void setShape(
|
||||
int type
|
||||
// 设置碰撞体
|
||||
virtual void setCollider(
|
||||
int nColliderType
|
||||
);
|
||||
|
||||
// 设置节点形状
|
||||
virtual void setShape(
|
||||
ShapeBase * pShape
|
||||
// 设置碰撞体
|
||||
virtual void setCollider(
|
||||
Collider * pCollider
|
||||
);
|
||||
|
||||
// 添加可碰撞节点的名称
|
||||
virtual void addCollider(
|
||||
virtual void addColliableName(
|
||||
String collliderName
|
||||
);
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 添加多个可碰撞节点的名称
|
||||
virtual void addCollider(
|
||||
virtual void addColliableName(
|
||||
const InitList<String>& vCollliderName /* 名称数组 */
|
||||
);
|
||||
#endif
|
||||
|
||||
// 移除可碰撞节点的名称
|
||||
virtual void removeCollider(
|
||||
virtual void removeColliableName(
|
||||
String collliderName
|
||||
);
|
||||
|
||||
|
|
@ -397,8 +397,8 @@ public:
|
|||
double defaultPiovtY
|
||||
);
|
||||
|
||||
// 设置节点是否包含默认形状(默认打开)
|
||||
static void setDefaultShapeEnable(
|
||||
// 设置节点是否包含默认碰撞体(默认打开)
|
||||
static void setDefaultColliderEnable(
|
||||
bool bEnable
|
||||
);
|
||||
|
||||
|
|
@ -410,7 +410,7 @@ protected:
|
|||
void _render();
|
||||
|
||||
// 渲染图形
|
||||
void _drawShape();
|
||||
void _drawCollider();
|
||||
|
||||
// 节点被添加到场景时的执行程序
|
||||
void _onEnter();
|
||||
|
|
@ -460,7 +460,7 @@ protected:
|
|||
bool m_bDisplayedInScene;
|
||||
bool m_bSortChildrenNeeded;
|
||||
bool m_bTransformNeeded;
|
||||
ShapeBase * m_pShape;
|
||||
Collider * m_pCollider;
|
||||
Scene * m_pParentScene;
|
||||
Node * m_pParent;
|
||||
D2D1::Matrix3x2F m_MatriInitial;
|
||||
|
|
@ -885,12 +885,19 @@ public:
|
|||
// 创建空菜单
|
||||
Menu();
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 创建菜单
|
||||
Menu(
|
||||
const InitList<Button*>& vButtons /* 按钮数组 */
|
||||
);
|
||||
#else
|
||||
// 创建菜单
|
||||
Menu(
|
||||
int number, /* 菜单中按钮的数量 */
|
||||
Button * button1, /* 第一个按钮 */
|
||||
...
|
||||
);
|
||||
#endif
|
||||
|
||||
// 获取菜单是否禁用
|
||||
bool isEnable() const;
|
||||
342
core/eshape.h
342
core/eshape.h
|
|
@ -1,202 +1,290 @@
|
|||
#pragma once
|
||||
#include "ebase.h"
|
||||
|
||||
#include "enode.h"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
|
||||
|
||||
class CollisionManager;
|
||||
|
||||
// ĐÎ×´
|
||||
class ShapeBase :
|
||||
public Object
|
||||
class Shape :
|
||||
public Node
|
||||
{
|
||||
friend CollisionManager;
|
||||
friend Node;
|
||||
|
||||
public:
|
||||
ShapeBase();
|
||||
Shape();
|
||||
|
||||
virtual ~ShapeBase();
|
||||
virtual ~Shape();
|
||||
|
||||
// 判断两形状的交集关系
|
||||
virtual int getRelationWith(
|
||||
ShapeBase * pShape
|
||||
) const;
|
||||
// 获取样式
|
||||
int getStyle() const;
|
||||
|
||||
// 获取父节点
|
||||
Node * getParentNode() const;
|
||||
// 获取填充颜色
|
||||
UINT32 getFillColor() const;
|
||||
|
||||
// 启用或关闭该形状
|
||||
virtual void setEnable(
|
||||
bool bEnable
|
||||
// 获取线条颜色
|
||||
UINT32 getLineColor() const;
|
||||
|
||||
// 获取线条宽度
|
||||
double getStrokeWidth() const;
|
||||
|
||||
// 设置填充颜色
|
||||
void setFillColor(
|
||||
UINT32 fillColor
|
||||
);
|
||||
|
||||
// 设置形状的可见性
|
||||
void setVisiable(
|
||||
bool bVisiable
|
||||
// 设置线条颜色
|
||||
void setLineColor(
|
||||
UINT32 lineColor
|
||||
);
|
||||
|
||||
// 设置绘制颜色
|
||||
void setColor(
|
||||
UINT32 color
|
||||
// 设置线条宽度
|
||||
void setStrokeWidth(
|
||||
double strokeWidth
|
||||
);
|
||||
|
||||
// 设置绘制透明度
|
||||
void setOpacity(
|
||||
double opacity
|
||||
);
|
||||
|
||||
// 设置大小跟随
|
||||
void setAutoResize(
|
||||
bool bEnable
|
||||
);
|
||||
|
||||
// 获取 ID2D1Geometry 对象
|
||||
virtual ID2D1Geometry * getD2dGeometry() const = 0;
|
||||
|
||||
protected:
|
||||
// 转换形状
|
||||
virtual void _transform();
|
||||
|
||||
// 重设大小
|
||||
virtual void _resize() = 0;
|
||||
// 设置样式
|
||||
void setStyle(int style);
|
||||
|
||||
// äÖČžĐÎ×´
|
||||
virtual void _render();
|
||||
virtual void onRender() override;
|
||||
|
||||
protected:
|
||||
bool m_bEnable;
|
||||
bool m_bIsVisiable;
|
||||
bool m_bAutoResize;
|
||||
UINT32 m_nColor;
|
||||
float m_fOpacity;
|
||||
Node * m_pParentNode;
|
||||
ID2D1TransformedGeometry * m_pTransformedShape;
|
||||
// 渲染轮廓
|
||||
virtual void _renderLine() = 0;
|
||||
|
||||
// 渲染填充色
|
||||
virtual void _renderFill() = 0;
|
||||
|
||||
protected:
|
||||
int m_nStyle;
|
||||
float m_fStrokeWidth;
|
||||
UINT32 m_nLineColor;
|
||||
UINT32 m_nFillColor;
|
||||
};
|
||||
|
||||
|
||||
// žŘĐÎ
|
||||
class ShapeRectangle :
|
||||
public ShapeBase
|
||||
class Rect :
|
||||
public Shape
|
||||
{
|
||||
public:
|
||||
// 创建一个默认矩形
|
||||
ShapeRectangle();
|
||||
Rect();
|
||||
|
||||
// 根据左上角坐标和宽高创建矩形
|
||||
ShapeRectangle(
|
||||
double x,
|
||||
double y,
|
||||
double width,
|
||||
double height
|
||||
Rect(
|
||||
double width, /* 宽度 */
|
||||
double height /* 高度 */
|
||||
);
|
||||
|
||||
// 创建一个和节点位置大小相同的矩形
|
||||
ShapeRectangle(
|
||||
Node * node
|
||||
Rect(
|
||||
Size size /* 宽度和高度 */
|
||||
);
|
||||
|
||||
virtual ~ShapeRectangle();
|
||||
|
||||
// 修改矩形大小
|
||||
void setRect(
|
||||
double left,
|
||||
double top,
|
||||
double right,
|
||||
double bottom
|
||||
Rect(
|
||||
double top, /* 左上角横坐标 */
|
||||
double left, /* 左上角纵坐标 */
|
||||
double width, /* 宽度 */
|
||||
double height /* 高度 */
|
||||
);
|
||||
|
||||
// 获取 ID2D1Geometry 对象
|
||||
virtual ID2D1RectangleGeometry * getD2dGeometry() const override;
|
||||
Rect(
|
||||
Point topLeft, /* 左上角坐标 */
|
||||
Size size /* 宽度和高度 */
|
||||
);
|
||||
|
||||
virtual ~Rect();
|
||||
|
||||
protected:
|
||||
// 重设大小
|
||||
virtual void _resize();
|
||||
// 渲染轮廓
|
||||
virtual void _renderLine() override;
|
||||
|
||||
// 渲染填充色
|
||||
virtual void _renderFill() override;
|
||||
};
|
||||
|
||||
|
||||
// 圆角矩形
|
||||
class RoundRect :
|
||||
public Shape
|
||||
{
|
||||
public:
|
||||
RoundRect();
|
||||
|
||||
RoundRect(
|
||||
double width, /* 宽度 */
|
||||
double height, /* 高度 */
|
||||
double radiusX, /* 圆角半径 */
|
||||
double radiusY /* 圆角半径 */
|
||||
);
|
||||
|
||||
RoundRect(
|
||||
Size size, /* 宽度和高度 */
|
||||
double radiusX, /* 圆角半径 */
|
||||
double radiusY /* 圆角半径 */
|
||||
);
|
||||
|
||||
RoundRect(
|
||||
double top, /* 左上角横坐标 */
|
||||
double left, /* 左上角纵坐标 */
|
||||
double width, /* 宽度 */
|
||||
double height, /* 高度 */
|
||||
double radiusX, /* 圆角半径 */
|
||||
double radiusY /* 圆角半径 */
|
||||
);
|
||||
|
||||
RoundRect(
|
||||
Point topLeft, /* 左上角坐标 */
|
||||
Size size, /* 宽度和高度 */
|
||||
double radiusX, /* 圆角半径 */
|
||||
double radiusY /* 圆角半径 */
|
||||
);
|
||||
|
||||
virtual ~RoundRect();
|
||||
|
||||
// 获取圆角半径
|
||||
double getRadiusX() const;
|
||||
|
||||
// 获取圆角半径
|
||||
double getRadiusY() const;
|
||||
|
||||
// 设置圆角半径
|
||||
virtual void setRadiusX(
|
||||
double radiusX
|
||||
);
|
||||
|
||||
// 设置圆角半径
|
||||
virtual void setRadiusY(
|
||||
double radiusY
|
||||
);
|
||||
|
||||
protected:
|
||||
ID2D1RectangleGeometry * m_pD2dRectangle;
|
||||
// 渲染轮廓
|
||||
virtual void _renderLine() override;
|
||||
|
||||
// 渲染填充色
|
||||
virtual void _renderFill() override;
|
||||
|
||||
protected:
|
||||
float m_fRadiusX;
|
||||
float m_fRadiusY;
|
||||
};
|
||||
|
||||
|
||||
// Ô˛ĐÎ
|
||||
class ShapeCircle :
|
||||
public ShapeBase
|
||||
class Circle :
|
||||
public Shape
|
||||
{
|
||||
public:
|
||||
// 创建一个默认圆形
|
||||
ShapeCircle();
|
||||
Circle();
|
||||
|
||||
// 根据圆心和半径创建圆形
|
||||
ShapeCircle(
|
||||
Point center,
|
||||
Circle(
|
||||
double radius /* 半径 */
|
||||
);
|
||||
|
||||
Circle(
|
||||
Point center, /* 圆心坐标 */
|
||||
double radius /* 半径 */
|
||||
);
|
||||
|
||||
Circle(
|
||||
double centerX, /* 圆心横坐标 */
|
||||
double centerY, /* 圆心纵坐标 */
|
||||
double radius /* 半径 */
|
||||
);
|
||||
|
||||
virtual ~Circle();
|
||||
|
||||
// 获取半径
|
||||
double getRadius() const;
|
||||
|
||||
// 设置半径
|
||||
virtual void setRadius(
|
||||
double radius
|
||||
);
|
||||
|
||||
// 创建一个和节点位置大小相同的圆形
|
||||
ShapeCircle(
|
||||
Node * node
|
||||
);
|
||||
public:
|
||||
// 禁用的函数
|
||||
void setWidth() {}
|
||||
|
||||
virtual ~ShapeCircle();
|
||||
// 禁用的函数
|
||||
void setHeight() {}
|
||||
|
||||
// 修改圆形大小
|
||||
void setCircle(
|
||||
Point center,
|
||||
double radius
|
||||
);
|
||||
|
||||
// 获取 ID2D1Geometry 对象
|
||||
virtual ID2D1EllipseGeometry * getD2dGeometry() const override;
|
||||
// 禁用的函数
|
||||
void setSize() {}
|
||||
|
||||
protected:
|
||||
// 重设大小
|
||||
virtual void _resize();
|
||||
// 渲染轮廓
|
||||
virtual void _renderLine() override;
|
||||
|
||||
// 渲染填充色
|
||||
virtual void _renderFill() override;
|
||||
|
||||
protected:
|
||||
ID2D1EllipseGeometry * m_pD2dCircle;
|
||||
float m_fRadius;
|
||||
};
|
||||
|
||||
|
||||
// ÍÖÔ˛ĐÎ
|
||||
class ShapeEllipse :
|
||||
public ShapeBase
|
||||
class Ellipse :
|
||||
public Shape
|
||||
{
|
||||
public:
|
||||
// 创建一个默认椭圆
|
||||
ShapeEllipse();
|
||||
Ellipse();
|
||||
|
||||
// 根据圆心和半径创建椭圆
|
||||
ShapeEllipse(
|
||||
Point center,
|
||||
double radiusX,
|
||||
Ellipse(
|
||||
double radiusX, /* 横轴半径 */
|
||||
double radiusY /* 纵轴半径 */
|
||||
);
|
||||
|
||||
Ellipse(
|
||||
Point center, /* 圆心坐标 */
|
||||
double radiusX, /* 横轴半径 */
|
||||
double radiusY /* 纵轴半径 */
|
||||
);
|
||||
|
||||
Ellipse(
|
||||
double centerX, /* 圆心横坐标 */
|
||||
double centerY, /* 圆心纵坐标 */
|
||||
double radiusX, /* 横轴半径 */
|
||||
double radiusY /* 纵轴半径 */
|
||||
);
|
||||
|
||||
virtual ~Ellipse();
|
||||
|
||||
// 获取横轴半径
|
||||
double getRadiusX() const;
|
||||
|
||||
// 获取纵轴半径
|
||||
double getRadiusY() const;
|
||||
|
||||
// 设置横轴半径
|
||||
virtual void setRadiusX(
|
||||
double radiusX
|
||||
);
|
||||
|
||||
// 设置纵轴半径
|
||||
virtual void setRadiusY(
|
||||
double radiusY
|
||||
);
|
||||
|
||||
// 创建一个和节点位置大小相同的椭圆
|
||||
ShapeEllipse(
|
||||
Node * node
|
||||
);
|
||||
public:
|
||||
// 禁用的函数
|
||||
void setWidth() {}
|
||||
|
||||
virtual ~ShapeEllipse();
|
||||
// 禁用的函数
|
||||
void setHeight() {}
|
||||
|
||||
// 修改椭圆大小
|
||||
void setEllipse(
|
||||
Point center,
|
||||
double radiusX,
|
||||
double radiusY
|
||||
);
|
||||
|
||||
// 获取 ID2D1Geometry 对象
|
||||
virtual ID2D1EllipseGeometry * getD2dGeometry() const override;
|
||||
// 禁用的函数
|
||||
void setSize() {}
|
||||
|
||||
protected:
|
||||
// 重设大小
|
||||
virtual void _resize();
|
||||
// 渲染轮廓
|
||||
virtual void _renderLine() override;
|
||||
|
||||
// 渲染填充色
|
||||
virtual void _renderFill() override;
|
||||
|
||||
protected:
|
||||
ID2D1EllipseGeometry * m_pD2dEllipse;
|
||||
float m_fRadiusX;
|
||||
float m_fRadiusY;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ namespace e2d
|
|||
class TimerManager;
|
||||
class MusicManager;
|
||||
class InputManager;
|
||||
class CollisionManager;
|
||||
class ColliderManager;
|
||||
|
||||
// 随机数产生器
|
||||
class Random
|
||||
|
|
@ -196,7 +196,7 @@ protected:
|
|||
class CollisionListener
|
||||
: public Listener
|
||||
{
|
||||
friend CollisionManager;
|
||||
friend ColliderManager;
|
||||
|
||||
public:
|
||||
CollisionListener();
|
||||
|
|
@ -211,6 +211,10 @@
|
|||
<ClCompile Include="..\..\core\Base\Renderer.cpp" />
|
||||
<ClCompile Include="..\..\core\Base\Time.cpp" />
|
||||
<ClCompile Include="..\..\core\Base\Window.cpp" />
|
||||
<ClCompile Include="..\..\core\Collider\Collider.cpp" />
|
||||
<ClCompile Include="..\..\core\Collider\ColliderCircle.cpp" />
|
||||
<ClCompile Include="..\..\core\Collider\ColliderEllipse.cpp" />
|
||||
<ClCompile Include="..\..\core\Collider\ColliderRect.cpp" />
|
||||
<ClCompile Include="..\..\core\Common\Font.cpp" />
|
||||
<ClCompile Include="..\..\core\Common\Object.cpp" />
|
||||
<ClCompile Include="..\..\core\Common\Point.cpp" />
|
||||
|
|
@ -222,19 +226,20 @@
|
|||
<ClCompile Include="..\..\core\Manager\InputManager.cpp" />
|
||||
<ClCompile Include="..\..\core\Manager\MusicManager.cpp" />
|
||||
<ClCompile Include="..\..\core\Manager\ObjectManager.cpp" />
|
||||
<ClCompile Include="..\..\core\Manager\CollisionManager.cpp" />
|
||||
<ClCompile Include="..\..\core\Manager\ColliderManager.cpp" />
|
||||
<ClCompile Include="..\..\core\Manager\SceneManager.cpp" />
|
||||
<ClCompile Include="..\..\core\Manager\TimerManager.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Button.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\ButtonToggle.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Menu.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Node.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Shape\Circle.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Shape\Ellipse.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Shape\Rect.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Shape\RoundRect.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Shape\Shape.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Sprite.cpp" />
|
||||
<ClCompile Include="..\..\core\Node\Text.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\ShapeBase.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\ShapeCircle.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\ShapeEllipse.cpp" />
|
||||
<ClCompile Include="..\..\core\Shape\ShapeRectangle.cpp" />
|
||||
<ClCompile Include="..\..\core\Tool\CollisionListener.cpp" />
|
||||
<ClCompile Include="..\..\core\Tool\Data.cpp" />
|
||||
<ClCompile Include="..\..\core\Tool\InputListener.cpp" />
|
||||
|
|
@ -249,16 +254,17 @@
|
|||
<ClCompile Include="..\..\core\Transition\TransitionMove.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\core\eactions.h" />
|
||||
<ClInclude Include="..\..\core\eaction.h" />
|
||||
<ClInclude Include="..\..\core\easy2d.h" />
|
||||
<ClInclude Include="..\..\core\ebase.h" />
|
||||
<ClInclude Include="..\..\core\ecommon.h" />
|
||||
<ClInclude Include="..\..\core\eshape.h" />
|
||||
<ClInclude Include="..\..\core\ecollider.h" />
|
||||
<ClInclude Include="..\..\core\emacros.h" />
|
||||
<ClInclude Include="..\..\core\emanagers.h" />
|
||||
<ClInclude Include="..\..\core\enodes.h" />
|
||||
<ClInclude Include="..\..\core\etools.h" />
|
||||
<ClInclude Include="..\..\core\etransitions.h" />
|
||||
<ClInclude Include="..\..\core\emanager.h" />
|
||||
<ClInclude Include="..\..\core\enode.h" />
|
||||
<ClInclude Include="..\..\core\eshape.h" />
|
||||
<ClInclude Include="..\..\core\etool.h" />
|
||||
<ClInclude Include="..\..\core\etransition.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
|||
|
|
@ -22,8 +22,11 @@
|
|||
<Filter Include="Common">
|
||||
<UniqueIdentifier>{be5d9314-b00a-4f11-bd2a-1f720dc32407}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Shape">
|
||||
<UniqueIdentifier>{d5f86335-f3a0-450d-92a3-7edd9348d995}</UniqueIdentifier>
|
||||
<Filter Include="Collider">
|
||||
<UniqueIdentifier>{765a2a00-5764-40f9-a15d-17b0640c6b53}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Node\Shape">
|
||||
<UniqueIdentifier>{eb72b49a-5b2f-4fc0-9ad2-8f5e02efac6f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
@ -168,21 +171,9 @@
|
|||
<ClCompile Include="..\..\core\Tool\Path.cpp">
|
||||
<Filter>Tool</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\ShapeRectangle.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\ShapeEllipse.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\ShapeCircle.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Tool\InputListener.cpp">
|
||||
<Filter>Tool</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Manager\CollisionManager.cpp">
|
||||
<Filter>Manager</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Tool\CollisionListener.cpp">
|
||||
<Filter>Tool</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -195,20 +186,48 @@
|
|||
<ClCompile Include="..\..\core\Action\ActionFunc.cpp">
|
||||
<Filter>Action</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Shape\ShapeBase.cpp">
|
||||
<Filter>Shape</Filter>
|
||||
<ClCompile Include="..\..\core\Collider\Collider.cpp">
|
||||
<Filter>Collider</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Collider\ColliderCircle.cpp">
|
||||
<Filter>Collider</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Collider\ColliderEllipse.cpp">
|
||||
<Filter>Collider</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Collider\ColliderRect.cpp">
|
||||
<Filter>Collider</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Manager\ColliderManager.cpp">
|
||||
<Filter>Manager</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Node\Shape\Shape.cpp">
|
||||
<Filter>Node\Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Node\Shape\Circle.cpp">
|
||||
<Filter>Node\Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Node\Shape\Rect.cpp">
|
||||
<Filter>Node\Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Node\Shape\RoundRect.cpp">
|
||||
<Filter>Node\Shape</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\Node\Shape\Ellipse.cpp">
|
||||
<Filter>Node\Shape</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\core\etools.h" />
|
||||
<ClInclude Include="..\..\core\enodes.h" />
|
||||
<ClInclude Include="..\..\core\emacros.h" />
|
||||
<ClInclude Include="..\..\core\ecommon.h" />
|
||||
<ClInclude Include="..\..\core\ebase.h" />
|
||||
<ClInclude Include="..\..\core\easy2d.h" />
|
||||
<ClInclude Include="..\..\core\eactions.h" />
|
||||
<ClInclude Include="..\..\core\etransitions.h" />
|
||||
<ClInclude Include="..\..\core\emanagers.h" />
|
||||
<ClInclude Include="..\..\core\ecollider.h" />
|
||||
<ClInclude Include="..\..\core\eshape.h" />
|
||||
<ClInclude Include="..\..\core\etransition.h" />
|
||||
<ClInclude Include="..\..\core\emanager.h" />
|
||||
<ClInclude Include="..\..\core\enode.h" />
|
||||
<ClInclude Include="..\..\core\etool.h" />
|
||||
<ClInclude Include="..\..\core\eaction.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Loading…
Reference in New Issue