diff --git a/core/Common/Image.cpp b/core/Common/Image.cpp index 28def6dc..6e87d601 100644 --- a/core/Common/Image.cpp +++ b/core/Common/Image.cpp @@ -46,7 +46,7 @@ e2d::Image::~Image() bool e2d::Image::open(const Resource& res) { - if (!res.isResource()) + if (res.isFile()) { WARN_IF(res.getFileName().isEmpty(), "Image open failed! Invalid file name."); @@ -162,7 +162,7 @@ bool e2d::Image::preload(const Resource& res) ID2D1Bitmap *pBitmap = nullptr; IWICImagingFactory *pImagingFactory = Renderer::getImagingFactory(); - if (res.isResource()) + if (!res.isFile()) { HRSRC imageResHandle = nullptr; HGLOBAL imageResDataHandle = nullptr; diff --git a/core/Common/Resource.cpp b/core/Common/Resource.cpp index 343c01a7..86bd4008 100644 --- a/core/Common/Resource.cpp +++ b/core/Common/Resource.cpp @@ -1,7 +1,7 @@ #include "..\e2dtool.h" e2d::Resource::Resource(const String & fileName) - : _isResource(false) + : _isFile(true) , _fileName(fileName) , _resNameId(0) , _resType() @@ -9,16 +9,16 @@ e2d::Resource::Resource(const String & fileName) } e2d::Resource::Resource(size_t resNameId, const String & resType) - : _isResource(true) + : _isFile(false) , _fileName() , _resNameId(resNameId) , _resType(resType) { } -bool e2d::Resource::isResource() const +bool e2d::Resource::isFile() const { - return _isResource; + return _isFile; } const e2d::String & e2d::Resource::getFileName() const @@ -38,7 +38,7 @@ const e2d::String & e2d::Resource::getResType() const size_t e2d::Resource::getKey() const { - return _isResource ? _resNameId : _fileName.getHashCode(); + return _isFile ? _fileName.getHashCode() : _resNameId; } bool e2d::Resource::operator>(const Resource &res) const diff --git a/core/Manager/SceneManager.cpp b/core/Manager/SceneManager.cpp index b197451a..7363e499 100644 --- a/core/Manager/SceneManager.cpp +++ b/core/Manager/SceneManager.cpp @@ -40,6 +40,7 @@ void e2d::SceneManager::push(Scene * scene, Transition * transition /* = nullptr return; // 保存下一场景的指针 + if (_nextScene) _nextScene->release(); _nextScene = scene; _nextScene->retain(); diff --git a/core/Node/Button.cpp b/core/Node/Button.cpp index 71b5cc2c..7179955f 100644 --- a/core/Node/Button.cpp +++ b/core/Node/Button.cpp @@ -191,10 +191,9 @@ void e2d::Button::_fixedUpdate() if (_isSelected && _normal->containsPoint(input->getMousePos())) { + _isSelected = false; _runCallback(); } - // 标记 _isSelected 为 false - _isSelected = false; } if (input->isPress(MouseCode::Left)) diff --git a/core/Tool/Music.cpp b/core/Tool/Music.cpp index 1dc678b0..c9e39ab5 100644 --- a/core/Tool/Music.cpp +++ b/core/Tool/Music.cpp @@ -81,7 +81,7 @@ bool e2d::Music::open(const Resource& res) return false; } - if (res.isResource()) + if (!res.isFile()) { HRSRC hResInfo; HGLOBAL hResData; diff --git a/core/e2dcommon.h b/core/e2dcommon.h index febde6b1..89c9c769 100644 --- a/core/e2dcommon.h +++ b/core/e2dcommon.h @@ -803,8 +803,8 @@ public: const String& resType /* 资源类型 */ ); - // 是否是资源类型 - bool isResource() const; + // 是否是本地文件 + bool isFile() const; const String& getFileName() const; @@ -821,7 +821,7 @@ public: bool operator<= (const Resource &) const; protected: - bool _isResource; + bool _isFile; size_t _resNameId; String _resType; String _fileName;