new feature: shape and collision.

This commit is contained in:
Nomango 2018-02-03 22:04:43 +08:00
parent 1a52f19dd4
commit f6eecee3aa
46 changed files with 823 additions and 1905 deletions

View File

@ -56,7 +56,7 @@ void e2d::EAction::setTarget(ENode * node)
e2d::EAction * e2d::EAction::reverse() const e2d::EAction * e2d::EAction::reverse() const
{ {
assert(0); ASSERT(false, "EAction cannot be reversed!");
return nullptr; return nullptr;
} }

View File

@ -13,6 +13,7 @@ void e2d::EActionGradual::_init()
void e2d::EActionGradual::_update() void e2d::EActionGradual::_update()
{ {
EAction::_update();
// 判断时间间隔是否足够 // 判断时间间隔是否足够
if (m_fDuration == 0) if (m_fDuration == 0)
{ {

View File

@ -21,9 +21,9 @@ e2d::EActionSequence::EActionSequence(int number, EAction * action1, ...) :
e2d::EActionSequence::~EActionSequence() e2d::EActionSequence::~EActionSequence()
{ {
for (auto action = m_vActions.begin(); action != m_vActions.end(); action++) for (auto action : m_vActions)
{ {
SafeRelease(&(*action)); SafeRelease(&action);
} }
} }
@ -33,9 +33,9 @@ void e2d::EActionSequence::_init()
// 将所有动作与目标绑定 // 将所有动作与目标绑定
if (m_pTarget) if (m_pTarget)
{ {
for (auto action = m_vActions.begin(); action != m_vActions.end(); action++) for (auto action : m_vActions)
{ {
(*action)->setTarget(m_pTarget); action->setTarget(m_pTarget);
} }
} }
// 初始化第一个动作 // 初始化第一个动作
@ -66,18 +66,18 @@ void e2d::EActionSequence::_update()
void e2d::EActionSequence::_reset() void e2d::EActionSequence::_reset()
{ {
EAction::_reset(); EAction::_reset();
for (auto action = m_vActions.begin(); action != m_vActions.end(); action++) for (auto action : m_vActions)
{ {
(*action)->_reset(); action->_reset();
} }
m_nActionIndex = 0; m_nActionIndex = 0;
} }
void e2d::EActionSequence::_resetTime() void e2d::EActionSequence::_resetTime()
{ {
for (auto action = m_vActions.begin(); action != m_vActions.end(); action++) for (auto action : m_vActions)
{ {
(*action)->_resetTime(); action->_resetTime();
} }
} }
@ -93,9 +93,9 @@ void e2d::EActionSequence::addAction(EAction * action)
e2d::EActionSequence * e2d::EActionSequence::clone() const e2d::EActionSequence * e2d::EActionSequence::clone() const
{ {
auto a = new EActionSequence(); auto a = new EActionSequence();
for (auto action = m_vActions.begin(); action != m_vActions.end(); action++) for (auto action : m_vActions)
{ {
a->addAction((*action)->clone()); a->addAction(action->clone());
} }
return a; return a;
} }
@ -103,15 +103,15 @@ e2d::EActionSequence * e2d::EActionSequence::clone() const
e2d::EActionSequence * e2d::EActionSequence::reverse(bool actionReverse) const e2d::EActionSequence * e2d::EActionSequence::reverse(bool actionReverse) const
{ {
auto a = new EActionSequence(); auto a = new EActionSequence();
for (auto action = m_vActions.begin(); action != m_vActions.end(); action++) for (auto action : m_vActions)
{ {
if (actionReverse) if (actionReverse)
{ {
a->addAction((*action)->reverse()); a->addAction(action->reverse());
} }
else else
{ {
a->addAction((*action)->clone()); a->addAction(action->clone());
} }
} }
// 将动作顺序逆序排列 // 将动作顺序逆序排列

View File

@ -13,9 +13,9 @@ e2d::EAnimation::EAnimation(float invertal)
e2d::EAnimation::~EAnimation() e2d::EAnimation::~EAnimation()
{ {
for (auto frame = m_vFrames.begin(); frame != m_vFrames.end(); frame++) for (auto frame : m_vFrames)
{ {
SafeRelease(&(*frame)); SafeRelease(&frame);
} }
} }
@ -62,7 +62,7 @@ void e2d::EAnimation::_reset()
m_nFrameIndex = 0; m_nFrameIndex = 0;
} }
void e2d::EAnimation::addKeyframe(EKeyframe * frame) void e2d::EAnimation::addKeyframe(EImage * frame)
{ {
if (frame) if (frame)
{ {
@ -74,9 +74,9 @@ void e2d::EAnimation::addKeyframe(EKeyframe * frame)
e2d::EAnimation * e2d::EAnimation::clone() const e2d::EAnimation * e2d::EAnimation::clone() const
{ {
auto a = new EAnimation(m_fInterval); auto a = new EAnimation(m_fInterval);
for (auto frame = m_vFrames.begin(); frame != m_vFrames.end(); frame++) for (auto frame : m_vFrames)
{ {
a->addKeyframe((*frame)); a->addKeyframe(frame);
} }
return a; return a;
} }

View File

@ -167,6 +167,8 @@ void e2d::EGame::uninit()
EMusicManager::__uninit(); EMusicManager::__uninit();
// 恢复计时操作 // 恢复计时操作
ETime::__uninit(); ETime::__uninit();
// 헌왕暠튬뻠닸
EImage::clearCache();
// 删除渲染相关资源 // 删除渲染相关资源
ERenderer::__discardResources(); ERenderer::__discardResources();
// 刷新内存池 // 刷新内存池

View File

@ -133,7 +133,7 @@ void e2d::ERenderer::__render()
if (FAILED(hr)) if (FAILED(hr))
{ {
// 渲染时产生了未知的错误,退出游戏 // 渲染时产生了未知的错误,退出游戏
ASSERT(false, L"Renderer error!"); ASSERT(false, L"Renderer error: %#X!", hr);
EGame::quit(); EGame::quit();
} }
} }

View File

@ -1,83 +1,82 @@
#include "..\enodes.h" #include "..\enodes.h"
#include <map> #include <map>
struct ResKey
{
ResKey() { resNameHash = 0; resTypeHash = 0; }
bool operator < (ResKey const& key) const
{
if (resNameHash > key.resNameHash)
return true;
else if (resNameHash == key.resNameHash)
return resTypeHash > key.resTypeHash;
else
return false;
}
size_t resNameHash;
size_t resTypeHash;
};
static std::map<size_t, ID2D1Bitmap*> s_mBitmapsFromFile; static std::map<size_t, ID2D1Bitmap*> s_mBitmapsFromFile;
static std::map<ResKey, ID2D1Bitmap*> s_mBitmapsFromResource;
e2d::EImage::EImage() e2d::EImage::EImage()
: m_pBitmap(nullptr) : m_pBitmap(nullptr)
, m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_fSourceClipWidth(0)
, m_fSourceClipHeight(0)
{ {
} }
e2d::EImage::EImage(LPCTSTR fileName) e2d::EImage::EImage(LPCTSTR strFileName)
{ {
this->loadFromFile(fileName); this->loadFrom(strFileName);
} }
e2d::EImage::EImage(LPCTSTR resourceName, LPCTSTR resourceType) e2d::EImage::EImage(LPCTSTR strFileName, float nClipX, float nClipY, float nClipWidth, float nClipHeight)
{ {
this->loadFromResource(resourceName, resourceType); this->loadFrom(strFileName);
this->clip(nClipX, nClipY, nClipWidth, nClipHeight);
} }
e2d::EImage::~EImage() e2d::EImage::~EImage()
{ {
} }
void e2d::EImage::loadFromFile(const EString & fileName) void e2d::EImage::loadFrom(const EString & strFilePath)
{ {
WARN_IF(fileName.isEmpty(), "EImage cannot load bitmap from NULL file name."); WARN_IF(strFilePath.isEmpty(), "EImage cannot load bitmap from NULL file name.");
if (fileName.isEmpty()) if (strFilePath.isEmpty())
return; return;
if (!e2d::EImage::preload(fileName)) if (!EImage::preload(strFilePath))
{ {
WARN_IF(true, "Load EImage from file failed!"); WARN_IF(true, "Load EImage from file failed!");
return; return;
} }
m_pBitmap = s_mBitmapsFromFile.at(fileName.hash()); m_pBitmap = s_mBitmapsFromFile.at(strFilePath.hash());
m_fSourceClipX = m_fSourceClipY = 0;
m_fSourceClipWidth = m_pBitmap->GetSize().width;
m_fSourceClipHeight = m_pBitmap->GetSize().height;
} }
void e2d::EImage::loadFromResource(LPCTSTR resourceName, LPCTSTR resourceType) void e2d::EImage::loadFrom(const EString & strFilePath, float x, float y, float width, float height)
{ {
WARN_IF(!resourceName || !resourceType, "EImage cannot load bitmap from NULL resource."); loadFrom(strFilePath);
clip(x, y, width, height);
}
if (!resourceName || !resourceType) void e2d::EImage::clip(float x, float y, float width, float height)
return; {
if (m_pBitmap)
if (!e2d::EImage::preload(resourceName, resourceType))
{ {
WARN_IF(true, "Load EImage from resource failed!"); m_fSourceClipX = min(max(x, 0), this->getSourceWidth());
return; m_fSourceClipY = min(max(y, 0), this->getSourceHeight());
m_fSourceClipWidth = min(max(width, 0), this->getSourceWidth() - m_fSourceClipX);
m_fSourceClipHeight = min(max(height, 0), this->getSourceHeight() - m_fSourceClipY);
} }
}
ResKey key; float e2d::EImage::getWidth() const
std::hash<LPCTSTR> h; {
key.resNameHash = h(resourceName); return m_fSourceClipWidth;
key.resTypeHash = h(resourceType); }
m_pBitmap = s_mBitmapsFromResource.at(key); float e2d::EImage::getHeight() const
{
return m_fSourceClipHeight;
}
e2d::ESize e2d::EImage::getSize() const
{
return ESize(m_fSourceClipWidth, m_fSourceClipHeight);
} }
float e2d::EImage::getSourceWidth() const float e2d::EImage::getSourceWidth() const
@ -116,6 +115,21 @@ e2d::ESize e2d::EImage::getSourceSize() const
} }
} }
float e2d::EImage::getClipX() const
{
return m_fSourceClipX;
}
float e2d::EImage::getClipY() const
{
return m_fSourceClipY;
}
e2d::EPoint e2d::EImage::getClipPos() const
{
return EPoint(m_fSourceClipX, m_fSourceClipY);
}
bool e2d::EImage::preload(const EString & fileName) bool e2d::EImage::preload(const EString & fileName)
{ {
if (s_mBitmapsFromFile.find(fileName.hash()) != s_mBitmapsFromFile.end()) if (s_mBitmapsFromFile.find(fileName.hash()) != s_mBitmapsFromFile.end())
@ -192,161 +206,16 @@ bool e2d::EImage::preload(const EString & fileName)
return SUCCEEDED(hr); return SUCCEEDED(hr);
} }
bool e2d::EImage::preload(LPCTSTR resourceName, LPCTSTR resourceType)
{
std::hash<LPCTSTR> h;
ResKey key;
key.resNameHash = h(resourceName);
key.resTypeHash = h(resourceType);
if (s_mBitmapsFromResource.find(key) != s_mBitmapsFromResource.end())
{
return true;
}
HRESULT hr = S_OK;
IWICBitmapDecoder *pDecoder = nullptr;
IWICBitmapFrameDecode *pSource = nullptr;
IWICStream *pStream = nullptr;
IWICFormatConverter *pConverter = nullptr;
ID2D1Bitmap *pBitmap = nullptr;
HRSRC imageResHandle = nullptr;
HGLOBAL imageResDataHandle = nullptr;
void *pImageFile = nullptr;
DWORD imageFileSize = 0;
// 定位资源
imageResHandle = ::FindResourceW(HINST_THISCOMPONENT, resourceName, resourceType);
hr = imageResHandle ? S_OK : E_FAIL;
if (SUCCEEDED(hr))
{
// 加载资源
imageResDataHandle = ::LoadResource(HINST_THISCOMPONENT, imageResHandle);
hr = imageResDataHandle ? S_OK : E_FAIL;
}
if (SUCCEEDED(hr))
{
// 获取文件指针,并锁定资源
pImageFile = ::LockResource(imageResDataHandle);
hr = pImageFile ? S_OK : E_FAIL;
}
if (SUCCEEDED(hr))
{
// 计算大小
imageFileSize = SizeofResource(HINST_THISCOMPONENT, imageResHandle);
hr = imageFileSize ? S_OK : E_FAIL;
}
if (SUCCEEDED(hr))
{
// 创建 WIC 流
hr = ERenderer::getIWICImagingFactory()->CreateStream(&pStream);
}
if (SUCCEEDED(hr))
{
// 初始化流
hr = pStream->InitializeFromMemory(
reinterpret_cast<BYTE*>(pImageFile),
imageFileSize
);
}
if (SUCCEEDED(hr))
{
// 创建流的解码器
hr = ERenderer::getIWICImagingFactory()->CreateDecoderFromStream(
pStream,
NULL,
WICDecodeMetadataCacheOnLoad,
&pDecoder
);
}
if (SUCCEEDED(hr))
{
// 创建初始化框架
hr = pDecoder->GetFrame(0, &pSource);
}
if (SUCCEEDED(hr))
{
// 创建图片格式转换器
// (DXGI_FORMAT_B8G8R8A8_UNORM + D2D1_ALPHA_MODE_PREMULTIPLIED).
hr = ERenderer::getIWICImagingFactory()->CreateFormatConverter(&pConverter);
}
if (SUCCEEDED(hr))
{
// 图片格式转换成 32bppPBGRA
hr = pConverter->Initialize(
pSource,
GUID_WICPixelFormat32bppPBGRA,
WICBitmapDitherTypeNone,
NULL,
0.f,
WICBitmapPaletteTypeMedianCut
);
}
if (SUCCEEDED(hr))
{
// 从 WIC 位图创建一个 Direct2D 位图
hr = ERenderer::getRenderTarget()->CreateBitmapFromWicBitmap(
pConverter,
NULL,
&pBitmap
);
}
if (SUCCEEDED(hr))
{
std::hash<LPCTSTR> h;
ResKey key;
key.resNameHash = h(resourceName);
key.resTypeHash = h(resourceType);
s_mBitmapsFromResource.insert(
std::map<ResKey, ID2D1Bitmap*>::value_type(
key,
pBitmap)
);
}
// 释放相关资源
SafeReleaseInterface(&pDecoder);
SafeReleaseInterface(&pSource);
SafeReleaseInterface(&pStream);
SafeReleaseInterface(&pConverter);
return SUCCEEDED(hr);
}
void e2d::EImage::clearCache() void e2d::EImage::clearCache()
{ {
for (auto child = s_mBitmapsFromFile.begin(); child != s_mBitmapsFromFile.end(); child++) for (auto child : s_mBitmapsFromFile)
{ {
SafeReleaseInterface(&(*child).second); SafeReleaseInterface(&child.second);
}
for (auto child = s_mBitmapsFromFile.begin(); child != s_mBitmapsFromFile.end(); child++)
{
SafeReleaseInterface(&(*child).second);
} }
s_mBitmapsFromFile.clear(); s_mBitmapsFromFile.clear();
s_mBitmapsFromResource.clear();
} }
ID2D1Bitmap * e2d::EImage::_getBitmap() ID2D1Bitmap * e2d::EImage::getBitmap()
{ {
return m_pBitmap; return m_pBitmap;
} }

View File

@ -1,118 +0,0 @@
#include "..\ecommon.h"
e2d::EKeyframe::EKeyframe()
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_fSourceClipWidth(0)
, m_fSourceClipHeight(0)
, m_pImage(nullptr)
{
}
e2d::EKeyframe::EKeyframe(EImage * texture)
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_fSourceClipWidth(0)
, m_fSourceClipHeight(0)
, m_pImage(nullptr)
{
_setImage(texture);
}
e2d::EKeyframe::EKeyframe(const EString & imageFileName)
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_fSourceClipWidth(0)
, m_fSourceClipHeight(0)
, m_pImage(nullptr)
{
_setImage(new EImage(imageFileName));
}
e2d::EKeyframe::EKeyframe(LPCTSTR resourceName, LPCTSTR resourceType)
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_fSourceClipWidth(0)
, m_fSourceClipHeight(0)
, m_pImage(nullptr)
{
_setImage(new EImage(resourceName, resourceType));
}
e2d::EKeyframe::EKeyframe(EImage * texture, float x, float y, float width, float height)
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_fSourceClipWidth(0)
, m_fSourceClipHeight(0)
, m_pImage(nullptr)
{
_setImage(texture);
_clipTexture(x, y, width, height);
}
e2d::EKeyframe::EKeyframe(const EString & imageFileName, float x, float y, float width, float height)
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_fSourceClipWidth(0)
, m_fSourceClipHeight(0)
, m_pImage(nullptr)
{
_setImage(new EImage(imageFileName));
_clipTexture(x, y, width, height);
}
e2d::EKeyframe::EKeyframe(LPCTSTR resourceName, LPCTSTR resourceType, float x, float y, float width, float height)
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_fSourceClipWidth(0)
, m_fSourceClipHeight(0)
, m_pImage(nullptr)
{
_setImage(new EImage(resourceName, resourceType));
_clipTexture(x, y, width, height);
}
e2d::EKeyframe::~EKeyframe()
{
SafeRelease(&m_pImage);
}
float e2d::EKeyframe::getWidth() const
{
return m_fSourceClipWidth;
}
float e2d::EKeyframe::getHeight() const
{
return m_fSourceClipHeight;
}
e2d::EImage * e2d::EKeyframe::getImage() const
{
return m_pImage;
}
void e2d::EKeyframe::_setImage(EImage * texture)
{
if (texture)
{
SafeRelease(&m_pImage);
m_pImage = texture;
m_pImage->retain();
m_fSourceClipX = 0;
m_fSourceClipY = 0;
m_fSourceClipWidth = texture->getSourceWidth();
m_fSourceClipHeight = texture->getSourceHeight();
}
}
void e2d::EKeyframe::_clipTexture(float x, float y, float width, float height)
{
if (m_pImage)
{
m_fSourceClipX = min(max(x, 0), m_pImage->getSourceWidth());
m_fSourceClipY = min(max(y, 0), m_pImage->getSourceHeight());
m_fSourceClipWidth = min(max(width, 0), m_pImage->getSourceWidth() - m_fSourceClipX);
m_fSourceClipHeight = min(max(height, 0), m_pImage->getSourceHeight() - m_fSourceClipY);
}
}

View File

@ -7,8 +7,9 @@
e2d::EScene::EScene() e2d::EScene::EScene()
: m_bWillSave(true) : m_bWillSave(true)
, m_bAutoUpdate(true)
, m_bSortNeeded(false) , m_bSortNeeded(false)
, m_bGeometryVisiable(false) , m_bShapeVisiable(false)
, m_pRoot(new ENode()) , m_pRoot(new ENode())
{ {
m_pRoot->retain(); m_pRoot->retain();
@ -27,23 +28,31 @@ void e2d::EScene::_render()
{ {
m_pRoot->_render(); m_pRoot->_render();
if (m_bGeometryVisiable) if (m_bShapeVisiable)
{ {
// 恢复矩阵转换 // 恢复矩阵转换
ERenderer::getRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity()); ERenderer::getRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity());
// 绘制所有几何图形 // 绘制所有几何图形
m_pRoot->_drawGeometry(); m_pRoot->_drawShape();
} }
} }
void e2d::EScene::_update() void e2d::EScene::_update()
{ {
// 执行 onUpdate 函数 // 执行 onUpdate 函数
if (m_bAutoUpdate)
{
this->onUpdate(); this->onUpdate();
}
// 更新根节点 // 更新根节点
m_pRoot->_update(); m_pRoot->_update();
} }
void e2d::EScene::setAutoUpdate(bool bAutoUpdate)
{
m_bAutoUpdate = bAutoUpdate;
}
void e2d::EScene::add(ENode * child, int order /* = 0 */) void e2d::EScene::add(ENode * child, int order /* = 0 */)
{ {
m_pRoot->addChild(child, order); m_pRoot->addChild(child, order);
@ -54,42 +63,12 @@ bool e2d::EScene::remove(ENode * child)
return m_pRoot->removeChild(child); return m_pRoot->removeChild(child);
} }
void e2d::EScene::remove(const EString &childName)
{
return m_pRoot->removeChild(childName);
}
std::vector<e2d::ENode*> e2d::EScene::getChildren()
{
return m_pRoot->m_vChildren;
}
size_t e2d::EScene::getChildrenCount() const
{
return m_pRoot->getChildrenCount();
}
e2d::ENode * e2d::EScene::getChild(const EString &childName)
{
return m_pRoot->getChild(childName);
}
e2d::ENode * e2d::EScene::getRoot() const e2d::ENode * e2d::EScene::getRoot() const
{ {
return m_pRoot; return m_pRoot;
} }
void e2d::EScene::clearAllChildren() void e2d::EScene::setShapeVisiable(bool visiable)
{ {
m_pRoot->clearAllChildren(); m_bShapeVisiable = visiable;
}
void e2d::EScene::runAction(EAction * action)
{
this->m_pRoot->runAction(action);
}
void e2d::EScene::setGeometryVisiable(bool visiable)
{
m_bGeometryVisiable = visiable;
} }

View File

@ -28,7 +28,9 @@ EString::EString(const wchar_t *str)
} }
else else
{ {
this->EString::EString(); _size = 0;
_string = new wchar_t[1];
_string[0] = 0;
} }
} }
@ -49,7 +51,9 @@ EString::EString(const EString &str)
} }
else else
{ {
this->EString::EString(); _size = 0;
_string = new wchar_t[1];
_string[0] = 0;
} }
} }
@ -63,7 +67,9 @@ e2d::EString::EString(const std::wstring &str)
} }
else else
{ {
this->EString::EString(); _size = 0;
_string = new wchar_t[1];
_string[0] = 0;
} }
} }
@ -86,8 +92,9 @@ EString &EString::operator=(const wchar_t *str)
} }
else else
{ {
_string = nullptr;
_size = 0; _size = 0;
_string = new wchar_t[1];
_string[0] = 0;
} }
return *this; return *this;
} }
@ -106,8 +113,9 @@ EString &EString::operator=(const EString &str)
} }
else else
{ {
_string = nullptr;
_size = 0; _size = 0;
_string = new wchar_t[1];
_string[0] = 0;
} }
return *this; return *this;
} }
@ -123,15 +131,23 @@ EString & e2d::EString::operator=(const std::wstring &str)
} }
else else
{ {
_string = nullptr;
_size = 0; _size = 0;
_string = new wchar_t[1];
_string[0] = 0;
} }
return *this; return *this;
} }
bool EString::operator==(const wchar_t *str) bool EString::operator==(const wchar_t *str)
{ {
if (str)
{
return (wcscmp(str, _string) == 0); return (wcscmp(str, _string) == 0);
}
else
{
return false;
}
} }
bool EString::operator ==(const EString &str) bool EString::operator ==(const EString &str)

View File

@ -1,20 +0,0 @@
#include "..\ecommon.h"
e2d::EPhysicsEvent::INTERSECT_RELATION e2d::EPhysicsEvent::s_nRelation = e2d::EPhysicsEvent::UNKNOWN;
e2d::EGeometry * e2d::EPhysicsEvent::s_pActiveGeometry = nullptr;
e2d::EGeometry * e2d::EPhysicsEvent::s_pPassiveGeometry = nullptr;
e2d::EPhysicsEvent::INTERSECT_RELATION e2d::EPhysicsEvent::getMsg()
{
return EPhysicsEvent::s_nRelation;
}
e2d::EGeometry * e2d::EPhysicsEvent::getActiveGeometry()
{
return EPhysicsEvent::s_pActiveGeometry;
}
e2d::EGeometry * e2d::EPhysicsEvent::getPassiveGeometry()
{
return EPhysicsEvent::s_pPassiveGeometry;
}

View File

@ -1,112 +0,0 @@
#include "..\egeometry.h"
#include "..\emanagers.h"
#include "..\enodes.h"
e2d::EGeometry::EGeometry()
: m_nCategoryBitmask(0)
, m_nCollisionBitmask(0)
, m_bIsVisiable(true)
, m_nColor(EColor::RED)
, m_fOpacity(1)
, m_pParentNode(nullptr)
, m_pTransformedGeometry(nullptr)
{
}
e2d::EGeometry::~EGeometry()
{
SafeReleaseInterface(&m_pTransformedGeometry);
}
e2d::ENode * e2d::EGeometry::getParentNode() const
{
return m_pParentNode;
}
UINT32 e2d::EGeometry::getCategoryBitmask() const
{
return m_nCategoryBitmask;
}
UINT32 e2d::EGeometry::getCollisionBitmask() const
{
return m_nCollisionBitmask;
}
void e2d::EGeometry::setCategoryBitmask(UINT32 mask)
{
m_nCategoryBitmask = mask;
}
void e2d::EGeometry::setCollisionBitmask(UINT32 mask)
{
m_nCollisionBitmask = mask;
}
void e2d::EGeometry::setVisiable(bool bVisiable)
{
m_bIsVisiable = bVisiable;
}
void e2d::EGeometry::setColor(UINT32 color)
{
m_nColor = color;
}
void e2d::EGeometry::setOpacity(float opacity)
{
m_fOpacity = min(max(opacity, 0), 1);
}
void e2d::EGeometry::_render()
{
if (m_pTransformedGeometry)
{
ID2D1SolidColorBrush * pBrush = ERenderer::getSolidColorBrush();
// 创建画刷
ERenderer::getRenderTarget()->CreateSolidColorBrush(
D2D1::ColorF(
m_nColor,
m_fOpacity),
&pBrush
);
// 绘制几何形状
ERenderer::getRenderTarget()->DrawGeometry(m_pTransformedGeometry, pBrush);
}
}
e2d::EPhysicsEvent::INTERSECT_RELATION e2d::EGeometry::_intersectWith(EGeometry * pGeometry)
{
if (m_pTransformedGeometry && pGeometry->m_pTransformedGeometry)
{
D2D1_GEOMETRY_RELATION relation;
m_pTransformedGeometry->CompareWithGeometry(
pGeometry->m_pTransformedGeometry,
D2D1::Matrix3x2F::Identity(),
&relation
);
return EPhysicsEvent::INTERSECT_RELATION(relation);
}
return EPhysicsEvent::UNKNOWN;
}
void e2d::EGeometry::_transform()
{
if (m_pParentNode)
{
// 释放原形状
SafeReleaseInterface(&m_pTransformedGeometry);
// 根据父节点转换几何图形
ERenderer::getID2D1Factory()->CreateTransformedGeometry(
_getD2dGeometry(),
m_pParentNode->m_MatriFinal,
&m_pTransformedGeometry
);
// 判断形状变换后的情况
EPhysicsManager::PhysicsGeometryProc(this);
}
}

View File

@ -1,73 +0,0 @@
#include "..\elisteners.h"
#include "..\emanagers.h"
#include "..\enodes.h"
e2d::EListener::EListener()
: m_bRunning(false)
, m_bAlways(false)
, m_pParentNode(nullptr)
, m_bSwallow(false)
{
}
e2d::EListener::EListener(const EString & name)
: m_bRunning(false)
, m_bAlways(false)
, m_pParentNode(nullptr)
, m_bSwallow(false)
{
m_sName = name;
}
bool e2d::EListener::isRunning() const
{
return m_bRunning;
}
void e2d::EListener::start()
{
m_bRunning = true;
}
void e2d::EListener::stop()
{
m_bRunning = false;
}
e2d::EString e2d::EListener::getName() const
{
return m_sName;
}
e2d::ENode * e2d::EListener::getParentNode() const
{
return m_pParentNode;
}
void e2d::EListener::setName(const EString & name)
{
m_sName = name;
}
void e2d::EListener::setSwallow(bool bSwallow)
{
m_bSwallow = bSwallow;
}
void e2d::EListener::setAlwaysWorking(bool bAlways)
{
m_bAlways = bAlways;
}
bool e2d::EListener::_isReady() const
{
if (m_bRunning && m_pParentNode)
{
if (m_pParentNode->getParentScene() == ESceneManager::getCurrentScene())
{
if (!EGame::isPaused() || m_bAlways)
return true;
}
}
return false;
}

View File

@ -1,60 +0,0 @@
#include "..\elisteners.h"
#include "..\egeometry.h"
#include "..\emanagers.h"
e2d::EListenerPhysics::EListenerPhysics()
: EListener()
, m_Callback(nullptr)
{
}
e2d::EListenerPhysics::EListenerPhysics(const EString & name)
: EListener(name)
, m_Callback(nullptr)
{
}
e2d::EListenerPhysics::EListenerPhysics(const PhysLsnrCallback & callback)
: EListener()
, m_Callback(callback)
{
}
e2d::EListenerPhysics::EListenerPhysics(const EString & name, const PhysLsnrCallback & callback)
: EListener(name)
, m_Callback(callback)
{
}
void e2d::EListenerPhysics::_callOn()
{
if (m_Callback)
{
m_Callback();
}
}
void e2d::EListenerPhysics::setCallback(const PhysLsnrCallback & callback)
{
m_Callback = callback;
}
void e2d::EListenerPhysics::bindWith(EScene * pParentScene)
{
WARN_IF(m_pParentNode != nullptr, "A listener cannot bind with two object.");
if (pParentScene)
{
EPhysicsManager::bindListener(this, pParentScene);
}
}
void e2d::EListenerPhysics::bindWith(ENode * pParentNode)
{
WARN_IF(m_pParentNode != nullptr, "A listener cannot bind with two object.");
if (pParentNode != nullptr)
{
EPhysicsManager::bindListener(this, pParentNode);
}
}

View File

@ -1,39 +0,0 @@
#include "..\elisteners.h"
#include "..\egeometry.h"
e2d::EListenerPhysicsCollision::EListenerPhysicsCollision()
: EListenerPhysics()
, m_Callback(nullptr)
{
}
e2d::EListenerPhysicsCollision::EListenerPhysicsCollision(const EString & name)
: EListenerPhysics(name)
, m_Callback(nullptr)
{
}
e2d::EListenerPhysicsCollision::EListenerPhysicsCollision(const ClsLsnrCallback & callback)
: EListenerPhysics()
, m_Callback(callback)
{
}
e2d::EListenerPhysicsCollision::EListenerPhysicsCollision(const EString & name, const ClsLsnrCallback & callback)
: EListenerPhysics(name)
, m_Callback(callback)
{
}
void e2d::EListenerPhysicsCollision::_callOn()
{
if (EPhysicsEvent::getMsg() == EPhysicsEvent::OVERLAP ||
EPhysicsEvent::getMsg() == EPhysicsEvent::CONTAINS ||
EPhysicsEvent::getMsg() == EPhysicsEvent::IS_CONTAINED)
{
if (m_Callback)
{
m_Callback();
}
}
}

View File

@ -20,16 +20,16 @@ void e2d::EActionManager::resumeAllActionsBindedWith(ENode * pTargetNode)
{ {
if (pTargetNode) if (pTargetNode)
{ {
for (auto action = s_vActions.begin(); action != s_vActions.end(); action++) for (auto action : s_vActions)
{ {
if ((*action)->getTarget() == pTargetNode) if (action->getTarget() == pTargetNode)
{ {
(*action)->start(); action->start();
} }
} }
for (auto child = pTargetNode->getChildren().begin(); child != pTargetNode->getChildren().end(); child++) for (auto child : pTargetNode->getChildren())
{ {
EActionManager::resumeAllActionsBindedWith((*child)); EActionManager::resumeAllActionsBindedWith(child);
} }
} }
} }
@ -38,16 +38,16 @@ void e2d::EActionManager::pauseAllActionsBindedWith(ENode * pTargetNode)
{ {
if (pTargetNode) if (pTargetNode)
{ {
for (auto action = s_vActions.begin(); action != s_vActions.end(); action++) for (auto action : s_vActions)
{ {
if ((*action)->getTarget() == pTargetNode) if (action->getTarget() == pTargetNode)
{ {
(*action)->pause(); action->pause();
} }
} }
for (auto child = pTargetNode->getChildren().begin(); child != pTargetNode->getChildren().end(); child++) for (auto child : pTargetNode->getChildren())
{ {
EActionManager::pauseAllActionsBindedWith((*child)); EActionManager::pauseAllActionsBindedWith(child);
} }
} }
} }
@ -56,16 +56,16 @@ void e2d::EActionManager::stopAllActionsBindedWith(ENode * pTargetNode)
{ {
if (pTargetNode) if (pTargetNode)
{ {
for (auto action = s_vActions.begin(); action != s_vActions.end(); action++) for (auto action : s_vActions)
{ {
if ((*action)->getTarget() == pTargetNode) if (action->getTarget() == pTargetNode)
{ {
(*action)->stop(); action->stop();
} }
} }
for (auto child = pTargetNode->getChildren().begin(); child != pTargetNode->getChildren().end(); child++) for (auto child : pTargetNode->getChildren())
{ {
EActionManager::stopAllActionsBindedWith((*child)); EActionManager::stopAllActionsBindedWith(child);
} }
} }
} }
@ -92,33 +92,33 @@ void e2d::EActionManager::__clearAllActionsBindedWith(ENode * pTargetNode)
void e2d::EActionManager::resumeAllActions() void e2d::EActionManager::resumeAllActions()
{ {
for (auto child = ESceneManager::getCurrentScene()->getChildren().begin(); child != ESceneManager::getCurrentScene()->getChildren().end(); child++) for (auto child : ESceneManager::getCurrentScene()->getRoot()->getChildren())
{ {
EActionManager::resumeAllActionsBindedWith((*child)); EActionManager::resumeAllActionsBindedWith(child);
} }
} }
void e2d::EActionManager::pauseAllActions() void e2d::EActionManager::pauseAllActions()
{ {
for (auto child = ESceneManager::getCurrentScene()->getChildren().begin(); child != ESceneManager::getCurrentScene()->getChildren().end(); child++) for (auto child : ESceneManager::getCurrentScene()->getRoot()->getChildren())
{ {
EActionManager::pauseAllActionsBindedWith((*child)); EActionManager::pauseAllActionsBindedWith(child);
} }
} }
void e2d::EActionManager::stopAllActions() void e2d::EActionManager::stopAllActions()
{ {
for (auto child = ESceneManager::getCurrentScene()->getChildren().begin(); child != ESceneManager::getCurrentScene()->getChildren().end(); child++) for (auto child : ESceneManager::getCurrentScene()->getRoot()->getChildren())
{ {
EActionManager::stopAllActionsBindedWith((*child)); EActionManager::stopAllActionsBindedWith(child);
} }
} }
void e2d::EActionManager::__resetAllActions() void e2d::EActionManager::__resetAllActions()
{ {
for (auto action = s_vActions.begin(); action != s_vActions.end(); action++) for (auto action : s_vActions)
{ {
(*action)->_resetTime(); action->_resetTime();
} }
} }

View File

@ -15,29 +15,27 @@ static MusicList& getMusicList()
} }
e2d::EMusic * e2d::EMusicManager::add(const EString & strFilePath) bool e2d::EMusicManager::add(const EString & strFilePath)
{ {
EMusic * pPlayer = get(strFilePath); EMusic * pPlayer = get(strFilePath);
if (pPlayer) if (pPlayer)
{ {
return pPlayer; return true;
} }
else else
{ {
UINT nRet = strFilePath.hash(); UINT nRet = strFilePath.hash();
pPlayer = new EMusic();
getMusicList().insert(MusicPair(nRet, new EMusic()));
pPlayer = getMusicList()[nRet];
if (pPlayer->_open(strFilePath)) if (pPlayer->_open(strFilePath))
{ {
return pPlayer; getMusicList().insert(MusicPair(nRet, pPlayer));
return true;
} }
else else
{ {
delete pPlayer; delete pPlayer;
getMusicList().erase(nRet); return false;
return nullptr;
} }
} }
} }
@ -57,25 +55,25 @@ e2d::EMusic * e2d::EMusicManager::get(const EString & strFilePath)
void e2d::EMusicManager::pauseAllMusics() void e2d::EMusicManager::pauseAllMusics()
{ {
for (auto iter = getMusicList().begin(); iter != getMusicList().end(); iter++) for (auto iter : getMusicList())
{ {
(*iter).second->pause(); iter.second->pause();
} }
} }
void e2d::EMusicManager::resumeAllMusics() void e2d::EMusicManager::resumeAllMusics()
{ {
for (auto iter = getMusicList().begin(); iter != getMusicList().end(); iter++) for (auto iter : getMusicList())
{ {
(*iter).second->resume(); iter.second->resume();
} }
} }
void e2d::EMusicManager::stopAllMusics() void e2d::EMusicManager::stopAllMusics()
{ {
for (auto iter = getMusicList().begin(); iter != getMusicList().end(); iter++) for (auto iter : getMusicList())
{ {
(*iter).second->stop(); iter.second->stop();
} }
} }
@ -111,10 +109,10 @@ bool e2d::EMusicManager::__init()
void e2d::EMusicManager::__uninit() void e2d::EMusicManager::__uninit()
{ {
for (auto iter = getMusicList().begin(); iter != getMusicList().end(); iter++) for (auto iter : getMusicList())
{ {
(*iter).second->_close(); iter.second->_close();
(*iter).second->release(); delete iter.second;
} }
getMusicList().clear(); getMusicList().clear();

View File

@ -1,225 +0,0 @@
#include "..\emanagers.h"
#include "..\enodes.h"
#include "..\elisteners.h"
#include "..\egeometry.h"
// 监听器集合
std::vector<e2d::EListenerPhysics*> s_vListeners;
// 形状集合
std::vector<e2d::EGeometry*> s_vGeometries;
void e2d::EPhysicsManager::PhysicsGeometryProc(EGeometry * pActiveGeometry)
{
if (s_vListeners.empty() || s_vGeometries.empty() || EGame::isPaused())
return;
// pActiveGeometry 为主动方
EPhysicsEvent::s_pActiveGeometry = pActiveGeometry;
// 判断变化后的状态
for (UINT i = 0; i < s_vGeometries.size(); i++)
{
auto pPassiveGeometry = s_vGeometries[i];
// 不与其他场景的物体判断
if (!pPassiveGeometry->getParentNode() ||
(pPassiveGeometry->getParentNode()->getParentScene() != ESceneManager::getCurrentScene()))
continue;
if (pActiveGeometry != pPassiveGeometry)
{
// 判断两物体是否是相互冲突的物体
if (pActiveGeometry->m_nCollisionBitmask & pPassiveGeometry->m_nCategoryBitmask)
{
// pPassiveGeometry 为被动方
EPhysicsEvent::s_pPassiveGeometry = pPassiveGeometry;
// 获取两方的关系
EPhysicsEvent::s_nRelation = pActiveGeometry->_intersectWith(pPassiveGeometry);
// 如果关系不为未知或无交集,响应监听器
if (EPhysicsEvent::s_nRelation != EPhysicsEvent::UNKNOWN &&
EPhysicsEvent::s_nRelation != EPhysicsEvent::DISJOINT)
{
// 执行监听器
PhysicsListenerProc();
}
}
}
}
}
void e2d::EPhysicsManager::PhysicsListenerProc()
{
// 执行鼠标消息监听函数
size_t i = s_vListeners.size();
do
{
auto listener = s_vListeners[--i];
if (listener->_isReady())
{
listener->_callOn();
if (listener->m_bSwallow)
break;
}
} while (i != 0);
}
void e2d::EPhysicsManager::bindListener(EListenerPhysics * listener, EScene * pParentScene)
{
EPhysicsManager::bindListener(listener, pParentScene->getRoot());
}
void e2d::EPhysicsManager::bindListener(EListenerPhysics * listener, ENode * pParentNode)
{
WARN_IF(listener == nullptr, "EListenerPhysics NULL pointer exception!");
WARN_IF(pParentNode == nullptr, "EListenerPhysics add to a NULL ENode pointer!");
if (listener && pParentNode)
{
ASSERT(
!listener->m_pParentNode,
"The listener is already binded, it cannot bind again!"
);
listener->retain();
listener->start();
listener->m_pParentNode = pParentNode;
s_vListeners.push_back(listener);
}
}
void e2d::EPhysicsManager::_addGeometry(EGeometry * geometry)
{
if (geometry)
{
geometry->retain();
s_vGeometries.push_back(geometry);
}
}
void e2d::EPhysicsManager::_delGeometry(EGeometry * geometry)
{
if (geometry)
{
for (UINT i = 0; i < s_vGeometries.size(); i++)
{
if (s_vGeometries[i] == geometry)
{
SafeRelease(&geometry);
s_vGeometries.erase(s_vGeometries.begin() + i);
return;
}
}
}
}
void e2d::EPhysicsManager::startListeners(const EString & name)
{
for (auto listener = s_vListeners.begin(); listener != s_vListeners.end(); listener++)
{
if ((*listener)->getName() == name)
{
(*listener)->start();
}
}
}
void e2d::EPhysicsManager::stopListeners(const EString & name)
{
for (auto listener = s_vListeners.begin(); listener != s_vListeners.end(); listener++)
{
if ((*listener)->getName() == name)
{
(*listener)->stop();
}
}
}
void e2d::EPhysicsManager::delListeners(const EString & name)
{
std::vector<EListenerPhysics*>::iterator iter;
for (iter = s_vListeners.begin(); iter != s_vListeners.end();)
{
if ((*iter)->getName() == name)
{
SafeRelease(&(*iter));
iter = s_vListeners.erase(iter);
}
else
{
iter++;
}
}
}
void e2d::EPhysicsManager::startAllListenersBindedWith(EScene * pParentScene)
{
EPhysicsManager::startAllListenersBindedWith(pParentScene->getRoot());
}
void e2d::EPhysicsManager::stopAllListenersBindedWith(EScene * pParentScene)
{
EPhysicsManager::stopAllListenersBindedWith(pParentScene->getRoot());
}
void e2d::EPhysicsManager::startAllListenersBindedWith(ENode * pParentNode)
{
for (auto listener = s_vListeners.begin(); listener != s_vListeners.end(); listener++)
{
if ((*listener)->getParentNode() == pParentNode)
{
(*listener)->start();
}
}
for (auto child = pParentNode->getChildren().begin(); child != pParentNode->getChildren().end(); child++)
{
EPhysicsManager::startAllListenersBindedWith((*child));
}
}
void e2d::EPhysicsManager::stopAllListenersBindedWith(ENode * pParentNode)
{
for (auto listener = s_vListeners.begin(); listener != s_vListeners.end(); listener++)
{
if ((*listener)->getParentNode() == pParentNode)
{
(*listener)->stop();
}
}
for (auto child = pParentNode->getChildren().begin(); child != pParentNode->getChildren().end(); child++)
{
EPhysicsManager::stopAllListenersBindedWith((*child));
}
}
void e2d::EPhysicsManager::startAllListeners()
{
EPhysicsManager::startAllListenersBindedWith(ESceneManager::getCurrentScene());
}
void e2d::EPhysicsManager::stopAllListeners()
{
EPhysicsManager::stopAllListenersBindedWith(ESceneManager::getCurrentScene());
}
void e2d::EPhysicsManager::_clearManager()
{
s_vListeners.clear();
}
void e2d::EPhysicsManager::_clearAllListenersBindedWith(ENode * pParentNode)
{
for (UINT i = 0; i < s_vListeners.size();)
{
auto listener = s_vListeners[i];
if (listener->getParentNode() == pParentNode)
{
SafeRelease(&listener);
s_vListeners.erase(s_vListeners.begin() + i);
}
else
{
i++;
}
}
}

View File

@ -79,21 +79,40 @@ e2d::EScene * e2d::ESceneManager::getCurrentScene()
void e2d::ESceneManager::__update() void e2d::ESceneManager::__update()
{ {
// 更新场景内容
if (s_pCurrentScene)
{
s_pCurrentScene->_update();
}
// 正在切换场景时,执行场景切换动画 // 正在切换场景时,执行场景切换动画
if (s_pTransition) if (s_pTransition)
{ {
// 更新场景内容
if (s_pNextScene)
{
s_pNextScene->_update();
}
// 更新场景动画
s_pTransition->_update(); s_pTransition->_update();
if (s_pTransition->isEnding()) if (s_pTransition->isEnding())
{ {
s_pTransition->release(); s_pTransition->release();
s_pTransition = nullptr; s_pTransition = nullptr;
} }
else
{
return; return;
} }
}
// 下一场景指针不为空时,切换场景 // 下一场景指针不为空时,切换场景
if (s_pNextScene) if (s_pNextScene)
{ {
// 执行当前场景的 onExit 函数
s_pCurrentScene->onExit();
// 若要保存当前场景,把它放入栈中 // 若要保存当前场景,把它放入栈中
if (s_pCurrentScene->m_bWillSave) if (s_pCurrentScene->m_bWillSave)
{ {
@ -104,21 +123,12 @@ void e2d::ESceneManager::__update()
SafeRelease(&s_pCurrentScene); SafeRelease(&s_pCurrentScene);
} }
// 执行当前场景的 onExit 函数
s_pCurrentScene->onExit();
// 执行下一场景的 onEnter 函数 // 执行下一场景的 onEnter 函数
s_pNextScene->onEnter(); s_pNextScene->onEnter();
s_pCurrentScene = s_pNextScene; // 切换场景 s_pCurrentScene = s_pNextScene; // 切换场景
s_pNextScene = nullptr; // 下一场景置空 s_pNextScene = nullptr; // 下一场景置空
} }
// 断言当前场景非空
ASSERT(s_pCurrentScene != nullptr, "Current scene NULL pointer exception.");
// 更新场景内容
s_pCurrentScene->_update();
} }
void e2d::ESceneManager::__render() void e2d::ESceneManager::__render()

View File

@ -0,0 +1,67 @@
#include "..\emanagers.h"
#include "..\enodes.h"
#include "..\eshape.h"
// 形状集合
std::vector<e2d::EShape*> s_vShapes;
void e2d::EShapeManager::__updateShape(e2d::EShape * pActiveShape)
{
ENode* pActiveNode = pActiveShape->m_pParentNode;
if (pActiveNode)
{
// 获取节点所在场景
EScene* pCurrentScene = pActiveNode->getParentScene();
// 判断与其他形状的交集情况
for (auto pPassiveShape : s_vShapes)
{
// 判断两物体是否是相互冲突的物体
if (pActiveShape->m_nCollisionBitmask & pPassiveShape->m_nCategoryBitmask)
{
// 获取被碰撞节点
ENode* pPassiveNode = pPassiveShape->m_pParentNode;
// 判断两节点是否处于同一场景中
if (pPassiveNode &&
pPassiveNode != pActiveNode &&
pPassiveNode->getParentScene() == pCurrentScene)
{
// 判断两形状交集情况
int relation = pActiveShape->getRelationWith(pPassiveShape);
// 忽略 UNKNOWN 和 DISJOINT 情况
if (relation != ERelation::UNKNOWN && relation != ERelation::DISJOINT)
{
pActiveNode->onCollide(pPassiveNode, relation);
pPassiveNode->onCollide(pActiveNode, pPassiveShape->getRelationWith(pActiveShape));
pCurrentScene->onCollide(pActiveNode, pPassiveNode);
}
}
}
}
}
}
void e2d::EShapeManager::__addShape(EShape * pShape)
{
if (pShape)
{
pShape->retain();
s_vShapes.push_back(pShape);
}
}
void e2d::EShapeManager::__delShape(EShape * pShape)
{
if (pShape)
{
for (size_t i = 0; i < s_vShapes.size(); i++)
{
if (s_vShapes[i] == pShape)
{
SafeRelease(&pShape);
s_vShapes.erase(s_vShapes.begin() + i);
return;
}
}
}
}

View File

@ -46,22 +46,22 @@ void e2d::ETimerManager::bindTimer(ETimer * timer, ENode * pParentNode)
void e2d::ETimerManager::startTimers(const EString & name) void e2d::ETimerManager::startTimers(const EString & name)
{ {
for (auto timer = s_vTimers.begin(); timer != s_vTimers.end(); timer++) for (auto timer : s_vTimers)
{ {
if ((*timer)->getName() == name) if (timer->getName() == name)
{ {
(*timer)->start(); timer->start();
} }
} }
} }
void e2d::ETimerManager::stopTimers(const EString & name) void e2d::ETimerManager::stopTimers(const EString & name)
{ {
for (auto timer = s_vTimers.begin(); timer != s_vTimers.end(); timer++) for (auto timer : s_vTimers)
{ {
if ((*timer)->getName() == name) if (timer->getName() == name)
{ {
(*timer)->stop(); timer->stop();
} }
} }
} }
@ -95,11 +95,11 @@ void e2d::ETimerManager::stopAllTimersBindedWith(EScene * pParentScene)
void e2d::ETimerManager::startAllTimersBindedWith(ENode * pParentNode) void e2d::ETimerManager::startAllTimersBindedWith(ENode * pParentNode)
{ {
for (auto timer = s_vTimers.begin(); timer != s_vTimers.end(); timer++) for (auto timer : s_vTimers)
{ {
if ((*timer)->getParentNode() == pParentNode) if (timer->getParentNode() == pParentNode)
{ {
(*timer)->start(); timer->start();
} }
} }
for (auto child = pParentNode->getChildren().begin(); child != pParentNode->getChildren().end(); child++) for (auto child = pParentNode->getChildren().begin(); child != pParentNode->getChildren().end(); child++)
@ -110,16 +110,16 @@ void e2d::ETimerManager::startAllTimersBindedWith(ENode * pParentNode)
void e2d::ETimerManager::stopAllTimersBindedWith(ENode * pParentNode) void e2d::ETimerManager::stopAllTimersBindedWith(ENode * pParentNode)
{ {
for (auto timer = s_vTimers.begin(); timer != s_vTimers.end(); timer++) for (auto timer : s_vTimers)
{ {
if ((*timer)->getParentNode() == pParentNode) if (timer->getParentNode() == pParentNode)
{ {
(*timer)->stop(); timer->stop();
} }
} }
for (auto child = pParentNode->getChildren().begin(); child != pParentNode->getChildren().end(); child++) for (auto child : pParentNode->getChildren())
{ {
ETimerManager::stopAllTimersBindedWith((*child)); ETimerManager::stopAllTimersBindedWith(child);
} }
} }
@ -142,9 +142,9 @@ void e2d::ETimerManager::__clearAllTimersBindedWith(ENode * pParentNode)
void e2d::ETimerManager::__resetAllTimers() void e2d::ETimerManager::__resetAllTimers()
{ {
for (auto timer = s_vTimers.begin(); timer != s_vTimers.end(); timer++) for (auto timer : s_vTimers)
{ {
(*timer)->m_fLast = ETime::getTotalTime(); timer->m_fLast = ETime::getTotalTime();
} }
} }

View File

@ -1,6 +1,4 @@
#include "..\enodes.h" #include "..\enodes.h"
#include "..\elisteners.h"
#include "..\emanagers.h"
e2d::EButton::EButton() e2d::EButton::EButton()
: m_Callback((const BtnClkCallback &)nullptr) : m_Callback((const BtnClkCallback &)nullptr)

View File

@ -1,6 +1,4 @@
#include "..\enodes.h" #include "..\enodes.h"
#include "..\elisteners.h"
#include "..\emanagers.h"
e2d::EButtonToggle::EButtonToggle() e2d::EButtonToggle::EButtonToggle()
: EButton() : EButton()

View File

@ -1,5 +1,4 @@
#include "..\enodes.h" #include "..\enodes.h"
#include "..\elisteners.h"
e2d::EMenu::EMenu() e2d::EMenu::EMenu()
: m_bEnable(true) : m_bEnable(true)
@ -35,9 +34,9 @@ void e2d::EMenu::setEnable(bool enable)
{ {
m_bEnable = enable; m_bEnable = enable;
for (auto button = m_vButtons.begin(); button != m_vButtons.end(); button++) for (auto button : m_vButtons)
{ {
(*button)->setEnable(enable); button->setEnable(enable);
} }
} }
} }

View File

@ -2,7 +2,7 @@
#include "..\emanagers.h" #include "..\emanagers.h"
#include "..\etools.h" #include "..\etools.h"
#include "..\eactions.h" #include "..\eactions.h"
#include "..\egeometry.h" #include "..\eshape.h"
#include <algorithm> #include <algorithm>
// 默认中心点位置 // 默认中心点位置
@ -24,59 +24,29 @@ e2d::ENode::ENode()
, m_MatriFinal(D2D1::Matrix3x2F::Identity()) , m_MatriFinal(D2D1::Matrix3x2F::Identity())
, m_bVisiable(true) , m_bVisiable(true)
, m_bDisplayedInScene(false) , m_bDisplayedInScene(false)
, m_pGeometry(nullptr) , m_pShape(nullptr)
, m_pParent(nullptr) , m_pParent(nullptr)
, m_pParentScene(nullptr) , m_pParentScene(nullptr)
, m_nHashName(0) , m_nHashName(0)
, m_bSortChildrenNeeded(false) , m_bSortChildrenNeeded(false)
, m_bTransformNeeded(false) , m_bTransformNeeded(false)
, m_bAutoUpdate(true)
{ {
} }
e2d::ENode::ENode(const EString & name)
: m_nOrder(0)
, m_fScaleX(1.0f)
, m_fScaleY(1.0f)
, m_fRotation(0)
, m_fSkewAngleX(0)
, m_fSkewAngleY(0)
, m_fDisplayOpacity(1.0f)
, m_fRealOpacity(1.0f)
, m_fPivotX(s_fDefaultPiovtX)
, m_fPivotY(s_fDefaultPiovtY)
, m_MatriInitial(D2D1::Matrix3x2F::Identity())
, m_MatriFinal(D2D1::Matrix3x2F::Identity())
, m_bVisiable(true)
, m_bDisplayedInScene(false)
, m_pGeometry(nullptr)
, m_pParent(nullptr)
, m_pParentScene(nullptr)
, m_nHashName(0)
, m_bSortChildrenNeeded(false)
, m_bTransformNeeded(false)
{
this->setName(name);
}
e2d::ENode::~ENode() e2d::ENode::~ENode()
{ {
ETimerManager::__clearAllTimersBindedWith(this); ETimerManager::__clearAllTimersBindedWith(this);
EActionManager::__clearAllActionsBindedWith(this); EActionManager::__clearAllActionsBindedWith(this);
EPhysicsManager::_clearAllListenersBindedWith(this); EShapeManager::__delShape(m_pShape);
EPhysicsManager::_delGeometry(m_pGeometry); for (auto child : m_vChildren)
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++)
{ {
SafeRelease(&(*child)); SafeRelease(&child);
} }
} }
void e2d::ENode::_update() void e2d::ENode::_update()
{ {
if (!m_bVisiable)
{
return;
}
if (m_bTransformNeeded) if (m_bTransformNeeded)
{ {
_updateTransform(this); _updateTransform(this);
@ -84,8 +54,21 @@ void e2d::ENode::_update()
if (!m_vChildren.empty()) if (!m_vChildren.empty())
{ {
this->_sortChildren(); // ×Ó½ÚµãÅÅÐò
if (m_bSortChildrenNeeded)
{
std::sort(
std::begin(m_vChildren),
std::end(m_vChildren),
[](ENode * n1, ENode * n2) {
return n1->getOrder() < n2->getOrder();
}
);
m_bSortChildrenNeeded = false;
}
// ±éÀú×Ó½Úµã
size_t size = m_vChildren.size(); size_t size = m_vChildren.size();
size_t i; size_t i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
@ -103,7 +86,10 @@ void e2d::ENode::_update()
} }
// 执行 onUpdate 函数 // 执行 onUpdate 函数
if (m_bAutoUpdate)
{
this->onUpdate(); this->onUpdate();
}
// 访问剩余节点 // 访问剩余节点
for (; i < size; i++) for (; i < size; i++)
@ -159,31 +145,31 @@ void e2d::ENode::_render()
} }
} }
void e2d::ENode::_drawGeometry() void e2d::ENode::_drawShape()
{ {
// 绘制自身的几何形状 // 绘制自身的几何形状
if (m_pGeometry && m_pGeometry->m_bIsVisiable) if (m_pShape && m_pShape->m_bIsVisiable)
{ {
m_pGeometry->_render(); m_pShape->_render();
} }
// 绘制所有子节点的几何形状 // 绘制所有子节点的几何形状
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++) for (auto child : m_vChildren)
{ {
(*child)->_drawGeometry(); child->_drawShape();
} }
} }
void e2d::ENode::_onEnter() void e2d::ENode::_onEnter()
{ {
if (!this->m_bDisplayedInScene && this->isVisiable()) if (!this->m_bDisplayedInScene)
{ {
this->m_bDisplayedInScene = true; this->m_bDisplayedInScene = true;
this->onEnter(); this->onEnter();
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++) for (auto child : m_vChildren)
{ {
(*child)->_onEnter(); child->_onEnter();
} }
} }
} }
@ -195,30 +181,13 @@ void e2d::ENode::_onExit()
this->m_bDisplayedInScene = false; this->m_bDisplayedInScene = false;
this->onExit(); this->onExit();
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++) for (auto child : m_vChildren)
{ {
(*child)->_onExit(); child->_onExit();
} }
} }
} }
void e2d::ENode::_sortChildren()
{
if (m_bSortChildrenNeeded)
{
// ×Ó½ÚµãÅÅÐò
std::sort(
std::begin(m_vChildren),
std::end(m_vChildren),
[](ENode * n1, ENode * n2) {
return n1->getOrder() < n2->getOrder();
}
);
m_bSortChildrenNeeded = false;
}
}
void e2d::ENode::_updateTransform() void e2d::ENode::_updateTransform()
{ {
// 计算中心点坐标 // 计算中心点坐标
@ -253,9 +222,9 @@ void e2d::ENode::_updateTransform()
void e2d::ENode::_updateChildrenTransform() void e2d::ENode::_updateChildrenTransform()
{ {
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++) for (auto child : m_vChildren)
{ {
_updateTransform((*child)); _updateTransform(child);
} }
} }
@ -264,9 +233,9 @@ void e2d::ENode::_updateTransform(ENode * node)
// 计算自身的转换矩阵 // 计算自身的转换矩阵
node->_updateTransform(); node->_updateTransform();
// 绑定于自身的形状也进行相应转换 // 绑定于自身的形状也进行相应转换
if (node->m_pGeometry) if (node->m_pShape)
{ {
node->m_pGeometry->_transform(); node->m_pShape->_transform();
} }
// 遍历子节点下的所有节点 // 遍历子节点下的所有节点
node->_updateChildrenTransform(); node->_updateChildrenTransform();
@ -276,9 +245,9 @@ void e2d::ENode::_updateTransform(ENode * node)
void e2d::ENode::_updateChildrenOpacity() void e2d::ENode::_updateChildrenOpacity()
{ {
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++) for (auto child : m_vChildren)
{ {
_updateOpacity((*child)); _updateOpacity(child);
} }
} }
@ -386,6 +355,11 @@ float e2d::ENode::getOpacity() const
return m_fRealOpacity; return m_fRealOpacity;
} }
e2d::EShape * e2d::ENode::getShape() const
{
return m_pShape;
}
int e2d::ENode::getOrder() const int e2d::ENode::getOrder() const
{ {
return m_nOrder; return m_nOrder;
@ -441,21 +415,6 @@ void e2d::ENode::movePos(const EVector2 & v)
this->movePos(v.x, v.y); this->movePos(v.x, v.y);
} }
void e2d::ENode::_setWidth(float width)
{
this->_setSize(width, m_Size.height);
}
void e2d::ENode::_setHeight(float height)
{
this->_setSize(m_Size.width, height);
}
void e2d::ENode::_setSize(const ESize & size)
{
this->_setSize(size.width, size.height);
}
void e2d::ENode::_setSize(float width, float height) void e2d::ENode::_setSize(float width, float height)
{ {
if (m_Size.width == width && m_Size.height == height) if (m_Size.width == width && m_Size.height == height)
@ -550,32 +509,33 @@ void e2d::ENode::setPivot(float pivotX, float pivotY)
m_bTransformNeeded = true; m_bTransformNeeded = true;
} }
void e2d::ENode::setGeometry(EGeometry * geometry) void e2d::ENode::setShape(EShape * pShape)
{ {
// 删除旧的形状 // 删除旧的形状
EPhysicsManager::_delGeometry(m_pGeometry); EShapeManager::__delShape(m_pShape);
// 添加新的形状 // 添加新的形状
EPhysicsManager::_addGeometry(geometry); EShapeManager::__addShape(pShape);
if (geometry) if (pShape)
{ {
// 双向绑定 // 双向绑定
this->m_pGeometry = geometry; this->m_pShape = pShape;
geometry->m_pParentNode = this; pShape->m_pParentNode = this;
} }
else else
{ {
this->m_pGeometry = nullptr; this->m_pShape = nullptr;
} }
} }
void e2d::ENode::addChild(ENode * child, int order /* = 0 */) void e2d::ENode::addChild(ENode * child, int order /* = 0 */)
{ {
WARN_IF(child == nullptr, "ENode::addChild NULL pointer exception."); WARN_IF(child == nullptr, "ENode::addChild NULL pointer exception.");
ASSERT(child->m_pParent == nullptr, "ENode already added. It can't be added again!");
if (child) if (child)
{ {
ASSERT(child->m_pParent == nullptr, "ENode already added. It can't be added again!");
for (ENode * parent = this; parent != nullptr; parent = parent->getParent()) for (ENode * parent = this; parent != nullptr; parent = parent->getParent())
{ {
ASSERT(child != parent, "A ENode cannot be the child of his own children!"); ASSERT(child != parent, "A ENode cannot be the child of his own children!");
@ -623,9 +583,9 @@ std::vector<e2d::ENode*>& e2d::ENode::getChildren()
return m_vChildren; return m_vChildren;
} }
size_t e2d::ENode::getChildrenCount() const int e2d::ENode::getChildrenCount() const
{ {
return m_vChildren.size(); return static_cast<int>(m_vChildren.size());
} }
e2d::ENode * e2d::ENode::getChild(const EString & name) e2d::ENode * e2d::ENode::getChild(const EString & name)
@ -634,15 +594,30 @@ e2d::ENode * e2d::ENode::getChild(const EString & name)
unsigned int hash = name.hash(); unsigned int hash = name.hash();
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++) for (auto child : m_vChildren)
{ {
// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度 // 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
if ((*child)->m_nHashName == hash && (*child)->m_sName == name) if (child->m_nHashName == hash && child->m_sName == name)
return (*child); return child;
} }
return nullptr; return nullptr;
} }
std::vector<e2d::ENode*> e2d::ENode::getChildren(const EString & name)
{
std::vector<ENode*> vChildren;
WARN_IF(name.isEmpty(), "Invalid ENode name.");
unsigned int hash = name.hash();
for (auto child : m_vChildren)
if (child->m_nHashName == hash && child->m_sName == name)
vChildren.push_back(child);
return std::move(vChildren);
}
void e2d::ENode::removeFromParent() void e2d::ENode::removeFromParent()
{ {
if (m_pParent) if (m_pParent)
@ -653,7 +628,7 @@ void e2d::ENode::removeFromParent()
bool e2d::ENode::removeChild(ENode * child) bool e2d::ENode::removeChild(ENode * child)
{ {
WARN_IF(child == nullptr, "ENode::removeChild NULL pointer exception."); WARN_IF(child == nullptr, "ENode::removeChildren NULL pointer exception.");
if (m_vChildren.empty()) if (m_vChildren.empty())
{ {
@ -669,11 +644,16 @@ bool e2d::ENode::removeChild(ENode * child)
{ {
m_vChildren.erase(m_vChildren.begin() + i); m_vChildren.erase(m_vChildren.begin() + i);
child->m_pParent = nullptr; child->m_pParent = nullptr;
if (child->m_pParentScene) if (child->m_pParentScene)
{ {
child->_setParentScene(nullptr); child->_setParentScene(nullptr);
} }
if (child->m_bDisplayedInScene)
{
child->_onExit(); child->_onExit();
}
child->release(); child->release();
return true; return true;
} }
@ -682,7 +662,7 @@ bool e2d::ENode::removeChild(ENode * child)
return false; return false;
} }
void e2d::ENode::removeChild(const EString & childName) void e2d::ENode::removeChildren(const EString & childName)
{ {
WARN_IF(childName.isEmpty(), "Invalid ENode name."); WARN_IF(childName.isEmpty(), "Invalid ENode name.");
@ -706,9 +686,11 @@ void e2d::ENode::removeChild(const EString & childName)
{ {
child->_setParentScene(nullptr); child->_setParentScene(nullptr);
} }
if (child->m_bDisplayedInScene)
{
child->_onExit(); child->_onExit();
}
child->release(); child->release();
return;
} }
} }
} }
@ -716,10 +698,13 @@ void e2d::ENode::removeChild(const EString & childName)
void e2d::ENode::clearAllChildren() void e2d::ENode::clearAllChildren()
{ {
// 所有节点的引用计数减一 // 所有节点的引用计数减一
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++) for (auto child : m_vChildren)
{ {
(*child)->_onExit(); if (child->m_bDisplayedInScene)
(*child)->release(); {
child->_onExit();
}
child->release();
} }
// 清空储存节点的容器 // 清空储存节点的容器
m_vChildren.clear(); m_vChildren.clear();
@ -727,10 +712,14 @@ void e2d::ENode::clearAllChildren()
void e2d::ENode::runAction(EAction * action) void e2d::ENode::runAction(EAction * action)
{ {
ASSERT( WARN_IF(
(!action->getTarget()), action->getTarget() != nullptr,
"The action is already running, it cannot run again!" "The action is already running, The clone of the action will be created automatically!"
); );
if (action->getTarget())
{
action = action->clone();
}
action->setTarget(this); action->setTarget(this);
EActionManager::addAction(action); EActionManager::addAction(action);
} }
@ -778,13 +767,18 @@ bool e2d::ENode::isPointIn(EPoint point)
} }
else else
{ {
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++) for (auto child : m_vChildren)
if ((*child)->isPointIn(point)) if (child->isPointIn(point))
return true; return true;
} }
return false; return false;
} }
void e2d::ENode::setAutoUpdate(bool bAutoUpdate)
{
m_bAutoUpdate = bAutoUpdate;
}
void e2d::ENode::setDefaultPiovt(float defaultPiovtX, float defaultPiovtY) void e2d::ENode::setDefaultPiovt(float defaultPiovtX, float defaultPiovtY)
{ {
s_fDefaultPiovtX = min(max(defaultPiovtX, 0), 1); s_fDefaultPiovtX = min(max(defaultPiovtX, 0), 1);
@ -817,17 +811,13 @@ void e2d::ENode::stopAllActions()
void e2d::ENode::setVisiable(bool value) void e2d::ENode::setVisiable(bool value)
{ {
m_bVisiable = value; m_bVisiable = value;
if (m_bDisplayedInScene == false)
{
this->_onEnter();
}
} }
void e2d::ENode::setName(const EString & name) void e2d::ENode::setName(const EString & name)
{ {
WARN_IF(name.isEmpty(), "Invalid ENode name."); WARN_IF(name.isEmpty(), "Invalid ENode name.");
if (!name.isEmpty()) if (!name.isEmpty() && m_sName != name)
{ {
// 保存节点名 // 保存节点名
m_sName = name; m_sName = name;
@ -839,8 +829,8 @@ void e2d::ENode::setName(const EString & name)
void e2d::ENode::_setParentScene(EScene * scene) void e2d::ENode::_setParentScene(EScene * scene)
{ {
m_pParentScene = scene; m_pParentScene = scene;
for (auto child = m_vChildren.begin(); child != m_vChildren.end(); child++) for (auto child : m_vChildren)
{ {
(*child)->_setParentScene(scene); child->_setParentScene(scene);
} }
} }

View File

@ -2,62 +2,29 @@
e2d::ESprite::ESprite() e2d::ESprite::ESprite()
: m_fSourceClipX(0) : m_pImage(nullptr)
, m_fSourceClipY(0)
, m_pImage(nullptr)
{ {
} }
e2d::ESprite::ESprite(EImage * image) e2d::ESprite::ESprite(EImage * image)
: m_fSourceClipX(0) : m_pImage(nullptr)
, m_fSourceClipY(0)
, m_pImage(nullptr)
{ {
loadFrom(image); loadFrom(image);
} }
e2d::ESprite::ESprite(EKeyframe * spriteFrame)
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_pImage(nullptr)
{
loadFrom(spriteFrame);
}
e2d::ESprite::ESprite(LPCTSTR imageFileName) e2d::ESprite::ESprite(LPCTSTR imageFileName)
: m_fSourceClipX(0) : m_pImage(nullptr)
, m_fSourceClipY(0)
, m_pImage(nullptr)
{ {
loadFrom(imageFileName); loadFrom(imageFileName);
} }
e2d::ESprite::ESprite(LPCTSTR imageFileName, float x, float y, float width, float height) e2d::ESprite::ESprite(LPCTSTR imageFileName, float x, float y, float width, float height)
: m_fSourceClipX(0) : m_pImage(nullptr)
, m_fSourceClipY(0)
, m_pImage(nullptr)
{ {
loadFrom(imageFileName); loadFrom(imageFileName);
clip(x, y, width, height); clip(x, y, width, height);
} }
e2d::ESprite::ESprite(LPCTSTR resourceName, LPCTSTR resourceType)
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_pImage(nullptr)
{
loadFrom(resourceName, resourceType);
}
e2d::ESprite::ESprite(LPCTSTR resourceName, LPCTSTR resourceType, float x, float y, float width, float height)
: m_fSourceClipX(0)
, m_fSourceClipY(0)
, m_pImage(nullptr)
{
loadFrom(resourceName, resourceType);
clip(x, y, width, height);
}
e2d::ESprite::~ESprite() e2d::ESprite::~ESprite()
{ {
SafeRelease(&m_pImage); SafeRelease(&m_pImage);
@ -71,9 +38,7 @@ void e2d::ESprite::loadFrom(EImage * image)
m_pImage = image; m_pImage = image;
m_pImage->retain(); m_pImage->retain();
m_fSourceClipX = m_fSourceClipY = 0; ENode::_setSize(m_pImage->getWidth(), m_pImage->getHeight());
ENode::_setWidth(m_pImage->getSourceWidth());
ENode::_setHeight(m_pImage->getSourceHeight());
} }
} }
@ -82,49 +47,35 @@ void e2d::ESprite::loadFrom(LPCTSTR imageFileName)
loadFrom(new EImage(imageFileName)); loadFrom(new EImage(imageFileName));
} }
void e2d::ESprite::loadFrom(LPCTSTR resourceName, LPCTSTR resourceType)
{
loadFrom(new EImage(resourceName, resourceType));
}
void e2d::ESprite::loadFrom(EImage * image, float x, float y, float width, float height)
{
loadFrom(image);
clip(x, y, width, height);
}
void e2d::ESprite::loadFrom(EKeyframe * frame)
{
if (frame)
{
loadFrom(frame->m_pImage);
clip(frame->m_fSourceClipX, frame->m_fSourceClipY, frame->m_fSourceClipWidth, frame->m_fSourceClipHeight);
}
}
void e2d::ESprite::clip(float x, float y, float width, float height) void e2d::ESprite::clip(float x, float y, float width, float height)
{ {
m_fSourceClipX = min(max(x, 0), m_pImage->getSourceWidth()); m_pImage->clip(x, y, width, height);
m_fSourceClipY = min(max(y, 0), m_pImage->getSourceHeight()); ENode::_setSize(
ENode::_setWidth(min(max(width, 0), m_pImage->getSourceWidth() - m_fSourceClipX)); min(max(width, 0), m_pImage->getSourceWidth() - m_pImage->getClipX()),
ENode::_setHeight(min(max(height, 0), m_pImage->getSourceHeight() - m_fSourceClipY)); min(max(height, 0), m_pImage->getSourceHeight() - m_pImage->getClipY())
);
}
e2d::EImage * e2d::ESprite::getImage() const
{
return m_pImage;
} }
void e2d::ESprite::onRender() void e2d::ESprite::onRender()
{ {
if (m_pImage && m_pImage->_getBitmap()) if (m_pImage && m_pImage->getBitmap())
{ {
// Draw bitmap // äÖȾͼƬ
ERenderer::getRenderTarget()->DrawBitmap( ERenderer::getRenderTarget()->DrawBitmap(
m_pImage->_getBitmap(), m_pImage->getBitmap(),
D2D1::RectF(0, 0, getRealWidth(), getRealHeight()), D2D1::RectF(0, 0, getRealWidth(), getRealHeight()),
m_fDisplayOpacity, m_fDisplayOpacity,
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
D2D1::RectF( D2D1::RectF(
m_fSourceClipX, m_pImage->getClipX(),
m_fSourceClipY, m_pImage->getClipY(),
m_fSourceClipX + getRealWidth(), m_pImage->getClipX() + getRealWidth(),
m_fSourceClipY + getRealHeight() m_pImage->getClipY() + getRealHeight()
) )
); );
} }

View File

@ -120,7 +120,7 @@ void e2d::EText::_initTextLayout()
// 未设置字体或空字符串时,文本宽高为 0 // 未设置字体或空字符串时,文本宽高为 0
if (!m_pFont || m_sText.isEmpty()) if (!m_pFont || m_sText.isEmpty())
{ {
this->_setHeight(0); this->_setSize(0, 0);
m_fWordWrappingWidth = 0; m_fWordWrappingWidth = 0;
return; return;
} }

View File

@ -1,4 +1,4 @@
#include "..\egeometry.h" #include "..\eshape.h"
#include "..\enodes.h" #include "..\enodes.h"
e2d::ECircle::ECircle() e2d::ECircle::ECircle()

View File

@ -1,4 +1,4 @@
#include "..\egeometry.h" #include "..\eshape.h"
#include "..\enodes.h" #include "..\enodes.h"
e2d::EEllipse::EEllipse() e2d::EEllipse::EEllipse()

View File

@ -1,4 +1,4 @@
#include "..\egeometry.h" #include "..\eshape.h"
#include "..\enodes.h" #include "..\enodes.h"
e2d::ERectangle::ERectangle() e2d::ERectangle::ERectangle()

120
core/Shape/Shape.cpp Normal file
View File

@ -0,0 +1,120 @@
#include "..\eshape.h"
#include "..\emanagers.h"
#include "..\enodes.h"
e2d::EShape::EShape()
: m_nCategoryBitmask(0)
, m_nCollisionBitmask(0)
, m_bIsVisiable(true)
, m_nColor(EColor::RED)
, m_fOpacity(1)
, m_pParentNode(nullptr)
, m_pTransformedShape(nullptr)
, m_bEnable(true)
{
}
e2d::EShape::~EShape()
{
SafeReleaseInterface(&m_pTransformedShape);
}
e2d::ENode * e2d::EShape::getParentNode() const
{
return m_pParentNode;
}
UINT32 e2d::EShape::getCategoryBitmask() const
{
return m_nCategoryBitmask;
}
UINT32 e2d::EShape::getCollisionBitmask() const
{
return m_nCollisionBitmask;
}
void e2d::EShape::setCategoryBitmask(UINT32 mask)
{
m_nCategoryBitmask = mask;
}
void e2d::EShape::setCollisionBitmask(UINT32 mask)
{
m_nCollisionBitmask = mask;
}
void e2d::EShape::setEnable(bool bEnable)
{
m_bEnable = bEnable;
}
void e2d::EShape::setVisiable(bool bVisiable)
{
m_bIsVisiable = bVisiable;
}
void e2d::EShape::setColor(UINT32 color)
{
m_nColor = color;
}
void e2d::EShape::setOpacity(float opacity)
{
m_fOpacity = min(max(opacity, 0), 1);
}
void e2d::EShape::_render()
{
if (m_pTransformedShape && m_bEnable)
{
ID2D1SolidColorBrush * pBrush = ERenderer::getSolidColorBrush();
// 눼쉔뺌岬
ERenderer::getRenderTarget()->CreateSolidColorBrush(
D2D1::ColorF(
m_nColor,
m_fOpacity),
&pBrush
);
// 삥齡섯부近榴
ERenderer::getRenderTarget()->DrawGeometry(m_pTransformedShape, pBrush);
}
}
int e2d::EShape::getRelationWith(EShape * 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 0;
}
void e2d::EShape::_transform()
{
if (m_pParentNode && m_bEnable)
{
// 姦렴覩近榴
SafeReleaseInterface(&m_pTransformedShape);
// 몽앴만쌘듐瘻뻣섯부暠近
ERenderer::getID2D1Factory()->CreateTransformedGeometry(
_getD2dGeometry(),
m_pParentNode->m_MatriFinal,
&m_pTransformedShape
);
EShapeManager::__updateShape(this);
}
}

View File

@ -205,7 +205,7 @@ bool EMusic::isPlaying()
} }
} }
float e2d::EMusic::getVolume() const float EMusic::getVolume() const
{ {
float fVolume = 0.0f; float fVolume = 0.0f;
if (m_pSourceVoice) if (m_pSourceVoice)
@ -215,7 +215,7 @@ float e2d::EMusic::getVolume() const
return fVolume; return fVolume;
} }
bool e2d::EMusic::setVolume(float fVolume) bool EMusic::setVolume(float fVolume)
{ {
if (m_pSourceVoice) if (m_pSourceVoice)
{ {
@ -224,7 +224,7 @@ bool e2d::EMusic::setVolume(float fVolume)
return false; return false;
} }
float e2d::EMusic::getFrequencyRatio() const float EMusic::getFrequencyRatio() const
{ {
float fFrequencyRatio = 0.0f; float fFrequencyRatio = 0.0f;
if (m_pSourceVoice) if (m_pSourceVoice)
@ -234,7 +234,7 @@ float e2d::EMusic::getFrequencyRatio() const
return fFrequencyRatio; return fFrequencyRatio;
} }
bool e2d::EMusic::setFrequencyRatio(float fFrequencyRatio) bool EMusic::setFrequencyRatio(float fFrequencyRatio)
{ {
if (m_pSourceVoice) if (m_pSourceVoice)
{ {
@ -244,7 +244,7 @@ bool e2d::EMusic::setFrequencyRatio(float fFrequencyRatio)
return false; return false;
} }
IXAudio2SourceVoice * e2d::EMusic::getIXAudio2SourceVoice() const IXAudio2SourceVoice * EMusic::getIXAudio2SourceVoice() const
{ {
return m_pSourceVoice; return m_pSourceVoice;
} }

View File

@ -576,7 +576,7 @@ public:
// 添加关键帧 // 添加关键帧
void addKeyframe( void addKeyframe(
EKeyframe * frame /* 添加关键帧 */ EImage * frame /* 添加关键帧 */
); );
// 设置每一帧的时间间隔(秒) // 设置每一帧的时间间隔(秒)
@ -603,7 +603,7 @@ protected:
protected: protected:
float m_fInterval; float m_fInterval;
UINT m_nFrameIndex; UINT m_nFrameIndex;
std::vector<EKeyframe*> m_vFrames; std::vector<EImage*> m_vFrames;
}; };

View File

@ -1,5 +1,5 @@
/****************************************************** /******************************************************
* Easy2D Game Core * Easy2D Game Framework
* *
* Website: https://www.easy2d.cn * Website: https://www.easy2d.cn
* Source Code: https://github.com/Nomango/Easy2D * Source Code: https://github.com/Nomango/Easy2D
@ -12,8 +12,8 @@
#error 仅能在 C++ 环境下使用 Easy2D #error 仅能在 C++ 环境下使用 Easy2D
#endif #endif
#if _MSC_VER < 1600 #if _MSC_VER < 1700
#error Easy2D 不支持 Visual Studio 2010 以下版本 #error Easy2D 不支持 Visual Studio 2012 以下版本
#endif #endif
@ -22,11 +22,10 @@
#include "ebase.h" #include "ebase.h"
#include "emanagers.h" #include "emanagers.h"
#include "enodes.h" #include "enodes.h"
#include "elisteners.h"
#include "etools.h" #include "etools.h"
#include "eactions.h" #include "eactions.h"
#include "etransitions.h" #include "etransitions.h"
#include "egeometry.h" #include "eshape.h"
#if defined(DEBUG) || defined(_DEBUG) #if defined(DEBUG) || defined(_DEBUG)

View File

@ -86,6 +86,7 @@ struct ESize
} }
}; };
// 字符串 // 字符串
class EString class EString
{ {
@ -219,31 +220,6 @@ private:
}; };
// 二维向量
typedef EPoint EVector2;
// 定时器回调函数(参数为该定时器被调用的次数,从 0 开始)
typedef std::function<void(int)> TimerCallback;
// 按钮点击回调函数
typedef std::function<void()> BtnClkCallback;
// 物理世界消息监听器回调函数
typedef std::function<void()> PhysLsnrCallback;
// 碰撞消息监听器回调函数
typedef PhysLsnrCallback ClsLsnrCallback;
template<typename T>
inline void SafeDelete(T** p) { if (*p) { delete *p; *p = nullptr; } }
template<typename Obj>
inline void SafeRelease(Obj** p) { if (*p) { (*p)->release(); *p = nullptr; } }
template<class Interface>
inline void SafeReleaseInterface(Interface **pp) { if (*pp != nullptr) { (*pp)->Release(); (*pp) = nullptr; } }
// 颜色 // 颜色
class EColor class EColor
{ {
@ -418,13 +394,11 @@ public:
}; };
class EGeometry; // 形状交集关系
class ERelation
// 物理消息
class EPhysicsEvent
{ {
public: public:
enum INTERSECT_RELATION enum VALUE
{ {
UNKNOWN = 0, /* 关系不确定 */ UNKNOWN = 0, /* 关系不确定 */
DISJOINT = 1, /* 没有交集 */ DISJOINT = 1, /* 没有交集 */
@ -432,25 +406,12 @@ public:
CONTAINS = 3, /* 完全包含 */ CONTAINS = 3, /* 完全包含 */
OVERLAP = 4 /* 部分重叠 */ OVERLAP = 4 /* 部分重叠 */
}; };
// 获取当前物理碰撞消息类型
static INTERSECT_RELATION getMsg();
// 获取主动方
static EGeometry * getActiveGeometry();
// 获取被动方
static EGeometry * getPassiveGeometry();
public:
static INTERSECT_RELATION s_nRelation;
static EGeometry * s_pActiveGeometry;
static EGeometry * s_pPassiveGeometry;
}; };
class EObjectManager; class EObjectManager;
// 基础对象
class EObject class EObject
{ {
friend EObjectManager; friend EObjectManager;
@ -547,41 +508,61 @@ protected:
}; };
class ESprite; // 图片
class EImage : class EImage :
public EObject public EObject
{ {
friend ESprite;
public: public:
// 创建一个空的图片 // 创建一个空的图片
EImage(); EImage();
// 从本地文件中读取资源 // 从本地文件中读取资源
EImage( EImage(
LPCTSTR fileName LPCTSTR strFilePath /* 图片文件路径 */
); );
// 读取程序资源 // 从本地文件中读取资源
EImage( EImage(
LPCTSTR resourceName, LPCTSTR strFilePath,/* 图片文件路径 */
LPCTSTR resourceType float nClipX, /* 裁剪位置 X 坐标 */
float nClipY, /* 裁剪位置 Y 坐标 */
float nClipWidth, /* 裁剪宽度 */
float nClipHeight /* 裁剪高度 */
); );
virtual ~EImage(); virtual ~EImage();
// 从本地文件中读取资源 // 裁剪图片
void loadFromFile( void clip(
const EString & fileName float nClipX, /* 裁剪位置 X 坐标 */
float nClipY, /* 裁剪位置 Y 坐标 */
float nClipWidth, /* 裁剪宽度 */
float nClipHeight /* 裁剪高度 */
); );
// 读取程序资源 // 从本地文件中读取图片
void loadFromResource( void loadFrom(
LPCTSTR resourceName, const EString & strFilePath
LPCTSTR resourceType
); );
// 从本地文件中读取图片并裁剪
void loadFrom(
const EString & strFilePath,/* 图片文件路径 */
float nClipX, /* 裁剪位置 X 坐标 */
float nClipY, /* 裁剪位置 Y 坐标 */
float nClipWidth, /* 裁剪宽度 */
float nClipHeight /* 裁剪高度 */
);
// 获取宽度
virtual float getWidth() const;
// 获取高度
virtual float getHeight() const;
// 获取大小
virtual ESize getSize() const;
// 获取源图片宽度 // 获取源图片宽度
virtual float getSourceWidth() const; virtual float getSourceWidth() const;
@ -591,112 +572,32 @@ public:
// 获取源图片大小 // 获取源图片大小
virtual ESize getSourceSize() const; virtual ESize getSourceSize() const;
// 预加载资源 // 获取裁剪位置 X 坐标
static bool preload( virtual float getClipX() const;
const EString & fileName
); // 获取裁剪位置 Y 坐标
virtual float getClipY() const;
// 获取裁剪位置
virtual EPoint getClipPos() const;
// 获取 ID2D1Bitmap 对象
ID2D1Bitmap * getBitmap();
// 预加载资源 // 预加载资源
static bool preload( static bool preload(
LPCTSTR resourceName, const EString & sFileName /* 图片文件路径 */
LPCTSTR resourceType
); );
// 清空缓存 // 清空缓存
static void clearCache(); static void clearCache();
protected:
ID2D1Bitmap * _getBitmap();
protected:
ID2D1Bitmap * m_pBitmap;
};
class EKeyframe :
public EObject
{
friend ESprite;
public:
// 创建空的关键帧
EKeyframe();
// 创建空的关键帧
EKeyframe(
EImage * texture
);
// 创建空的关键帧
EKeyframe(
const EString & imageFileName
);
// 创建空的关键帧
EKeyframe(
LPCTSTR resourceName,
LPCTSTR resourceType
);
// 创建空的关键帧
EKeyframe(
EImage * texture,
float x,
float y,
float width,
float height
);
// 创建空的关键帧
EKeyframe(
const EString & imageFileName,
float x,
float y,
float width,
float height
);
// 创建空的关键帧
EKeyframe(
LPCTSTR resourceName,
LPCTSTR resourceType,
float x,
float y,
float width,
float height
);
virtual ~EKeyframe();
// 获取宽度
float getWidth() const;
// 获取高度
float getHeight() const;
// 获取图片
EImage * getImage() const;
protected:
// 修改图片
void _setImage(
EImage * texture
);
// 裁剪图片
void _clipTexture(
float x,
float y,
float width,
float height
);
protected: protected:
float m_fSourceClipX; float m_fSourceClipX;
float m_fSourceClipY; float m_fSourceClipY;
float m_fSourceClipWidth; float m_fSourceClipWidth;
float m_fSourceClipHeight; float m_fSourceClipHeight;
EImage * m_pImage; ID2D1Bitmap * m_pBitmap;
}; };
@ -721,11 +622,11 @@ public:
// 重写这个函数,它将在离开这个场景时自动执行 // 重写这个函数,它将在离开这个场景时自动执行
virtual void onExit() {} virtual void onExit() {}
// 重写这个函数,它将在窗口激活时执行 // 重写这个函数,它将在碰撞发生时自动执行
virtual bool onActivate() { return false; } virtual void onCollide(
ENode * pActiveNode, /* 主动发生碰撞的节点 */
// 重写这个函数,它将在窗口非激活时执行 ENode * pPassiveNode /* 被动发生碰撞的节点 */
virtual bool onInactive() { return false; } ) {}
// 重写这个函数,它将在关闭窗口时执行 // 重写这个函数,它将在关闭窗口时执行
virtual bool onCloseWindow() { return true; } virtual bool onCloseWindow() { return true; }
@ -733,7 +634,12 @@ public:
// 重写这个函数,它将在每一帧画面刷新时执行 // 重写这个函数,它将在每一帧画面刷新时执行
virtual void onUpdate() {} virtual void onUpdate() {}
// 添加子节点到场景 // 开启或禁用 onUpdate 函数
virtual void setAutoUpdate(
bool bAutoUpdate
);
// 添加节点到场景
void add( void add(
ENode * child, ENode * child,
int zOrder = 0 int zOrder = 0
@ -744,35 +650,11 @@ public:
ENode * child ENode * child
); );
// 删除相同名称的子节点
void remove(
const EString &childName
);
// 获取所有子节点
std::vector<e2d::ENode*> getChildren();
// 获取子节点数量
size_t getChildrenCount() const;
// 根据名称获取子节点
ENode * getChild(
const EString &childName
);
// 获取根节点 // 获取根节点
ENode * getRoot() const; ENode * getRoot() const;
// 清空所有子成员
void clearAllChildren();
// 执行动画
void runAction(
EAction * action
);
// 开启几何图形的渲染 // 开启几何图形的渲染
void setGeometryVisiable( void setShapeVisiable(
bool visiable bool visiable
); );
@ -784,10 +666,30 @@ protected:
void _update(); void _update();
protected: protected:
bool m_bAutoUpdate;
bool m_bSortNeeded; bool m_bSortNeeded;
bool m_bWillSave; bool m_bWillSave;
bool m_bGeometryVisiable; bool m_bShapeVisiable;
ENode * m_pRoot; ENode * m_pRoot;
}; };
// 二维向量
typedef EPoint EVector2;
// 定时器回调函数(参数为该定时器被调用的次数,从 0 开始)
typedef std::function<void(int)> TimerCallback;
// 按钮点击回调函数
typedef std::function<void()> BtnClkCallback;
template<typename T>
inline void SafeDelete(T** p) { if (*p) { delete *p; *p = nullptr; } }
template<typename Obj>
inline void SafeRelease(Obj** p) { if (*p) { (*p)->release(); *p = nullptr; } }
template<class Interface>
inline void SafeReleaseInterface(Interface **pp) { if (*pp != nullptr) { (*pp)->Release(); (*pp) = nullptr; } }
} }

View File

@ -1,152 +0,0 @@
#pragma once
#include "ebase.h"
#include "egeometry.h"
namespace e2d
{
class ENode;
class EPhysicsManager;
// 监听器
class EListener :
public EObject
{
public:
EListener();
EListener(
const EString &name
);
// 获取监听器状态
bool isRunning() const;
// 启动监听
void start();
// 停止监听
void stop();
// 获取监听器名称
EString getName() const;
// 获取监听器所在节点
ENode * getParentNode() const;
// 设置监听器名称
void setName(
const EString &name
);
// 设置监听器吞噬消息
void setSwallow(
bool bSwallow
);
// 设置监听器在游戏暂停时继续工作
void setAlwaysWorking(
bool bAlways
);
// 绑定监听器到场景
virtual void bindWith(
EScene * pParentScene
) = 0;
// 绑定监听器到节点
virtual void bindWith(
ENode * pParentNode
) = 0;
protected:
// 执行监听器回调函数
virtual void _callOn() = 0;
// 获取监听器状态是否就绪
virtual bool _isReady() const;
protected:
EString m_sName;
bool m_bRunning;
bool m_bAlways;
bool m_bSwallow;
ENode * m_pParentNode;
};
// 物理世界消息监听器
class EListenerPhysics :
public EListener
{
friend EPhysicsManager;
public:
EListenerPhysics();
EListenerPhysics(
const EString &name
);
EListenerPhysics(
const PhysLsnrCallback &callback
);
EListenerPhysics(
const EString &name,
const PhysLsnrCallback &callback
);
// 设置监听器回调函数
void setCallback(
const PhysLsnrCallback &callback
);
// 将监听器与场景绑定
virtual void bindWith(
EScene * pParentScene
) override;
// 将监听器与节点绑定
virtual void bindWith(
ENode * pParentNode
) override;
protected:
// 执行监听器回调函数
virtual void _callOn() override;
protected:
PhysLsnrCallback m_Callback;
};
// 几何体冲突消息监听器
class EListenerPhysicsCollision :
public EListenerPhysics
{
public:
EListenerPhysicsCollision();
EListenerPhysicsCollision(
const EString &name
);
EListenerPhysicsCollision(
const ClsLsnrCallback &callback
);
EListenerPhysicsCollision(
const EString &name,
const ClsLsnrCallback &callback
);
protected:
// 执行监听器回调函数
virtual void _callOn() override;
protected:
ClsLsnrCallback m_Callback;
};
}

View File

@ -13,7 +13,7 @@ class ENode;
class ETimer; class ETimer;
class EAction; class EAction;
class EMusic; class EMusic;
class EGeometry; class EShape;
class ETransition; class ETransition;
class EListenerPhysics; class EListenerPhysics;
@ -81,7 +81,6 @@ private:
class ETimerManager class ETimerManager
{ {
friend EGame; friend EGame;
friend EScene;
friend ENode; friend ENode;
public: public:
@ -156,7 +155,6 @@ private:
class EActionManager class EActionManager
{ {
friend EGame; friend EGame;
friend EScene;
friend ENode; friend ENode;
public: public:
@ -210,7 +208,7 @@ class EMusicManager
public: public:
// 添加音乐文件 // 添加音乐文件
static EMusic * add( static bool add(
const EString & strFilePath /* 音乐文件路径 */ const EString & strFilePath /* 音乐文件路径 */
); );
@ -243,93 +241,27 @@ private:
}; };
class EPhysicsManager class EShapeManager
{ {
friend EGame; friend EGame;
friend EScene;
friend ENode; friend ENode;
friend EGeometry; friend EShape;
public:
// 将监听器与场景绑定
static void bindListener(
EListenerPhysics * listener,
EScene * pParentScene
);
// 将监听器与节点绑定
static void bindListener(
EListenerPhysics * listener,
ENode * pParentNode
);
// 启动具有相同名称的监听器
static void startListeners(
const EString &name
);
// 停止具有相同名称的监听器
static void stopListeners(
const EString &name
);
// 删除具有相同名称的监听器
static void delListeners(
const EString &name
);
// 启动绑定在场景及其子节点上的所有监听器
static void startAllListenersBindedWith(
EScene * pParentScene
);
// 停止绑定在场景及其子节点上的所有监听器
static void stopAllListenersBindedWith(
EScene * pParentScene
);
// 启动绑定在节点上的所有监听器
static void startAllListenersBindedWith(
ENode * pParentNode
);
// 停止绑定在节点上的所有监听器
static void stopAllListenersBindedWith(
ENode * pParentNode
);
// 启动所有监听器
static void startAllListeners();
// 停止所有监听器
static void stopAllListeners();
private: private:
// 清空监听器管理器 // 更新形状
static void _clearManager(); static void __updateShape(
EShape * pActiveShape
);
// 添加形状 // 添加形状
static void _addGeometry( static void __addShape(
EGeometry * geometry EShape * pShape
); );
// 删除已绑定的形状 // 删除已绑定的形状
static void _delGeometry( static void __delShape(
EGeometry * geometry EShape * pShape
); );
// 清空绑定在节点上的所有监听器
static void _clearAllListenersBindedWith(
ENode * pParentNode
);
// 几何图形判断程序
static void PhysicsGeometryProc(
EGeometry * pActiveGeometry
);
// 物理碰撞监听器执行程序
static void PhysicsListenerProc();
}; };
} }

View File

@ -4,48 +4,49 @@
namespace e2d namespace e2d
{ {
class EText;
class ESprite;
class EAction; class EAction;
class EButton; class EShape;
class EButtonToggle;
class EGeometry;
class EMenu;
class ETransition; class ETransition;
class ENode : class ENode :
public EObject public EObject
{ {
friend EScene; friend EScene;
friend EButton; friend EShape;
friend EButtonToggle;
friend EGeometry;
friend ETransition; friend ETransition;
public: public:
ENode(); ENode();
ENode(
const EString & name
);
virtual ~ENode(); virtual ~ENode();
// 节点进入场景时,这个函数将自动运行 // 更新节点
virtual void onEnter() {}
// 节点离开场景时,这个函数将自动运行
virtual void onExit() {}
// 每一帧画面刷新时,这个函数将自动运行
virtual void onUpdate() {} virtual void onUpdate() {}
// 渲染节点时,这个函数将自动运行 // 渲染节点
virtual void onRender() {} virtual void onRender() {}
// 碰撞处理
virtual void onCollide(
ENode* pCollisionNode, /* 发生碰撞的节点 */
int nRelation /* 碰撞关系,取值为 ERelation::VALUE 中的一种 */
) {}
// 进入场景时执行
virtual void onEnter() {}
// 离开场景时执行
virtual void onExit() {}
// 获取节点显示状态 // 获取节点显示状态
virtual bool isVisiable() const; virtual bool isVisiable() const;
// 判断点是否在节点内
virtual bool isPointIn(
EPoint point
);
// 获取节点名称 // 获取节点名称
virtual EString getName() const; virtual EString getName() const;
@ -103,28 +104,57 @@ public:
// 获取节点透明度 // 获取节点透明度
virtual float getOpacity() const; virtual float getOpacity() const;
// 获取节点形状
virtual EShape * getShape() const;
// 获取父节点 // 获取父节点
virtual ENode * getParent() const; virtual ENode * getParent() const;
// 获取节点所在场景 // 获取节点所在场景
virtual EScene * getParentScene() const; virtual EScene * getParentScene() const;
// 获取所有子节点 // 获取名称相同的子节点
virtual std::vector<ENode*> &getChildren();
// 获取子节点数量
virtual size_t getChildrenCount() const;
// 根据名字获取子节点
virtual ENode * getChild( virtual ENode * getChild(
const EString & name const EString & name
); );
// 获取所有名称相同的子节点
virtual std::vector<ENode*> getChildren(
const EString & name
);
// 获取所有子节点
virtual std::vector<ENode*> &getChildren();
// 获取子节点数量
virtual int getChildrenCount() const;
// 移除子节点
virtual bool removeChild(
ENode * child
);
// 移除所有名称相同的子节点
virtual void removeChildren(
const EString & childName
);
// 从父节点移除
virtual void removeFromParent();
// 移除所有节点
virtual void clearAllChildren();
// 设置节点是否显示 // 设置节点是否显示
virtual void setVisiable( virtual void setVisiable(
bool value bool value
); );
// 开启或禁用 onUpdate 函数
virtual void setAutoUpdate(
bool bAutoUpdate
);
// 设置节点名称 // 设置节点名称
virtual void setName( virtual void setName(
const EString & name const EString & name
@ -254,8 +284,8 @@ public:
); );
// 设置节点形状 // 设置节点形状
virtual void setGeometry( virtual void setShape(
EGeometry * geometry EShape * pShape
); );
// 添加子节点 // 添加子节点
@ -264,22 +294,6 @@ public:
int order = 0 int order = 0
); );
// 从父节点移除
virtual void removeFromParent();
// 移除子节点
virtual bool removeChild(
ENode * child
);
// 移除子节点
virtual void removeChild(
const EString & childName
);
// 移除所有节点
virtual void clearAllChildren();
// 执行动画 // 执行动画
virtual void runAction( virtual void runAction(
EAction * action EAction * action
@ -309,11 +323,6 @@ public:
// 停止所有动画 // 停止所有动画
virtual void stopAllActions(); virtual void stopAllActions();
// 判断点是否在节点内
virtual bool isPointIn(
EPoint point
);
// 修改节点的默认中心点位置 // 修改节点的默认中心点位置
static void setDefaultPiovt( static void setDefaultPiovt(
float defaultPiovtX, float defaultPiovtX,
@ -328,7 +337,7 @@ protected:
virtual void _render(); virtual void _render();
// 渲染几何图形 // 渲染几何图形
virtual void _drawGeometry(); virtual void _drawShape();
// 节点被添加到场景时的执行程序 // 节点被添加到场景时的执行程序
virtual void _onEnter(); virtual void _onEnter();
@ -336,9 +345,6 @@ protected:
// 节点从场景中消失时的执行程序 // 节点从场景中消失时的执行程序
virtual void _onExit(); virtual void _onExit();
// 子节点排序
void _sortChildren();
// 设置节点所在场景 // 设置节点所在场景
virtual void _setParentScene( virtual void _setParentScene(
EScene * scene EScene * scene
@ -359,22 +365,7 @@ protected:
// 更新节点透明度 // 更新节点透明度
static void _updateOpacity(ENode * node); static void _updateOpacity(ENode * node);
// 设置节点宽度 // 修改节点大小
virtual void _setWidth(
float width
);
// 设置节点高度
virtual void _setHeight(
float height
);
// 设置节点大小
virtual void _setSize(
const ESize & size
);
// 设置节点大小
virtual void _setSize( virtual void _setSize(
float width, float width,
float height float height
@ -396,10 +387,11 @@ protected:
float m_fPivotY; float m_fPivotY;
int m_nOrder; int m_nOrder;
bool m_bVisiable; bool m_bVisiable;
bool m_bAutoUpdate;
bool m_bDisplayedInScene; bool m_bDisplayedInScene;
bool m_bSortChildrenNeeded; bool m_bSortChildrenNeeded;
bool m_bTransformNeeded; bool m_bTransformNeeded;
EGeometry * m_pGeometry; EShape * m_pShape;
EScene * m_pParentScene; EScene * m_pParentScene;
ENode * m_pParent; ENode * m_pParent;
D2D1::Matrix3x2F m_MatriInitial; D2D1::Matrix3x2F m_MatriInitial;
@ -415,16 +407,11 @@ public:
// 创建一个空精灵 // 创建一个空精灵
ESprite(); ESprite();
// 从文理资源创建精灵 // 从 EImage 对象创建精灵
ESprite( ESprite(
EImage * image EImage * image
); );
// 从关键帧创建精灵
ESprite(
EKeyframe * spriteFrame
);
// 从文件图片创建精灵 // 从文件图片创建精灵
ESprite( ESprite(
LPCTSTR imageFileName LPCTSTR imageFileName
@ -439,68 +426,33 @@ public:
float height float height
); );
// 从资源图片创建精灵
ESprite(
LPCTSTR resourceName,
LPCTSTR resourceType
);
// 从资源图片创建精灵并裁剪
ESprite(
LPCTSTR resourceName,
LPCTSTR resourceType,
float x,
float y,
float width,
float height
);
virtual ~ESprite(); virtual ~ESprite();
// 加载精灵图片 // 加载精灵图片
void loadFrom( virtual void loadFrom(
EImage * texture EImage * texture
); );
// 从本地文件加载图片 // 从本地文件加载图片
void loadFrom( virtual void loadFrom(
LPCTSTR imageFileName LPCTSTR imageFileName
); );
// 从资源加载图片
void loadFrom(
LPCTSTR resourceName,
LPCTSTR resourceType
);
// 加载图片并裁剪
void loadFrom(
EImage * image,
float x,
float y,
float width,
float height
);
// 从关键帧加载资源
void loadFrom(
EKeyframe * frame
);
// 裁剪图片 // 裁剪图片
void clip( virtual void clip(
float x, float x,
float y, float y,
float width, float width,
float height float height
); );
// 获取 EImage 对象
virtual EImage * getImage() const;
// 渲染精灵 // 渲染精灵
virtual void onRender() override; virtual void onRender() override;
protected: protected:
float m_fSourceClipX;
float m_fSourceClipY;
EImage * m_pImage; EImage * m_pImage;
}; };
@ -585,8 +537,6 @@ protected:
class EButton : class EButton :
public ENode public ENode
{ {
friend EMenu;
public: public:
// 创建一个空按钮 // 创建一个空按钮
EButton(); EButton();

View File

@ -5,20 +5,25 @@
namespace e2d namespace e2d
{ {
class EPhysicsManager; class EShapeManager;
class ENode; class ENode;
class EGeometry : class EShape :
public EObject public EObject
{ {
friend EPhysicsManager; friend EShapeManager;
friend ENode; friend ENode;
public: public:
EGeometry(); EShape();
virtual ~EGeometry(); virtual ~EShape();
// 判断两形状的交集关系
virtual int getRelationWith(
EShape * pShape
) const;
// »ñÈ¡¸¸½Úµã // »ñÈ¡¸¸½Úµã
ENode * getParentNode() const; ENode * getParentNode() const;
@ -39,7 +44,12 @@ public:
UINT32 mask UINT32 mask
); );
// 设置几何形状的可见性 // 启用或关闭该形状
virtual void setEnable(
bool bEnable
);
// 设置形状的可见性
void setVisiable( void setVisiable(
bool bVisiable bool bVisiable
); );
@ -55,38 +65,35 @@ public:
); );
protected: protected:
// 判断两形状的交集关系
virtual EPhysicsEvent::INTERSECT_RELATION _intersectWith(
EGeometry * pGeometry
);
// ת»»ÐÎ×´ // ת»»ÐÎ×´
virtual void _transform(); virtual void _transform();
// 渲染几何图 // 渲染形状
virtual void _render(); virtual void _render();
// 获取 ID2D1Geometry 对象
virtual ID2D1Geometry * _getD2dGeometry() const = 0; virtual ID2D1Geometry * _getD2dGeometry() const = 0;
protected: protected:
bool m_bEnable;
bool m_bIsVisiable; bool m_bIsVisiable;
UINT32 m_nCategoryBitmask; UINT32 m_nCategoryBitmask;
UINT32 m_nCollisionBitmask; UINT32 m_nCollisionBitmask;
UINT32 m_nColor; UINT32 m_nColor;
float m_fOpacity; float m_fOpacity;
ENode * m_pParentNode; ENode * m_pParentNode;
ID2D1TransformedGeometry * m_pTransformedGeometry; ID2D1TransformedGeometry * m_pTransformedShape;
}; };
class ERectangle : class ERectangle :
public EGeometry public EShape
{ {
public: public:
// 创建一个空几何矩形 // 创建一个空矩形
ERectangle(); ERectangle();
// 根据左上角坐标和宽高创建几何矩形 // 根据左上角坐标和宽高创建矩形
ERectangle( ERectangle(
float x, float x,
float y, float y,
@ -94,7 +101,7 @@ public:
float height float height
); );
// 创建一个和节点位置大小相同的几何矩形 // 创建一个和节点位置大小相同的矩形
ERectangle( ERectangle(
ENode * node ENode * node
); );
@ -117,19 +124,19 @@ protected:
class ECircle : class ECircle :
public EGeometry public EShape
{ {
public: public:
// 创建一个空的几何圆形 // 创建一个空的圆形
ECircle(); ECircle();
// 根据圆心和半径创建几何圆形 // 根据圆心和半径创建圆形
ECircle( ECircle(
EPoint center, EPoint center,
float radius float radius
); );
// 创建一个和节点位置大小相同的几何圆形 // 创建一个和节点位置大小相同的圆形
ECircle( ECircle(
ENode * node ENode * node
); );
@ -150,20 +157,20 @@ protected:
class EEllipse : class EEllipse :
public EGeometry public EShape
{ {
public: public:
// 创建一个空的几何椭圆 // 创建一个空的椭圆
EEllipse(); EEllipse();
// 根据圆心和半径创建几何椭圆 // 根据圆心和半径创建椭圆
EEllipse( EEllipse(
EPoint center, EPoint center,
float radiusX, float radiusX,
float radiusY float radiusY
); );
// 创建一个和节点位置大小相同的几何椭圆 // 创建一个和节点位置大小相同的椭圆
EEllipse( EEllipse(
ENode * node ENode * node
); );

View File

@ -217,14 +217,13 @@ public:
// 音乐播放器 // 音乐播放器
class EMusic class EMusic
: public EObject
{ {
friend EMusicManager; friend EMusicManager;
public: public:
// 播放 // 播放
bool play( bool play(
int nLoopCount = 0 /* 重复播放次数 */ int nLoopCount = 0 /* 重复播放次数,设置为 255 时循环播放 */
); );
// 暂停 // 暂停

View File

@ -14,12 +14,10 @@
<ClInclude Include="..\..\core\eactions.h" /> <ClInclude Include="..\..\core\eactions.h" />
<ClInclude Include="..\..\core\easy2d.h" /> <ClInclude Include="..\..\core\easy2d.h" />
<ClInclude Include="..\..\core\ebase.h" /> <ClInclude Include="..\..\core\ebase.h" />
<ClInclude Include="..\..\core\ecommon.h" />
<ClInclude Include="..\..\core\egeometry.h" />
<ClInclude Include="..\..\core\elisteners.h" />
<ClInclude Include="..\..\core\emacros.h" /> <ClInclude Include="..\..\core\emacros.h" />
<ClInclude Include="..\..\core\emanagers.h" /> <ClInclude Include="..\..\core\emanagers.h" />
<ClInclude Include="..\..\core\enodes.h" /> <ClInclude Include="..\..\core\enodes.h" />
<ClInclude Include="..\..\core\eshape.h" />
<ClInclude Include="..\..\core\etools.h" /> <ClInclude Include="..\..\core\etools.h" />
<ClInclude Include="..\..\core\etransitions.h" /> <ClInclude Include="..\..\core\etransitions.h" />
</ItemGroup> </ItemGroup>
@ -48,22 +46,14 @@
<ClCompile Include="..\..\core\Base\Window.cpp" /> <ClCompile Include="..\..\core\Base\Window.cpp" />
<ClCompile Include="..\..\core\Common\Font.cpp" /> <ClCompile Include="..\..\core\Common\Font.cpp" />
<ClCompile Include="..\..\core\Common\Image.cpp" /> <ClCompile Include="..\..\core\Common\Image.cpp" />
<ClCompile Include="..\..\core\Common\Keyframe.cpp" />
<ClCompile Include="..\..\core\Common\Object.cpp" /> <ClCompile Include="..\..\core\Common\Object.cpp" />
<ClCompile Include="..\..\core\Common\Scene.cpp" /> <ClCompile Include="..\..\core\Common\Scene.cpp" />
<ClCompile Include="..\..\core\Common\String.cpp" /> <ClCompile Include="..\..\core\Common\String.cpp" />
<ClCompile Include="..\..\core\Event\PhysicsEvent.cpp" />
<ClCompile Include="..\..\core\Geometry\Circle.cpp" />
<ClCompile Include="..\..\core\Geometry\Ellipse.cpp" />
<ClCompile Include="..\..\core\Geometry\Geometry.cpp" />
<ClCompile Include="..\..\core\Geometry\Rectangle.cpp" />
<ClCompile Include="..\..\core\Listener\Listener.cpp" />
<ClCompile Include="..\..\core\Listener\ListenerPhysics.cpp" />
<ClCompile Include="..\..\core\Listener\ListenerPhysicsCollision.cpp" />
<ClCompile Include="..\..\core\Manager\ActionManager.cpp" /> <ClCompile Include="..\..\core\Manager\ActionManager.cpp" />
<ClCompile Include="..\..\core\Manager\MusicManager.cpp" />
<ClCompile Include="..\..\core\Manager\ObjectManager.cpp" /> <ClCompile Include="..\..\core\Manager\ObjectManager.cpp" />
<ClCompile Include="..\..\core\Manager\PhysicsManager.cpp" />
<ClCompile Include="..\..\core\Manager\SceneManager.cpp" /> <ClCompile Include="..\..\core\Manager\SceneManager.cpp" />
<ClCompile Include="..\..\core\Manager\ShapeManager.cpp" />
<ClCompile Include="..\..\core\Manager\TimerManager.cpp" /> <ClCompile Include="..\..\core\Manager\TimerManager.cpp" />
<ClCompile Include="..\..\core\Node\Button.cpp" /> <ClCompile Include="..\..\core\Node\Button.cpp" />
<ClCompile Include="..\..\core\Node\ButtonToggle.cpp" /> <ClCompile Include="..\..\core\Node\ButtonToggle.cpp" />
@ -71,7 +61,12 @@
<ClCompile Include="..\..\core\Node\Node.cpp" /> <ClCompile Include="..\..\core\Node\Node.cpp" />
<ClCompile Include="..\..\core\Node\Sprite.cpp" /> <ClCompile Include="..\..\core\Node\Sprite.cpp" />
<ClCompile Include="..\..\core\Node\Text.cpp" /> <ClCompile Include="..\..\core\Node\Text.cpp" />
<ClCompile Include="..\..\core\Shape\Circle.cpp" />
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
<ClCompile Include="..\..\core\Shape\Rectangle.cpp" />
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
<ClCompile Include="..\..\core\Tool\Data.cpp" /> <ClCompile Include="..\..\core\Tool\Data.cpp" />
<ClCompile Include="..\..\core\Tool\File.cpp" />
<ClCompile Include="..\..\core\Tool\Music.cpp" /> <ClCompile Include="..\..\core\Tool\Music.cpp" />
<ClCompile Include="..\..\core\Tool\Random.cpp" /> <ClCompile Include="..\..\core\Tool\Random.cpp" />
<ClCompile Include="..\..\core\Tool\Timer.cpp" /> <ClCompile Include="..\..\core\Tool\Timer.cpp" />

View File

@ -10,18 +10,9 @@
<Filter Include="Common"> <Filter Include="Common">
<UniqueIdentifier>{08126b0c-d139-48f9-8559-3d9d9e3a5940}</UniqueIdentifier> <UniqueIdentifier>{08126b0c-d139-48f9-8559-3d9d9e3a5940}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Event">
<UniqueIdentifier>{a00a6f30-ec6b-42be-93a2-c540466670a8}</UniqueIdentifier>
</Filter>
<Filter Include="Manager"> <Filter Include="Manager">
<UniqueIdentifier>{a8185fe2-5477-4293-97d6-d84f27d354bb}</UniqueIdentifier> <UniqueIdentifier>{a8185fe2-5477-4293-97d6-d84f27d354bb}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Geometry">
<UniqueIdentifier>{dfaa8954-50d7-49c5-8aa6-7232c6d5c557}</UniqueIdentifier>
</Filter>
<Filter Include="Listener">
<UniqueIdentifier>{9b2673ff-9077-4d74-b7ec-b435e5540b66}</UniqueIdentifier>
</Filter>
<Filter Include="Node"> <Filter Include="Node">
<UniqueIdentifier>{70412fec-4c60-425b-81c9-4547e5a1b78a}</UniqueIdentifier> <UniqueIdentifier>{70412fec-4c60-425b-81c9-4547e5a1b78a}</UniqueIdentifier>
</Filter> </Filter>
@ -31,19 +22,20 @@
<Filter Include="Transition"> <Filter Include="Transition">
<UniqueIdentifier>{337d5a0f-60fd-473a-83da-b2a3515affd9}</UniqueIdentifier> <UniqueIdentifier>{337d5a0f-60fd-473a-83da-b2a3515affd9}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Shape">
<UniqueIdentifier>{dfaa8954-50d7-49c5-8aa6-7232c6d5c557}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\core\eactions.h" /> <ClInclude Include="..\..\core\eactions.h" />
<ClInclude Include="..\..\core\easy2d.h" /> <ClInclude Include="..\..\core\easy2d.h" />
<ClInclude Include="..\..\core\ebase.h" /> <ClInclude Include="..\..\core\ebase.h" />
<ClInclude Include="..\..\core\ecommon.h" />
<ClInclude Include="..\..\core\egeometry.h" />
<ClInclude Include="..\..\core\elisteners.h" />
<ClInclude Include="..\..\core\emacros.h" /> <ClInclude Include="..\..\core\emacros.h" />
<ClInclude Include="..\..\core\emanagers.h" /> <ClInclude Include="..\..\core\emanagers.h" />
<ClInclude Include="..\..\core\enodes.h" /> <ClInclude Include="..\..\core\enodes.h" />
<ClInclude Include="..\..\core\etools.h" /> <ClInclude Include="..\..\core\etools.h" />
<ClInclude Include="..\..\core\etransitions.h" /> <ClInclude Include="..\..\core\etransitions.h" />
<ClInclude Include="..\..\core\eshape.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\core\Action\Action.cpp"> <ClCompile Include="..\..\core\Action\Action.cpp">
@ -118,9 +110,6 @@
<ClCompile Include="..\..\core\Common\Image.cpp"> <ClCompile Include="..\..\core\Common\Image.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Common\Keyframe.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Common\Object.cpp"> <ClCompile Include="..\..\core\Common\Object.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>
@ -130,45 +119,18 @@
<ClCompile Include="..\..\core\Common\String.cpp"> <ClCompile Include="..\..\core\Common\String.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Event\PhysicsEvent.cpp">
<Filter>Event</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\ActionManager.cpp"> <ClCompile Include="..\..\core\Manager\ActionManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Manager\ObjectManager.cpp"> <ClCompile Include="..\..\core\Manager\ObjectManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Manager\PhysicsManager.cpp">
<Filter>Manager</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\SceneManager.cpp"> <ClCompile Include="..\..\core\Manager\SceneManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Manager\TimerManager.cpp"> <ClCompile Include="..\..\core\Manager\TimerManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Geometry\Circle.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Ellipse.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Geometry.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Rectangle.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Listener\Listener.cpp">
<Filter>Listener</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Listener\ListenerPhysics.cpp">
<Filter>Listener</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Listener\ListenerPhysicsCollision.cpp">
<Filter>Listener</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Tool\Data.cpp"> <ClCompile Include="..\..\core\Tool\Data.cpp">
<Filter>Tool</Filter> <Filter>Tool</Filter>
</ClCompile> </ClCompile>
@ -211,5 +173,26 @@
<ClCompile Include="..\..\core\Node\Text.cpp"> <ClCompile Include="..\..\core\Node\Text.cpp">
<Filter>Node</Filter> <Filter>Node</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Shape\Circle.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Ellipse.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Rectangle.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Shape.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\MusicManager.cpp">
<Filter>Manager</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\ShapeManager.cpp">
<Filter>Manager</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Tool\File.cpp">
<Filter>Tool</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -89,11 +89,10 @@
<ClInclude Include="..\..\core\easy2d.h" /> <ClInclude Include="..\..\core\easy2d.h" />
<ClInclude Include="..\..\core\ebase.h" /> <ClInclude Include="..\..\core\ebase.h" />
<ClInclude Include="..\..\core\ecommon.h" /> <ClInclude Include="..\..\core\ecommon.h" />
<ClInclude Include="..\..\core\egeometry.h" />
<ClInclude Include="..\..\core\elisteners.h" />
<ClInclude Include="..\..\core\emacros.h" /> <ClInclude Include="..\..\core\emacros.h" />
<ClInclude Include="..\..\core\emanagers.h" /> <ClInclude Include="..\..\core\emanagers.h" />
<ClInclude Include="..\..\core\enodes.h" /> <ClInclude Include="..\..\core\enodes.h" />
<ClInclude Include="..\..\core\eshape.h" />
<ClInclude Include="..\..\core\etools.h" /> <ClInclude Include="..\..\core\etools.h" />
<ClInclude Include="..\..\core\etransitions.h" /> <ClInclude Include="..\..\core\etransitions.h" />
</ItemGroup> </ItemGroup>
@ -122,22 +121,14 @@
<ClCompile Include="..\..\core\Base\Window.cpp" /> <ClCompile Include="..\..\core\Base\Window.cpp" />
<ClCompile Include="..\..\core\Common\Font.cpp" /> <ClCompile Include="..\..\core\Common\Font.cpp" />
<ClCompile Include="..\..\core\Common\Image.cpp" /> <ClCompile Include="..\..\core\Common\Image.cpp" />
<ClCompile Include="..\..\core\Common\Keyframe.cpp" />
<ClCompile Include="..\..\core\Common\Object.cpp" /> <ClCompile Include="..\..\core\Common\Object.cpp" />
<ClCompile Include="..\..\core\Common\Scene.cpp" /> <ClCompile Include="..\..\core\Common\Scene.cpp" />
<ClCompile Include="..\..\core\Common\String.cpp" /> <ClCompile Include="..\..\core\Common\String.cpp" />
<ClCompile Include="..\..\core\Event\PhysicsEvent.cpp" />
<ClCompile Include="..\..\core\Geometry\Circle.cpp" />
<ClCompile Include="..\..\core\Geometry\Ellipse.cpp" />
<ClCompile Include="..\..\core\Geometry\Geometry.cpp" />
<ClCompile Include="..\..\core\Geometry\Rectangle.cpp" />
<ClCompile Include="..\..\core\Listener\Listener.cpp" />
<ClCompile Include="..\..\core\Listener\ListenerPhysics.cpp" />
<ClCompile Include="..\..\core\Listener\ListenerPhysicsCollision.cpp" />
<ClCompile Include="..\..\core\Manager\ActionManager.cpp" /> <ClCompile Include="..\..\core\Manager\ActionManager.cpp" />
<ClCompile Include="..\..\core\Manager\MusicManager.cpp" />
<ClCompile Include="..\..\core\Manager\ObjectManager.cpp" /> <ClCompile Include="..\..\core\Manager\ObjectManager.cpp" />
<ClCompile Include="..\..\core\Manager\PhysicsManager.cpp" />
<ClCompile Include="..\..\core\Manager\SceneManager.cpp" /> <ClCompile Include="..\..\core\Manager\SceneManager.cpp" />
<ClCompile Include="..\..\core\Manager\ShapeManager.cpp" />
<ClCompile Include="..\..\core\Manager\TimerManager.cpp" /> <ClCompile Include="..\..\core\Manager\TimerManager.cpp" />
<ClCompile Include="..\..\core\Node\Button.cpp" /> <ClCompile Include="..\..\core\Node\Button.cpp" />
<ClCompile Include="..\..\core\Node\ButtonToggle.cpp" /> <ClCompile Include="..\..\core\Node\ButtonToggle.cpp" />
@ -145,7 +136,12 @@
<ClCompile Include="..\..\core\Node\Node.cpp" /> <ClCompile Include="..\..\core\Node\Node.cpp" />
<ClCompile Include="..\..\core\Node\Sprite.cpp" /> <ClCompile Include="..\..\core\Node\Sprite.cpp" />
<ClCompile Include="..\..\core\Node\Text.cpp" /> <ClCompile Include="..\..\core\Node\Text.cpp" />
<ClCompile Include="..\..\core\Shape\Circle.cpp" />
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
<ClCompile Include="..\..\core\Shape\Rectangle.cpp" />
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
<ClCompile Include="..\..\core\Tool\Data.cpp" /> <ClCompile Include="..\..\core\Tool\Data.cpp" />
<ClCompile Include="..\..\core\Tool\File.cpp" />
<ClCompile Include="..\..\core\Tool\Music.cpp" /> <ClCompile Include="..\..\core\Tool\Music.cpp" />
<ClCompile Include="..\..\core\Tool\Random.cpp" /> <ClCompile Include="..\..\core\Tool\Random.cpp" />
<ClCompile Include="..\..\core\Tool\Timer.cpp" /> <ClCompile Include="..\..\core\Tool\Timer.cpp" />

View File

@ -10,18 +10,9 @@
<Filter Include="Common"> <Filter Include="Common">
<UniqueIdentifier>{08126b0c-d139-48f9-8559-3d9d9e3a5940}</UniqueIdentifier> <UniqueIdentifier>{08126b0c-d139-48f9-8559-3d9d9e3a5940}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Event">
<UniqueIdentifier>{a00a6f30-ec6b-42be-93a2-c540466670a8}</UniqueIdentifier>
</Filter>
<Filter Include="Manager"> <Filter Include="Manager">
<UniqueIdentifier>{a8185fe2-5477-4293-97d6-d84f27d354bb}</UniqueIdentifier> <UniqueIdentifier>{a8185fe2-5477-4293-97d6-d84f27d354bb}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Geometry">
<UniqueIdentifier>{dfaa8954-50d7-49c5-8aa6-7232c6d5c557}</UniqueIdentifier>
</Filter>
<Filter Include="Listener">
<UniqueIdentifier>{9b2673ff-9077-4d74-b7ec-b435e5540b66}</UniqueIdentifier>
</Filter>
<Filter Include="Node"> <Filter Include="Node">
<UniqueIdentifier>{70412fec-4c60-425b-81c9-4547e5a1b78a}</UniqueIdentifier> <UniqueIdentifier>{70412fec-4c60-425b-81c9-4547e5a1b78a}</UniqueIdentifier>
</Filter> </Filter>
@ -31,19 +22,21 @@
<Filter Include="Transition"> <Filter Include="Transition">
<UniqueIdentifier>{337d5a0f-60fd-473a-83da-b2a3515affd9}</UniqueIdentifier> <UniqueIdentifier>{337d5a0f-60fd-473a-83da-b2a3515affd9}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Shape">
<UniqueIdentifier>{dfaa8954-50d7-49c5-8aa6-7232c6d5c557}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\core\eactions.h" /> <ClInclude Include="..\..\core\eactions.h" />
<ClInclude Include="..\..\core\easy2d.h" /> <ClInclude Include="..\..\core\easy2d.h" />
<ClInclude Include="..\..\core\ebase.h" /> <ClInclude Include="..\..\core\ebase.h" />
<ClInclude Include="..\..\core\ecommon.h" /> <ClInclude Include="..\..\core\ecommon.h" />
<ClInclude Include="..\..\core\egeometry.h" />
<ClInclude Include="..\..\core\elisteners.h" />
<ClInclude Include="..\..\core\emacros.h" /> <ClInclude Include="..\..\core\emacros.h" />
<ClInclude Include="..\..\core\emanagers.h" /> <ClInclude Include="..\..\core\emanagers.h" />
<ClInclude Include="..\..\core\enodes.h" /> <ClInclude Include="..\..\core\enodes.h" />
<ClInclude Include="..\..\core\etools.h" /> <ClInclude Include="..\..\core\etools.h" />
<ClInclude Include="..\..\core\etransitions.h" /> <ClInclude Include="..\..\core\etransitions.h" />
<ClInclude Include="..\..\core\eshape.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\core\Action\Action.cpp"> <ClCompile Include="..\..\core\Action\Action.cpp">
@ -118,9 +111,6 @@
<ClCompile Include="..\..\core\Common\Image.cpp"> <ClCompile Include="..\..\core\Common\Image.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Common\Keyframe.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Common\Object.cpp"> <ClCompile Include="..\..\core\Common\Object.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>
@ -130,45 +120,18 @@
<ClCompile Include="..\..\core\Common\String.cpp"> <ClCompile Include="..\..\core\Common\String.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Event\PhysicsEvent.cpp">
<Filter>Event</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\ActionManager.cpp"> <ClCompile Include="..\..\core\Manager\ActionManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Manager\ObjectManager.cpp"> <ClCompile Include="..\..\core\Manager\ObjectManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Manager\PhysicsManager.cpp">
<Filter>Manager</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\SceneManager.cpp"> <ClCompile Include="..\..\core\Manager\SceneManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Manager\TimerManager.cpp"> <ClCompile Include="..\..\core\Manager\TimerManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Geometry\Circle.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Ellipse.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Geometry.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Rectangle.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Listener\Listener.cpp">
<Filter>Listener</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Listener\ListenerPhysics.cpp">
<Filter>Listener</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Listener\ListenerPhysicsCollision.cpp">
<Filter>Listener</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Tool\Data.cpp"> <ClCompile Include="..\..\core\Tool\Data.cpp">
<Filter>Tool</Filter> <Filter>Tool</Filter>
</ClCompile> </ClCompile>
@ -211,5 +174,26 @@
<ClCompile Include="..\..\core\Node\Text.cpp"> <ClCompile Include="..\..\core\Node\Text.cpp">
<Filter>Node</Filter> <Filter>Node</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Shape\Circle.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Ellipse.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Rectangle.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Shape.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\ShapeManager.cpp">
<Filter>Manager</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Tool\File.cpp">
<Filter>Tool</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\MusicManager.cpp">
<Filter>Manager</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -214,22 +214,13 @@
<ClCompile Include="..\..\core\Base\Window.cpp" /> <ClCompile Include="..\..\core\Base\Window.cpp" />
<ClCompile Include="..\..\core\Common\Font.cpp" /> <ClCompile Include="..\..\core\Common\Font.cpp" />
<ClCompile Include="..\..\core\Common\Object.cpp" /> <ClCompile Include="..\..\core\Common\Object.cpp" />
<ClCompile Include="..\..\core\Common\Keyframe.cpp" />
<ClCompile Include="..\..\core\Common\Scene.cpp" /> <ClCompile Include="..\..\core\Common\Scene.cpp" />
<ClCompile Include="..\..\core\Common\String.cpp" /> <ClCompile Include="..\..\core\Common\String.cpp" />
<ClCompile Include="..\..\core\Common\Image.cpp" /> <ClCompile Include="..\..\core\Common\Image.cpp" />
<ClCompile Include="..\..\core\Event\PhysicsEvent.cpp" />
<ClCompile Include="..\..\core\Geometry\Circle.cpp" />
<ClCompile Include="..\..\core\Geometry\Ellipse.cpp" />
<ClCompile Include="..\..\core\Geometry\Geometry.cpp" />
<ClCompile Include="..\..\core\Geometry\Rectangle.cpp" />
<ClCompile Include="..\..\core\Listener\ListenerPhysicsCollision.cpp" />
<ClCompile Include="..\..\core\Listener\Listener.cpp" />
<ClCompile Include="..\..\core\Listener\ListenerPhysics.cpp" />
<ClCompile Include="..\..\core\Manager\ActionManager.cpp" /> <ClCompile Include="..\..\core\Manager\ActionManager.cpp" />
<ClCompile Include="..\..\core\Manager\MusicManager.cpp" /> <ClCompile Include="..\..\core\Manager\MusicManager.cpp" />
<ClCompile Include="..\..\core\Manager\ObjectManager.cpp" /> <ClCompile Include="..\..\core\Manager\ObjectManager.cpp" />
<ClCompile Include="..\..\core\Manager\PhysicsManager.cpp" /> <ClCompile Include="..\..\core\Manager\ShapeManager.cpp" />
<ClCompile Include="..\..\core\Manager\SceneManager.cpp" /> <ClCompile Include="..\..\core\Manager\SceneManager.cpp" />
<ClCompile Include="..\..\core\Manager\TimerManager.cpp" /> <ClCompile Include="..\..\core\Manager\TimerManager.cpp" />
<ClCompile Include="..\..\core\Node\Button.cpp" /> <ClCompile Include="..\..\core\Node\Button.cpp" />
@ -238,6 +229,10 @@
<ClCompile Include="..\..\core\Node\Node.cpp" /> <ClCompile Include="..\..\core\Node\Node.cpp" />
<ClCompile Include="..\..\core\Node\Sprite.cpp" /> <ClCompile Include="..\..\core\Node\Sprite.cpp" />
<ClCompile Include="..\..\core\Node\Text.cpp" /> <ClCompile Include="..\..\core\Node\Text.cpp" />
<ClCompile Include="..\..\core\Shape\Circle.cpp" />
<ClCompile Include="..\..\core\Shape\Ellipse.cpp" />
<ClCompile Include="..\..\core\Shape\Rectangle.cpp" />
<ClCompile Include="..\..\core\Shape\Shape.cpp" />
<ClCompile Include="..\..\core\Tool\Data.cpp" /> <ClCompile Include="..\..\core\Tool\Data.cpp" />
<ClCompile Include="..\..\core\Tool\File.cpp" /> <ClCompile Include="..\..\core\Tool\File.cpp" />
<ClCompile Include="..\..\core\Tool\Music.cpp" /> <ClCompile Include="..\..\core\Tool\Music.cpp" />
@ -253,8 +248,7 @@
<ClInclude Include="..\..\core\easy2d.h" /> <ClInclude Include="..\..\core\easy2d.h" />
<ClInclude Include="..\..\core\ebase.h" /> <ClInclude Include="..\..\core\ebase.h" />
<ClInclude Include="..\..\core\ecommon.h" /> <ClInclude Include="..\..\core\ecommon.h" />
<ClInclude Include="..\..\core\egeometry.h" /> <ClInclude Include="..\..\core\eshape.h" />
<ClInclude Include="..\..\core\elisteners.h" />
<ClInclude Include="..\..\core\emacros.h" /> <ClInclude Include="..\..\core\emacros.h" />
<ClInclude Include="..\..\core\emanagers.h" /> <ClInclude Include="..\..\core\emanagers.h" />
<ClInclude Include="..\..\core\enodes.h" /> <ClInclude Include="..\..\core\enodes.h" />

View File

@ -19,17 +19,11 @@
<Filter Include="Manager"> <Filter Include="Manager">
<UniqueIdentifier>{9031e36b-fa85-4b4e-8e80-657c7e68f283}</UniqueIdentifier> <UniqueIdentifier>{9031e36b-fa85-4b4e-8e80-657c7e68f283}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Listener">
<UniqueIdentifier>{b9bb1728-5106-4574-998e-8564b49cb4a1}</UniqueIdentifier>
</Filter>
<Filter Include="Geometry">
<UniqueIdentifier>{d5f86335-f3a0-450d-92a3-7edd9348d995}</UniqueIdentifier>
</Filter>
<Filter Include="Common"> <Filter Include="Common">
<UniqueIdentifier>{be5d9314-b00a-4f11-bd2a-1f720dc32407}</UniqueIdentifier> <UniqueIdentifier>{be5d9314-b00a-4f11-bd2a-1f720dc32407}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Event"> <Filter Include="Shape">
<UniqueIdentifier>{6d0b43af-2432-4221-b572-4bef331ae10e}</UniqueIdentifier> <UniqueIdentifier>{d5f86335-f3a0-450d-92a3-7edd9348d995}</UniqueIdentifier>
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -105,9 +99,6 @@
<ClCompile Include="..\..\core\Common\Image.cpp"> <ClCompile Include="..\..\core\Common\Image.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Common\Keyframe.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Common\Object.cpp"> <ClCompile Include="..\..\core\Common\Object.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>
@ -117,39 +108,12 @@
<ClCompile Include="..\..\core\Common\Scene.cpp"> <ClCompile Include="..\..\core\Common\Scene.cpp">
<Filter>Common</Filter> <Filter>Common</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Event\PhysicsEvent.cpp">
<Filter>Event</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Circle.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Ellipse.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Geometry.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Geometry\Rectangle.cpp">
<Filter>Geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Listener\Listener.cpp">
<Filter>Listener</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Listener\ListenerPhysics.cpp">
<Filter>Listener</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Listener\ListenerPhysicsCollision.cpp">
<Filter>Listener</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\ActionManager.cpp"> <ClCompile Include="..\..\core\Manager\ActionManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Manager\ObjectManager.cpp"> <ClCompile Include="..\..\core\Manager\ObjectManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Manager\PhysicsManager.cpp">
<Filter>Manager</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Manager\TimerManager.cpp"> <ClCompile Include="..\..\core\Manager\TimerManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
@ -204,6 +168,21 @@
<ClCompile Include="..\..\core\Manager\MusicManager.cpp"> <ClCompile Include="..\..\core\Manager\MusicManager.cpp">
<Filter>Manager</Filter> <Filter>Manager</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\Manager\ShapeManager.cpp">
<Filter>Manager</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Circle.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Ellipse.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Rectangle.cpp">
<Filter>Shape</Filter>
</ClCompile>
<ClCompile Include="..\..\core\Shape\Shape.cpp">
<Filter>Shape</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\core\etools.h" /> <ClInclude Include="..\..\core\etools.h" />
@ -214,8 +193,7 @@
<ClInclude Include="..\..\core\easy2d.h" /> <ClInclude Include="..\..\core\easy2d.h" />
<ClInclude Include="..\..\core\eactions.h" /> <ClInclude Include="..\..\core\eactions.h" />
<ClInclude Include="..\..\core\etransitions.h" /> <ClInclude Include="..\..\core\etransitions.h" />
<ClInclude Include="..\..\core\egeometry.h" />
<ClInclude Include="..\..\core\elisteners.h" />
<ClInclude Include="..\..\core\emanagers.h" /> <ClInclude Include="..\..\core\emanagers.h" />
<ClInclude Include="..\..\core\eshape.h" />
</ItemGroup> </ItemGroup>
</Project> </Project>