函数参数中的String替换为const String&

This commit is contained in:
Nomango 2018-05-07 15:48:06 +08:00
parent d311461a48
commit 6336c979c9
25 changed files with 287 additions and 285 deletions

View File

@ -57,7 +57,7 @@ e2d::String e2d::ActionBase::getName() const
return m_sName; return m_sName;
} }
void e2d::ActionBase::setName(String name) void e2d::ActionBase::setName(const String& name)
{ {
m_sName = name; m_sName = name;
} }

View File

@ -13,7 +13,7 @@ static bool s_bInitialized = false;
static e2d::String s_sGameName; static e2d::String s_sGameName;
bool e2d::Game::init(String sGameName) bool e2d::Game::init(const String& name)
{ {
if (s_bInitialized) if (s_bInitialized)
{ {
@ -60,7 +60,7 @@ bool e2d::Game::init(String sGameName)
} }
// ±£´æÓÎÏ·Ãû³Æ // ±£´æÓÎÏ·Ãû³Æ
s_sGameName = sGameName; s_sGameName = name;
// ³õʼ»¯Â·¾¶ // ³õʼ»¯Â·¾¶
if (!Path::__init()) if (!Path::__init())
@ -88,7 +88,7 @@ succeeded:
return s_bInitialized; return s_bInitialized;
} }
int e2d::Game::start(bool bAutoRelease/* true */) int e2d::Game::start(bool autoRelease/* true */)
{ {
if (!s_bInitialized) if (!s_bInitialized)
{ {
@ -134,7 +134,7 @@ int e2d::Game::start(bool bAutoRelease/* true */)
} }
} }
if (bAutoRelease) if (autoRelease)
{ {
Game::destroy(); Game::destroy();
} }
@ -201,7 +201,7 @@ void e2d::Game::destroy()
s_bInitialized = false; s_bInitialized = false;
} }
bool e2d::Game::createMutex(String sMutexName, String sWindowTitle) bool e2d::Game::createMutex(const String& sMutexName, const String& sWindowTitle)
{ {
// ´´½¨½ø³Ì»¥³âÌå // ´´½¨½ø³Ì»¥³âÌå
HANDLE m_hMutex = ::CreateMutex(NULL, TRUE, L"Easy2DApp-" + sMutexName); HANDLE m_hMutex = ::CreateMutex(NULL, TRUE, L"Easy2DApp-" + sMutexName);

View File

@ -174,16 +174,16 @@ void e2d::Window::setSize(int width, int height)
::MoveWindow(s_HWnd, (screenWidth - width) / 2, (screenHeight - height) / 2, width, height, TRUE); ::MoveWindow(s_HWnd, (screenWidth - width) / 2, (screenHeight - height) / 2, width, height, TRUE);
} }
void e2d::Window::setTitle(String title) void e2d::Window::setTitle(const String& title)
{ {
// 设置窗口标题 // 设置窗口标题
::SetWindowText(s_HWnd, title); ::SetWindowText(s_HWnd, title);
} }
void e2d::Window::setIcon(int pIconID) void e2d::Window::setIcon(int iconID)
{ {
HINSTANCE hInstance = ::GetModuleHandle(NULL); HINSTANCE hInstance = ::GetModuleHandle(NULL);
HICON hIcon = (HICON)::LoadImage(hInstance, MAKEINTRESOURCE(pIconID), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); HICON hIcon = (HICON)::LoadImage(hInstance, MAKEINTRESOURCE(iconID), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
// 设置窗口的图标 // 设置窗口的图标
::SendMessage(s_HWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon); ::SendMessage(s_HWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
::SendMessage(s_HWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); ::SendMessage(s_HWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
@ -237,11 +237,11 @@ void e2d::Window::showConsole(bool show)
} }
} }
void e2d::Window::setTypewritingEnable(bool bEnable) void e2d::Window::setTypewritingEnable(bool enable)
{ {
static HIMC hImc = nullptr; static HIMC hImc = nullptr;
if (bEnable) if (enable)
{ {
if (hImc != nullptr) if (hImc != nullptr)
{ {

View File

@ -27,9 +27,9 @@ e2d::Color e2d::Collider::getColor() const
return m_nColor; return m_nColor;
} }
void e2d::Collider::setEnable(bool bEnable) void e2d::Collider::setEnable(bool enable)
{ {
m_bEnable = bEnable; m_bEnable = enable;
} }
void e2d::Collider::setVisiable(bool bVisiable) void e2d::Collider::setVisiable(bool bVisiable)
@ -42,9 +42,9 @@ void e2d::Collider::setColor(Color color)
m_nColor = color; m_nColor = color;
} }
void e2d::Collider::setAutoResize(bool bEnable) void e2d::Collider::setAutoResize(bool enable)
{ {
m_bAutoResize = bEnable; m_bAutoResize = enable;
} }
void e2d::Collider::_render() void e2d::Collider::_render()

View File

@ -14,57 +14,57 @@ e2d::Image::Image()
{ {
} }
e2d::Image::Image(String strFileName) e2d::Image::Image(const String& filePath)
: m_pBitmap(nullptr) : m_pBitmap(nullptr)
{ {
this->open(strFileName); this->open(filePath);
} }
e2d::Image::Image(int resNameId, String resType) e2d::Image::Image(int resNameId, const String& resType)
: m_pBitmap(nullptr) : m_pBitmap(nullptr)
{ {
this->open(resNameId, resType); this->open(resNameId, resType);
} }
e2d::Image::Image(String strFileName, double nCropX, double nCropY, double nCropWidth, double nCropHeight) e2d::Image::Image(const String& filePath, double cropX, double cropY, double cropWidth, double cropHeight)
: m_pBitmap(nullptr) : m_pBitmap(nullptr)
{ {
this->open(strFileName); this->open(filePath);
this->crop(nCropX, nCropY, nCropWidth, nCropHeight); this->crop(cropX, cropY, cropWidth, cropHeight);
} }
e2d::Image::Image(int resNameId, String resType, double nCropX, double nCropY, double nCropWidth, double nCropHeight) e2d::Image::Image(int resNameId, const String& resType, double cropX, double cropY, double cropWidth, double cropHeight)
: m_pBitmap(nullptr) : m_pBitmap(nullptr)
{ {
this->open(resNameId, resType); this->open(resNameId, resType);
this->crop(nCropX, nCropY, nCropWidth, nCropHeight); this->crop(cropX, cropY, cropWidth, cropHeight);
} }
e2d::Image::~Image() e2d::Image::~Image()
{ {
} }
bool e2d::Image::open(String strFilePath) bool e2d::Image::open(const String& filePath)
{ {
WARN_IF(strFilePath.isEmpty(), "Image cannot load bitmap from NULL file name."); WARN_IF(filePath.isEmpty(), "Image cannot load bitmap from NULL file name.");
if (strFilePath.isEmpty()) if (filePath.isEmpty())
return false; return false;
if (!Image::preload(strFilePath)) if (!Image::preload(filePath))
{ {
WARN_IF(true, "Load Image from file failed!"); WARN_IF(true, "Load Image from file failed!");
return false; return false;
} }
m_pBitmap = s_mBitmapsFromFile.at(strFilePath.getHashCode()); m_pBitmap = s_mBitmapsFromFile.at(filePath.getHashCode());
m_fSourceCropX = m_fSourceCropY = 0; m_fSourceCropX = m_fSourceCropY = 0;
m_fSourceCropWidth = m_pBitmap->GetSize().width; m_fSourceCropWidth = m_pBitmap->GetSize().width;
m_fSourceCropHeight = m_pBitmap->GetSize().height; m_fSourceCropHeight = m_pBitmap->GetSize().height;
return true; return true;
} }
bool e2d::Image::open(int resNameId, String resType) bool e2d::Image::open(int resNameId, const String& resType)
{ {
if (!Image::preload(resNameId, resType)) if (!Image::preload(resNameId, resType))
{ {
@ -156,7 +156,7 @@ e2d::Point e2d::Image::getCropPos() const
return Point(m_fSourceCropX, m_fSourceCropY); return Point(m_fSourceCropX, m_fSourceCropY);
} }
bool e2d::Image::preload(String fileName) bool e2d::Image::preload(const String& fileName)
{ {
if (s_mBitmapsFromFile.find(fileName.getHashCode()) != s_mBitmapsFromFile.end()) if (s_mBitmapsFromFile.find(fileName.getHashCode()) != s_mBitmapsFromFile.end())
{ {
@ -232,7 +232,7 @@ bool e2d::Image::preload(String fileName)
return SUCCEEDED(hr); return SUCCEEDED(hr);
} }
bool e2d::Image::preload(int resNameId, String resType) bool e2d::Image::preload(int resNameId, const String& resType)
{ {
if (s_mBitmapsFromResource.find(resNameId) != s_mBitmapsFromResource.end()) if (s_mBitmapsFromResource.find(resNameId) != s_mBitmapsFromResource.end())
{ {

View File

@ -67,12 +67,12 @@ bool e2d::Scene::remove(Node * child)
return m_pRoot->removeChild(child); return m_pRoot->removeChild(child);
} }
std::vector<e2d::Node*> e2d::Scene::get(String name) const std::vector<e2d::Node*> e2d::Scene::get(const String& name) const
{ {
return m_pRoot->getChildren(name); return m_pRoot->getChildren(name);
} }
e2d::Node * e2d::Scene::getOne(String name) const e2d::Node * e2d::Scene::getOne(const String& name) const
{ {
return m_pRoot->getChild(name); return m_pRoot->getChild(name);
} }

View File

@ -19,7 +19,7 @@ e2d::TextStyle::TextStyle()
{} {}
e2d::TextStyle::TextStyle( e2d::TextStyle::TextStyle(
String fontFamily, const String& fontFamily,
double fontSize, double fontSize,
Color color, Color color,
UINT32 fontWeight, UINT32 fontWeight,

View File

@ -114,7 +114,7 @@ void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode)
} }
} }
void e2d::ActionManager::resume(String strActionName) void e2d::ActionManager::resume(const String& strActionName)
{ {
for (auto action : s_vRunningActions) for (auto action : s_vRunningActions)
{ {
@ -125,7 +125,7 @@ void e2d::ActionManager::resume(String strActionName)
} }
} }
void e2d::ActionManager::pause(String strActionName) void e2d::ActionManager::pause(const String& strActionName)
{ {
for (auto action : s_vRunningActions) for (auto action : s_vRunningActions)
{ {
@ -136,7 +136,7 @@ void e2d::ActionManager::pause(String strActionName)
} }
} }
void e2d::ActionManager::stop(String strActionName) void e2d::ActionManager::stop(const String& strActionName)
{ {
for (auto action : s_vRunningActions) for (auto action : s_vRunningActions)
{ {
@ -201,7 +201,7 @@ void e2d::ActionManager::stopAll()
} }
} }
std::vector<e2d::ActionBase*> e2d::ActionManager::get(String strActionName) std::vector<e2d::ActionBase*> e2d::ActionManager::get(const String& strActionName)
{ {
std::vector<ActionBase*> vActions; std::vector<ActionBase*> vActions;
for (auto action : s_vActions) for (auto action : s_vActions)

View File

@ -9,7 +9,7 @@ class Listener
public: public:
Listener( Listener(
e2d::Function func, e2d::Function func,
e2d::String name, const e2d::String& name,
bool paused bool paused
) )
: name(name) : name(name)
@ -47,9 +47,9 @@ static e2d::Node * s_pActiveNode = nullptr;
static e2d::Node * s_pPassiveNode = nullptr; static e2d::Node * s_pPassiveNode = nullptr;
void e2d::ColliderManager::setEnable(bool bEnable) void e2d::ColliderManager::setEnable(bool enable)
{ {
s_bCollisionEnable = bEnable; s_bCollisionEnable = enable;
} }
void e2d::ColliderManager::__update() void e2d::ColliderManager::__update()
@ -133,13 +133,13 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider)
s_pPassiveNode = nullptr; s_pPassiveNode = nullptr;
} }
void e2d::ColliderManager::add(Function func, String name, bool paused) void e2d::ColliderManager::add(Function func, const String& name, bool paused)
{ {
auto listener = new Listener(func, name, paused); auto listener = new Listener(func, name, paused);
s_vListeners.push_back(listener); s_vListeners.push_back(listener);
} }
void e2d::ColliderManager::pause(String name) void e2d::ColliderManager::pause(const String& name)
{ {
for (auto pListener : s_vListeners) for (auto pListener : s_vListeners)
{ {
@ -150,7 +150,7 @@ void e2d::ColliderManager::pause(String name)
} }
} }
void e2d::ColliderManager::resume(String name) void e2d::ColliderManager::resume(const String& name)
{ {
for (auto pListener : s_vListeners) for (auto pListener : s_vListeners)
{ {
@ -161,7 +161,7 @@ void e2d::ColliderManager::resume(String name)
} }
} }
void e2d::ColliderManager::stop(String name) void e2d::ColliderManager::stop(const String& name)
{ {
for (auto pListener : s_vListeners) for (auto pListener : s_vListeners)
{ {
@ -215,7 +215,7 @@ e2d::Node* e2d::ColliderManager::isCausedBy(Node * pNode)
return nullptr; return nullptr;
} }
e2d::Node* e2d::ColliderManager::isCausedBy(String name) e2d::Node* e2d::ColliderManager::isCausedBy(const String& name)
{ {
if (s_pActiveNode->getName() == name) if (s_pActiveNode->getName() == name)
return s_pActiveNode; return s_pActiveNode;

View File

@ -7,7 +7,7 @@ class Listener
public: public:
Listener( Listener(
e2d::Function func, e2d::Function func,
e2d::String name, const e2d::String& name,
bool paused bool paused
) )
: name(name) : name(name)
@ -37,13 +37,13 @@ public:
static std::vector<Listener*> s_vListeners; static std::vector<Listener*> s_vListeners;
void e2d::InputManager::add(Function func, String name, bool paused) void e2d::InputManager::add(Function func, const String& name, bool paused)
{ {
auto listener = new Listener(func, name, paused); auto listener = new Listener(func, name, paused);
s_vListeners.push_back(listener); s_vListeners.push_back(listener);
} }
void e2d::InputManager::pause(String name) void e2d::InputManager::pause(const String& name)
{ {
for (auto pListener : s_vListeners) for (auto pListener : s_vListeners)
{ {
@ -54,7 +54,7 @@ void e2d::InputManager::pause(String name)
} }
} }
void e2d::InputManager::resume(String name) void e2d::InputManager::resume(const String& name)
{ {
for (auto pListener : s_vListeners) for (auto pListener : s_vListeners)
{ {
@ -65,7 +65,7 @@ void e2d::InputManager::resume(String name)
} }
} }
void e2d::InputManager::stop(String name) void e2d::InputManager::stop(const String& name)
{ {
for (auto pListener : s_vListeners) for (auto pListener : s_vListeners)
{ {

View File

@ -161,11 +161,11 @@ void e2d::Button::setDisabled(Node * disabled)
} }
} }
void e2d::Button::setEnable(bool bEnable) void e2d::Button::setEnable(bool enable)
{ {
if (m_bEnable != bEnable) if (m_bEnable != enable)
{ {
m_bEnable = bEnable; m_bEnable = enable;
_updateVisiable(); _updateVisiable();
} }
} }

View File

@ -610,7 +610,7 @@ void e2d::Node::setCollider(Collider * pCollider)
} }
} }
void e2d::Node::addColliableName(String collliderName) void e2d::Node::addColliableName(const String& collliderName)
{ {
unsigned int hash = collliderName.getHashCode(); unsigned int hash = collliderName.getHashCode();
m_vColliders.insert(hash); m_vColliders.insert(hash);
@ -626,7 +626,7 @@ void e2d::Node::addColliableName(const InitList<String>& vCollliderName)
} }
#endif #endif
void e2d::Node::removeColliableName(String collliderName) void e2d::Node::removeColliableName(const String& collliderName)
{ {
unsigned int hash = collliderName.getHashCode(); unsigned int hash = collliderName.getHashCode();
m_vColliders.erase(hash); m_vColliders.erase(hash);
@ -692,7 +692,7 @@ e2d::Scene * e2d::Node::getParentScene() const
return m_pParentScene; return m_pParentScene;
} }
std::vector<e2d::Node*> e2d::Node::getChildren(String name) const std::vector<e2d::Node*> e2d::Node::getChildren(const String& name) const
{ {
std::vector<Node*> vChildren; std::vector<Node*> vChildren;
unsigned int hash = name.getHashCode(); unsigned int hash = name.getHashCode();
@ -708,7 +708,7 @@ std::vector<e2d::Node*> e2d::Node::getChildren(String name) const
return std::move(vChildren); return std::move(vChildren);
} }
e2d::Node * e2d::Node::getChild(String name) const e2d::Node * e2d::Node::getChild(const String& name) const
{ {
unsigned int hash = name.getHashCode(); unsigned int hash = name.getHashCode();
@ -777,7 +777,7 @@ bool e2d::Node::removeChild(Node * child)
return false; return false;
} }
void e2d::Node::removeChildren(String childName) void e2d::Node::removeChildren(const String& childName)
{ {
WARN_IF(childName.isEmpty(), "Invalid Node name."); WARN_IF(childName.isEmpty(), "Invalid Node name.");
@ -846,7 +846,7 @@ void e2d::Node::runAction(ActionBase * action)
} }
} }
void e2d::Node::resumeAction(String strActionName) void e2d::Node::resumeAction(const String& strActionName)
{ {
auto actions = ActionManager::get(strActionName); auto actions = ActionManager::get(strActionName);
for (auto action : actions) for (auto action : actions)
@ -858,7 +858,7 @@ void e2d::Node::resumeAction(String strActionName)
} }
} }
void e2d::Node::pauseAction(String strActionName) void e2d::Node::pauseAction(const String& strActionName)
{ {
auto actions = ActionManager::get(strActionName); auto actions = ActionManager::get(strActionName);
for (auto action : actions) for (auto action : actions)
@ -870,7 +870,7 @@ void e2d::Node::pauseAction(String strActionName)
} }
} }
void e2d::Node::stopAction(String strActionName) void e2d::Node::stopAction(const String& strActionName)
{ {
auto actions = ActionManager::get(strActionName); auto actions = ActionManager::get(strActionName);
for (auto action : actions) for (auto action : actions)
@ -882,7 +882,7 @@ void e2d::Node::stopAction(String strActionName)
} }
} }
e2d::ActionBase * e2d::Node::getAction(String strActionName) e2d::ActionBase * e2d::Node::getAction(const String& strActionName)
{ {
auto actions = ActionManager::get(strActionName); auto actions = ActionManager::get(strActionName);
for (auto action : actions) for (auto action : actions)
@ -895,7 +895,7 @@ e2d::ActionBase * e2d::Node::getAction(String strActionName)
return nullptr; return nullptr;
} }
std::vector<e2d::ActionBase*> e2d::Node::getActions(String strActionName) std::vector<e2d::ActionBase*> e2d::Node::getActions(const String& strActionName)
{ {
std::vector<ActionBase*>::iterator iter; std::vector<ActionBase*>::iterator iter;
auto actions = ActionManager::get(strActionName); auto actions = ActionManager::get(strActionName);
@ -1022,9 +1022,9 @@ void e2d::Node::setDefaultPiovt(double defaultPiovtX, double defaultPiovtY)
s_fDefaultPiovtY = min(max(static_cast<float>(defaultPiovtY), 0), 1); s_fDefaultPiovtY = min(max(static_cast<float>(defaultPiovtY), 0), 1);
} }
void e2d::Node::setDefaultColliderEnable(bool bEnable) void e2d::Node::setDefaultColliderEnable(bool enable)
{ {
s_fDefaultColliderEnabled = bEnable; s_fDefaultColliderEnabled = enable;
} }
void e2d::Node::destroy() void e2d::Node::destroy()
@ -1057,7 +1057,7 @@ void e2d::Node::setVisiable(bool value)
m_bVisiable = value; m_bVisiable = value;
} }
void e2d::Node::setName(String name) void e2d::Node::setName(const String& name)
{ {
WARN_IF(name.isEmpty(), "Invalid Node name."); WARN_IF(name.isEmpty(), "Invalid Node name.");

View File

@ -12,26 +12,26 @@ e2d::Sprite::Sprite(Image * image)
open(image); open(image);
} }
e2d::Sprite::Sprite(String strFilePath) e2d::Sprite::Sprite(const String& filePath)
: m_pImage(nullptr) : m_pImage(nullptr)
{ {
open(strFilePath); open(filePath);
} }
e2d::Sprite::Sprite(int resNameId, String resType) e2d::Sprite::Sprite(int resNameId, const String& resType)
: m_pImage(nullptr) : m_pImage(nullptr)
{ {
open(resNameId, resType); open(resNameId, resType);
} }
e2d::Sprite::Sprite(String strFilePath, double x, double y, double width, double height) e2d::Sprite::Sprite(const String& filePath, double x, double y, double width, double height)
: m_pImage(nullptr) : m_pImage(nullptr)
{ {
open(strFilePath); open(filePath);
crop(x, y, width, height); crop(x, y, width, height);
} }
e2d::Sprite::Sprite(int resNameId, String resType, double x, double y, double width, double height) e2d::Sprite::Sprite(int resNameId, const String& resType, double x, double y, double width, double height)
: m_pImage(nullptr) : m_pImage(nullptr)
{ {
open(resNameId, resType); open(resNameId, resType);
@ -56,7 +56,7 @@ bool e2d::Sprite::open(Image * image)
return false; return false;
} }
bool e2d::Sprite::open(String strFilePath) bool e2d::Sprite::open(const String& filePath)
{ {
if (!m_pImage) if (!m_pImage)
{ {
@ -64,7 +64,7 @@ bool e2d::Sprite::open(String strFilePath)
m_pImage->retain(); m_pImage->retain();
} }
if (m_pImage->open(strFilePath)) if (m_pImage->open(filePath))
{ {
Node::setSize(m_pImage->getWidth(), m_pImage->getHeight()); Node::setSize(m_pImage->getWidth(), m_pImage->getHeight());
return true; return true;
@ -72,7 +72,7 @@ bool e2d::Sprite::open(String strFilePath)
return false; return false;
} }
bool e2d::Sprite::open(int resNameId, String resType) bool e2d::Sprite::open(int resNameId, const String& resType)
{ {
if (!m_pImage) if (!m_pImage)
{ {

View File

@ -8,7 +8,7 @@ e2d::Text::Text()
{ {
} }
e2d::Text::Text(String text) e2d::Text::Text(const String& text)
: m_TextStyle() : m_TextStyle()
, m_pDWriteTextLayout(nullptr) , m_pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , m_pDWriteTextFormat(nullptr)
@ -25,7 +25,7 @@ e2d::Text::Text(TextStyle textStyle)
_reset(); _reset();
} }
e2d::Text::Text(String text, TextStyle textStyle) e2d::Text::Text(const String& text, TextStyle textStyle)
: m_TextStyle(textStyle) : m_TextStyle(textStyle)
, m_pDWriteTextLayout(nullptr) , m_pDWriteTextLayout(nullptr)
, m_pDWriteTextFormat(nullptr) , m_pDWriteTextFormat(nullptr)
@ -35,8 +35,8 @@ e2d::Text::Text(String text, TextStyle textStyle)
} }
e2d::Text::Text( e2d::Text::Text(
String text, const String& text,
String fontFamily, const String& fontFamily,
double fontSize, double fontSize,
UINT32 color, UINT32 color,
UINT32 fontWeight, UINT32 fontWeight,
@ -159,7 +159,7 @@ bool e2d::Text::hasOutline() const
return m_TextStyle.hasOutline; return m_TextStyle.hasOutline;
} }
void e2d::Text::setText(String text) void e2d::Text::setText(const String& text)
{ {
m_sText = text; m_sText = text;
_reset(); _reset();
@ -171,7 +171,7 @@ void e2d::Text::setTextStyle(TextStyle textStyle)
_reset(); _reset();
} }
void e2d::Text::setFontFamily(String fontFamily) void e2d::Text::setFontFamily(const String& fontFamily)
{ {
m_TextStyle.fontFamily = fontFamily; m_TextStyle.fontFamily = fontFamily;
_reset(); _reset();

View File

@ -2,54 +2,54 @@
static e2d::String s_sDataFileName = L"DefaultData.ini"; static e2d::String s_sDataFileName = L"DefaultData.ini";
void e2d::Data::saveInt(String key, int value, String field) void e2d::Data::saveInt(const String& key, int value, const String& field)
{ {
::WritePrivateProfileString(field, key, String::parse(value), Data::getDataFilePath()); ::WritePrivateProfileString(field, key, String::parse(value), Data::getDataFilePath());
} }
void e2d::Data::saveDouble(String key, double value, String field) void e2d::Data::saveDouble(const String& key, double value, const String& field)
{ {
::WritePrivateProfileString(field, key, String::parse(value), Data::getDataFilePath()); ::WritePrivateProfileString(field, key, String::parse(value), Data::getDataFilePath());
} }
void e2d::Data::saveBool(String key, bool value, String field) void e2d::Data::saveBool(const String& key, bool value, const String& field)
{ {
const wchar_t* sValue = value ? L"1" : L"0"; const wchar_t* sValue = value ? L"1" : L"0";
::WritePrivateProfileString(field, key, sValue, Data::getDataFilePath()); ::WritePrivateProfileString(field, key, sValue, Data::getDataFilePath());
} }
void e2d::Data::saveString(String key, String value, String field) void e2d::Data::saveString(const String& key, const String& value, const String& field)
{ {
::WritePrivateProfileString(field, key, value, Data::getDataFilePath()); ::WritePrivateProfileString(field, key, value, Data::getDataFilePath());
} }
int e2d::Data::getInt(String key, int defaultValue, String field) int e2d::Data::getInt(const String& key, int defaultValue, const String& field)
{ {
return ::GetPrivateProfileInt(field, key, defaultValue, Data::getDataFilePath()); return ::GetPrivateProfileInt(field, key, defaultValue, Data::getDataFilePath());
} }
double e2d::Data::getDouble(String key, double defaultValue, String field) double e2d::Data::getDouble(const String& key, double defaultValue, const String& field)
{ {
wchar_t temp[32] = { 0 }; wchar_t temp[32] = { 0 };
::GetPrivateProfileString(field, key, String::parse(defaultValue), temp, 31, Data::getDataFilePath()); ::GetPrivateProfileString(field, key, String::parse(defaultValue), temp, 31, Data::getDataFilePath());
return std::stof(temp); return std::stof(temp);
} }
bool e2d::Data::getBool(String key, bool defaultValue, String field) bool e2d::Data::getBool(const String& key, bool defaultValue, const String& field)
{ {
int nDefaultValue = defaultValue ? 1 : 0; int nDefaultValue = defaultValue ? 1 : 0;
int nValue = ::GetPrivateProfileInt(field, key, nDefaultValue, Data::getDataFilePath()); int nValue = ::GetPrivateProfileInt(field, key, nDefaultValue, Data::getDataFilePath());
return nValue != 0; return nValue != 0;
} }
e2d::String e2d::Data::getString(String key, String defaultValue, String field) e2d::String e2d::Data::getString(const String& key, const String& defaultValue, const String& field)
{ {
wchar_t temp[256] = { 0 }; wchar_t temp[256] = { 0 };
::GetPrivateProfileString(field, key, defaultValue, temp, 255, Data::getDataFilePath()); ::GetPrivateProfileString(field, key, defaultValue, temp, 255, Data::getDataFilePath());
return temp; return temp;
} }
void e2d::Data::setDataFileName(String fileName) void e2d::Data::setDataFileName(const String& fileName)
{ {
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {

View File

@ -36,7 +36,7 @@ public:
virtual ~MusicPlayer(); virtual ~MusicPlayer();
bool open( bool open(
const e2d::String& strFileName const e2d::String& filePath
); );
bool MusicPlayer::open( bool MusicPlayer::open(
@ -122,7 +122,7 @@ MusicPlayer::~MusicPlayer()
close(); close();
} }
bool MusicPlayer::open(const e2d::String& strFileName) bool MusicPlayer::open(const e2d::String& filePath)
{ {
if (m_bOpened) if (m_bOpened)
{ {
@ -130,7 +130,7 @@ bool MusicPlayer::open(const e2d::String& strFileName)
return false; return false;
} }
if (strFileName.isEmpty()) if (filePath.isEmpty())
{ {
WARN_IF(true, "MusicInfo::open Invalid file name."); WARN_IF(true, "MusicInfo::open Invalid file name.");
return false; return false;
@ -143,14 +143,14 @@ bool MusicPlayer::open(const e2d::String& strFileName)
} }
// ¶¨Î» wave Îļþ // ¶¨Î» wave Îļþ
wchar_t strFilePath[MAX_PATH]; wchar_t pFilePath[MAX_PATH];
if (!_findMediaFileCch(strFilePath, MAX_PATH, strFileName)) if (!_findMediaFileCch(pFilePath, MAX_PATH, filePath))
{ {
WARN_IF(true, "Failed to find media file: %s", (const wchar_t*)strFileName); WARN_IF(true, "Failed to find media file: %s", pFilePath);
return false; return false;
} }
m_hmmio = mmioOpen(strFilePath, nullptr, MMIO_ALLOCBUF | MMIO_READ); m_hmmio = mmioOpen(pFilePath, nullptr, MMIO_ALLOCBUF | MMIO_READ);
if (nullptr == m_hmmio) if (nullptr == m_hmmio)
{ {
@ -605,9 +605,9 @@ bool MusicPlayer::_findMediaFileCch(wchar_t* strDestPath, int cchDest, const wch
} }
bool e2d::Music::preload(String strFilePath) bool e2d::Music::preload(const String& filePath)
{ {
UINT nRet = strFilePath.getHashCode(); UINT nRet = filePath.getHashCode();
if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) if (GetMusicFileList().end() != GetMusicFileList().find(nRet))
{ {
@ -617,7 +617,7 @@ bool e2d::Music::preload(String strFilePath)
{ {
MusicPlayer * pPlayer = new (std::nothrow) MusicPlayer(); MusicPlayer * pPlayer = new (std::nothrow) MusicPlayer();
if (pPlayer->open(strFilePath)) if (pPlayer->open(filePath))
{ {
pPlayer->setVolume(s_fMusicVolume); pPlayer->setVolume(s_fMusicVolume);
GetMusicFileList().insert(std::pair<UINT, MusicPlayer *>(nRet, pPlayer)); GetMusicFileList().insert(std::pair<UINT, MusicPlayer *>(nRet, pPlayer));
@ -632,7 +632,7 @@ bool e2d::Music::preload(String strFilePath)
return false; return false;
} }
bool e2d::Music::preload(int resNameId, String resType) bool e2d::Music::preload(int resNameId, const String& resType)
{ {
if (GetMusicResList().end() != GetMusicResList().find(resNameId)) if (GetMusicResList().end() != GetMusicResList().find(resNameId))
{ {
@ -657,11 +657,11 @@ bool e2d::Music::preload(int resNameId, String resType)
return false; return false;
} }
bool e2d::Music::play(String strFilePath, int nLoopCount) bool e2d::Music::play(const String& filePath, int nLoopCount)
{ {
if (Music::preload(strFilePath)) if (Music::preload(filePath))
{ {
UINT nRet = strFilePath.getHashCode(); UINT nRet = filePath.getHashCode();
auto pMusic = GetMusicFileList()[nRet]; auto pMusic = GetMusicFileList()[nRet];
if (pMusic->play(nLoopCount)) if (pMusic->play(nLoopCount))
{ {
@ -671,7 +671,7 @@ bool e2d::Music::play(String strFilePath, int nLoopCount)
return false; return false;
} }
bool e2d::Music::play(int resNameId, String resType, int nLoopCount) bool e2d::Music::play(int resNameId, const String& resType, int nLoopCount)
{ {
if (Music::preload(resNameId, resType)) if (Music::preload(resNameId, resType))
{ {
@ -684,63 +684,63 @@ bool e2d::Music::play(int resNameId, String resType, int nLoopCount)
return false; return false;
} }
void e2d::Music::pause(String strFilePath) void e2d::Music::pause(const String& filePath)
{ {
if (strFilePath.isEmpty()) if (filePath.isEmpty())
return; return;
UINT nRet = strFilePath.getHashCode(); UINT nRet = filePath.getHashCode();
if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) if (GetMusicFileList().end() != GetMusicFileList().find(nRet))
GetMusicFileList()[nRet]->pause(); GetMusicFileList()[nRet]->pause();
} }
void e2d::Music::pause(int resNameId, String resType) void e2d::Music::pause(int resNameId, const String& resType)
{ {
if (GetMusicResList().end() != GetMusicResList().find(resNameId)) if (GetMusicResList().end() != GetMusicResList().find(resNameId))
GetMusicResList()[resNameId]->pause(); GetMusicResList()[resNameId]->pause();
} }
void e2d::Music::resume(String strFilePath) void e2d::Music::resume(const String& filePath)
{ {
if (strFilePath.isEmpty()) if (filePath.isEmpty())
return; return;
UINT nRet = strFilePath.getHashCode(); UINT nRet = filePath.getHashCode();
if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) if (GetMusicFileList().end() != GetMusicFileList().find(nRet))
GetMusicFileList()[nRet]->resume(); GetMusicFileList()[nRet]->resume();
} }
void e2d::Music::resume(int resNameId, String resType) void e2d::Music::resume(int resNameId, const String& resType)
{ {
if (GetMusicResList().end() != GetMusicResList().find(resNameId)) if (GetMusicResList().end() != GetMusicResList().find(resNameId))
GetMusicResList()[resNameId]->pause(); GetMusicResList()[resNameId]->pause();
} }
void e2d::Music::stop(String strFilePath) void e2d::Music::stop(const String& filePath)
{ {
if (strFilePath.isEmpty()) if (filePath.isEmpty())
return; return;
UINT nRet = strFilePath.getHashCode(); UINT nRet = filePath.getHashCode();
if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) if (GetMusicFileList().end() != GetMusicFileList().find(nRet))
GetMusicFileList()[nRet]->stop(); GetMusicFileList()[nRet]->stop();
} }
void e2d::Music::stop(int resNameId, String resType) void e2d::Music::stop(int resNameId, const String& resType)
{ {
if (GetMusicResList().end() != GetMusicResList().find(resNameId)) if (GetMusicResList().end() != GetMusicResList().find(resNameId))
GetMusicResList()[resNameId]->stop(); GetMusicResList()[resNameId]->stop();
} }
bool e2d::Music::isPlaying(String strFilePath) bool e2d::Music::isPlaying(const String& filePath)
{ {
if (strFilePath.isEmpty()) if (filePath.isEmpty())
return false; return false;
UINT nRet = strFilePath.getHashCode(); UINT nRet = filePath.getHashCode();
if (GetMusicFileList().end() != GetMusicFileList().find(nRet)) if (GetMusicFileList().end() != GetMusicFileList().find(nRet))
return GetMusicFileList()[nRet]->isPlaying(); return GetMusicFileList()[nRet]->isPlaying();
@ -748,7 +748,7 @@ bool e2d::Music::isPlaying(String strFilePath)
return false; return false;
} }
bool e2d::Music::isPlaying(int resNameId, String resType) bool e2d::Music::isPlaying(int resNameId, const String& resType)
{ {
if (GetMusicResList().end() != GetMusicResList().find(resNameId)) if (GetMusicResList().end() != GetMusicResList().find(resNameId))
return GetMusicResList()[resNameId]->isPlaying(); return GetMusicResList()[resNameId]->isPlaying();

View File

@ -129,7 +129,7 @@ e2d::String e2d::Path::getDefaultSavePath()
return s_sDefaultSavePath; return s_sDefaultSavePath;
} }
e2d::String e2d::Path::getFileExtension(String filePath) e2d::String e2d::Path::getFileExtension(const String& filePath)
{ {
String fileExtension; String fileExtension;
// 找到文件名中的最后一个 '.' 的位置 // 找到文件名中的最后一个 '.' 的位置
@ -146,7 +146,7 @@ e2d::String e2d::Path::getFileExtension(String filePath)
return fileExtension; return fileExtension;
} }
e2d::String e2d::Path::getSaveFilePath(const String title, const String defExt) e2d::String e2d::Path::getSaveFilePath(const String& title, const String& defExt)
{ {
// 弹出保存对话框 // 弹出保存对话框
OPENFILENAME ofn = { 0 }; OPENFILENAME ofn = { 0 };
@ -169,17 +169,17 @@ e2d::String e2d::Path::getSaveFilePath(const String title, const String defExt)
return L""; return L"";
} }
bool e2d::Path::createFolder(String strDirPath) bool e2d::Path::createFolder(const String& dirPath)
{ {
if (strDirPath.isEmpty()) if (dirPath.isEmpty())
{ {
WARN_IF(true, "Path::createFolder Failed: Invalid directory path!"); WARN_IF(true, "Path::createFolder Failed: Invalid directory path!");
return false; return false;
} }
if (-1 == ::_waccess(strDirPath, 0)) if (-1 == ::_waccess(dirPath, 0))
{ {
if (0 != ::_wmkdir(strDirPath)) if (0 != ::_wmkdir(dirPath))
{ {
return false; return false;
} }

View File

@ -6,7 +6,7 @@ class TimerInfo
public: public:
TimerInfo( TimerInfo(
e2d::Function func, e2d::Function func,
e2d::String name, const e2d::String& name,
double delay, double delay,
int updateTimes, int updateTimes,
bool paused bool paused
@ -65,13 +65,13 @@ public:
static std::vector<TimerInfo*> s_vTimers; static std::vector<TimerInfo*> s_vTimers;
void e2d::Timer::start(Function func, double delay, int updateTimes, bool paused, String name) void e2d::Timer::start(Function func, double delay, int updateTimes, bool paused, const String& name)
{ {
auto timer = new TimerInfo(func, name, delay, updateTimes, paused); auto timer = new TimerInfo(func, name, delay, updateTimes, paused);
s_vTimers.push_back(timer); s_vTimers.push_back(timer);
} }
void e2d::Timer::start(Function func, String name) void e2d::Timer::start(Function func, const String& name)
{ {
Timer::start(func, 0, -1, false, name); Timer::start(func, 0, -1, false, name);
} }
@ -82,7 +82,7 @@ void e2d::Timer::startOnce(Function func, double timeOut)
s_vTimers.push_back(timer); s_vTimers.push_back(timer);
} }
void e2d::Timer::pause(String name) void e2d::Timer::pause(const String& name)
{ {
for (auto timer : s_vTimers) for (auto timer : s_vTimers)
{ {
@ -93,7 +93,7 @@ void e2d::Timer::pause(String name)
} }
} }
void e2d::Timer::resume(String name) void e2d::Timer::resume(const String& name)
{ {
for (auto timer : s_vTimers) for (auto timer : s_vTimers)
{ {
@ -104,7 +104,7 @@ void e2d::Timer::resume(String name)
} }
} }
void e2d::Timer::stop(String name) void e2d::Timer::stop(const String& name)
{ {
for (auto timer : s_vTimers) for (auto timer : s_vTimers)
{ {

View File

@ -189,7 +189,7 @@ public:
// 设置动作名称 // 设置动作名称
virtual void setName( virtual void setName(
String name const String& name
); );
// 获取一个新的逆向动作 // 获取一个新的逆向动作

View File

@ -14,12 +14,12 @@ class Game
public: public:
// 初始化游戏 // 初始化游戏
static bool init( static bool init(
String sGameName = L"" /* 游戏英文名称 */ const String& name = L"" /* 游戏英文名称 */
); );
// 启动游戏 // 启动游戏
static int start( static int start(
bool bAutoRelease = true bool autoRelease = true /* 游戏结束时自动回收资源 */
); );
// 暂停游戏 // 暂停游戏
@ -39,8 +39,8 @@ public:
// 创建进程互斥体 // 创建进程互斥体
static bool createMutex( static bool createMutex(
String sMutexName, /* 互斥体名称 */ const String& sMutexName, /* 互斥体名称 */
String sWindowTitle = L"" /* 窗口标题 */ const String& sWindowTitle = L"" /* 窗口标题 */
); );
// 获取游戏名称 // 获取游戏名称
@ -56,18 +56,18 @@ class Window
public: public:
// 修改窗口大小 // 修改窗口大小
static void setSize( static void setSize(
int nWidth, /* 窗口宽度 */ int width, /* 窗口宽度 */
int nHeight /* 窗口高度 */ int height /* 窗口高度 */
); );
// 设置窗口标题 // 设置窗口标题
static void setTitle( static void setTitle(
String sTitle /* 窗口标题 */ const String& title /* 窗口标题 */
); );
// 设置窗口图标 // 设置窗口图标
static void setIcon( static void setIcon(
int pIconID int iconID
); );
// 获取窗口标题 // 获取窗口标题
@ -92,7 +92,7 @@ public:
// 是否允许响应输入法 // 是否允许响应输入法
static void setTypewritingEnable( static void setTypewritingEnable(
bool bEnable bool enable
); );
private: private:

View File

@ -33,7 +33,7 @@ public:
// 启用或关闭该碰撞体 // 启用或关闭该碰撞体
virtual void setEnable( virtual void setEnable(
bool bEnable bool enable
); );
// 设置碰撞体的可见性 // 设置碰撞体的可见性
@ -48,7 +48,7 @@ public:
// 设置大小跟随 // 设置大小跟随
void setAutoResize( void setAutoResize(
bool bEnable bool enable
); );
// 获取 ID2D1Geometry 对象 // 获取 ID2D1Geometry 对象

View File

@ -497,7 +497,7 @@ struct TextStyle
TextStyle(); TextStyle();
TextStyle( TextStyle(
String fontFamily, const String& fontFamily,
double fontSize = 22, double fontSize = 22,
Color color = Color::WHITE, Color color = Color::WHITE,
UINT32 fontWeight = FontWeight::NORMAL, UINT32 fontWeight = FontWeight::NORMAL,
@ -610,53 +610,53 @@ public:
// 加载图片文件 // 加载图片文件
Image( Image(
String strFilePath /* 图片文件路径 */ const String& filePath /* 图片文件路径 */
); );
// 加载图片资源 // 加载图片资源
Image( Image(
int resNameId, /* 图片资源名称 */ int resNameId, /* 图片资源名称 */
String resType /* 图片资源类型 */ const String& resType /* 图片资源类型 */
); );
// 加载图片文件并裁剪 // 加载图片文件并裁剪
Image( Image(
String strFilePath, /* 图片文件路径 */ const String& filePath, /* 图片文件路径 */
double nCropX, /* 裁剪位置 X 坐标 */ double cropX, /* 裁剪位置 X 坐标 */
double nCropY, /* 裁剪位置 Y 坐标 */ double cropY, /* 裁剪位置 Y 坐标 */
double nCropWidth, /* 裁剪宽度 */ double cropWidth, /* 裁剪宽度 */
double nCropHeight /* 裁剪高度 */ double cropHeight /* 裁剪高度 */
); );
// 加载图片资源并裁剪 // 加载图片资源并裁剪
Image( Image(
int resNameId, /* 图片资源名称 */ int resNameId, /* 图片资源名称 */
String resType, /* 图片资源类型 */ const String& resType, /* 图片资源类型 */
double nCropX, /* 裁剪位置 X 坐标 */ double cropX, /* 裁剪位置 X 坐标 */
double nCropY, /* 裁剪位置 Y 坐标 */ double cropY, /* 裁剪位置 Y 坐标 */
double nCropWidth, /* 裁剪宽度 */ double cropWidth, /* 裁剪宽度 */
double nCropHeight /* 裁剪高度 */ double cropHeight /* 裁剪高度 */
); );
virtual ~Image(); virtual ~Image();
// 加载图片文件 // 加载图片文件
bool open( bool open(
String strFilePath const String& filePath
); );
// 加载图片资源 // 加载图片资源
bool open( bool open(
int resNameId, /* 图片资源名称 */ int resNameId, /* 图片资源名称 */
String resType /* 图片资源类型 */ const String& resType /* 图片资源类型 */
); );
// 将图片裁剪为矩形 // 将图片裁剪为矩形
void crop( void crop(
double nCropX, /* 裁剪位置 X 坐标 */ double cropX, /* 裁剪位置 X 坐标 */
double nCropY, /* 裁剪位置 Y 坐标 */ double cropY, /* 裁剪位置 Y 坐标 */
double nCropWidth, /* 裁剪宽度 */ double cropWidth, /* 裁剪宽度 */
double nCropHeight /* 裁剪高度 */ double cropHeight /* 裁剪高度 */
); );
// 获取宽度 // 获取宽度
@ -691,13 +691,13 @@ public:
// 预加载图片文件 // 预加载图片文件
static bool preload( static bool preload(
String strFileName /* 图片文件路径 */ const String& filePath /* 图片文件路径 */
); );
// 预加载图片资源 // 预加载图片资源
static bool preload( static bool preload(
int resNameId, /* 图片资源名称 */ int resNameId, /* 图片资源名称 */
String resType /* 图片资源类型 */ const String& resType /* 图片资源类型 */
); );
// 清空缓存 // 清空缓存
@ -772,12 +772,12 @@ public:
// 获取所有名称相同的子节点 // 获取所有名称相同的子节点
std::vector<Node*> get( std::vector<Node*> get(
String name const String& name
) const; ) const;
// 获取名称相同的子节点 // 获取名称相同的子节点
Node* getOne( Node* getOne(
String name const String& name
) const; ) const;
// 获取所有子节点 // 获取所有子节点

View File

@ -95,17 +95,17 @@ class ActionManager
public: public:
// 继续名称相同的所有动作 // 继续名称相同的所有动作
static void resume( static void resume(
String strActionName const String& strActionName
); );
// 暂停名称相同的所有动作 // 暂停名称相同的所有动作
static void pause( static void pause(
String strActionName const String& strActionName
); );
// 停止名称相同的所有动作 // 停止名称相同的所有动作
static void stop( static void stop(
String strActionName const String& strActionName
); );
// 继续所有动作 // 继续所有动作
@ -119,7 +119,7 @@ public:
// 获取所有名称相同的动作 // 获取所有名称相同的动作
static std::vector<ActionBase *> get( static std::vector<ActionBase *> get(
String strActionName const String& strActionName
); );
// 获取所有动作 // 获取所有动作
@ -182,24 +182,24 @@ class InputManager
public: public:
// 添加输入监听 // 添加输入监听
static void add( static void add(
Function func, /* 监听到用户输入时的执行函数 */ Function func, /* 监听到用户输入时的执行函数 */
String name = L"", /* 监听器名称 */ const String& name = L"", /* 监听器名称 */
bool paused = false /* 是否暂停 */ bool paused = false /* 是否暂停 */
); );
// 暂停输入监听 // 暂停输入监听
static void pause( static void pause(
String name const String& name
); );
// 暂停输入监听 // 暂停输入监听
static void resume( static void resume(
String name const String& name
); );
// 停止输入监听 // 停止输入监听
static void stop( static void stop(
String name const String& name
); );
// 暂停所有监听器 // 暂停所有监听器
@ -230,29 +230,29 @@ class ColliderManager
public: public:
// 开启或关闭碰撞监听功能(默认关闭) // 开启或关闭碰撞监听功能(默认关闭)
static void setEnable( static void setEnable(
bool bEnable bool enable
); );
// 添加碰撞监听 // 添加碰撞监听
static void add( static void add(
Function func, /* 监听到碰撞时的执行函数 */ Function func, /* 监听到碰撞时的执行函数 */
String name = L"", /* 监听器名称 */ const String& name = L"", /* 监听器名称 */
bool paused = false /* 是否暂停 */ bool paused = false /* 是否暂停 */
); );
// 暂停碰撞监听 // 暂停碰撞监听
static void pause( static void pause(
String name const String& name
); );
// 暂停碰撞监听 // 暂停碰撞监听
static void resume( static void resume(
String name const String& name
); );
// 停止碰撞监听 // 停止碰撞监听
static void stop( static void stop(
String name const String& name
); );
// 暂停所有监听器 // 暂停所有监听器
@ -270,14 +270,16 @@ public:
// 获取碰撞发生时的被动体 // 获取碰撞发生时的被动体
static Node * getPassiveNode(); static Node * getPassiveNode();
// 判断碰撞是否由该节点引发(如果是,返回与其相撞的节点指针,否则返回空) // 判断碰撞是否由该节点引发
// 如果是,返回与其相撞的节点指针,否则返回空
static Node * isCausedBy( static Node * isCausedBy(
Node * pNode Node * pNode
); );
// 判断发生碰撞的节点名称是否相同(若相同返回其指针,否则返回空) // 判断发生碰撞的节点名称是否相同
// 若相同,返回其指针,否则返回空
static Node * isCausedBy( static Node * isCausedBy(
String name const String& name
); );
private: private:

View File

@ -130,12 +130,12 @@ public:
// 获取所有名称相同的子节点 // 获取所有名称相同的子节点
virtual std::vector<Node*> getChildren( virtual std::vector<Node*> getChildren(
String name const String& name
) const; ) const;
// 获取名称相同的子节点 // 获取名称相同的子节点
virtual Node* getChild( virtual Node* getChild(
String name const String& name
) const; ) const;
// 获取所有子节点 // 获取所有子节点
@ -151,7 +151,7 @@ public:
// 移除所有名称相同的子节点 // 移除所有名称相同的子节点
virtual void removeChildren( virtual void removeChildren(
String childName const String& childName
); );
// 从父节点移除 // 从父节点移除
@ -172,7 +172,7 @@ public:
// 设置节点名称 // 设置节点名称
virtual void setName( virtual void setName(
String name const String& name
); );
// 设置节点横坐标 // 设置节点横坐标
@ -336,7 +336,7 @@ public:
// 添加可碰撞节点的名称 // 添加可碰撞节点的名称
virtual void addColliableName( virtual void addColliableName(
String collliderName const String& collliderName
); );
#ifdef HIGHER_THAN_VS2012 #ifdef HIGHER_THAN_VS2012
@ -348,7 +348,7 @@ public:
// 移除可碰撞节点的名称 // 移除可碰撞节点的名称
virtual void removeColliableName( virtual void removeColliableName(
String collliderName const String& collliderName
); );
// 添加子节点 // 添加子节点
@ -372,27 +372,27 @@ public:
// 继续动画 // 继续动画
virtual void resumeAction( virtual void resumeAction(
String strActionName const String& strActionName
); );
// 暂停动画 // 暂停动画
virtual void pauseAction( virtual void pauseAction(
String strActionName const String& strActionName
); );
// 停止动画 // 停止动画
virtual void stopAction( virtual void stopAction(
String strActionName const String& strActionName
); );
// 获取名称相同的动画 // 获取名称相同的动画
virtual ActionBase * getAction( virtual ActionBase * getAction(
String strActionName const String& strActionName
); );
// 获取所有名称相同的动画 // 获取所有名称相同的动画
virtual std::vector<ActionBase*> getActions( virtual std::vector<ActionBase*> getActions(
String strActionName const String& strActionName
); );
// 继续所有暂停动画 // 继续所有暂停动画
@ -412,7 +412,7 @@ public:
// 设置节点是否包含默认碰撞体(默认打开) // 设置节点是否包含默认碰撞体(默认打开)
static void setDefaultColliderEnable( static void setDefaultColliderEnable(
bool bEnable bool enable
); );
// 销毁对象 // 销毁对象
@ -494,18 +494,18 @@ public:
// 加载图片文件 // 加载图片文件
Sprite( Sprite(
String strFilePath /* 图片文件路径 */ const String& filePath /* 图片文件路径 */
); );
// 加载图片资源 // 加载图片资源
Sprite( Sprite(
int resNameId, /* 图片资源名称 */ int resNameId, /* 图片资源名称 */
String resType /* 图片资源类型 */ const String& resType /* 图片资源类型 */
); );
// 加载图片文件 // 加载图片文件
Sprite( Sprite(
String strFilePath, /* 图片文件路径 */ const String& filePath, /* 图片文件路径 */
double x, double x,
double y, double y,
double width, double width,
@ -514,8 +514,8 @@ public:
// 加载图片资源 // 加载图片资源
Sprite( Sprite(
int resNameId, /* 图片资源名称 */ int resNameId, /* 图片资源名称 */
String resType, /* 图片资源类型 */ const String& resType, /* 图片资源类型 */
double x, double x,
double y, double y,
double width, double width,
@ -526,13 +526,13 @@ public:
// 加载图片文件 // 加载图片文件
bool open( bool open(
String strFilePath const String& filePath
); );
// 加载图片资源 // 加载图片资源
bool open( bool open(
int resNameId, /* 图片资源名称 */ int resNameId, /* 图片资源名称 */
String resType /* 图片资源类型 */ const String& resType /* 图片资源类型 */
); );
// 加载图片 // 加载图片
@ -569,21 +569,21 @@ public:
Text(); Text();
Text( Text(
String text /* 文字内容 */ const String& text /* 文字内容 */
); );
Text( Text(
TextStyle textStyle /* 文字样式 */ TextStyle textStyle /* 文字样式 */
); );
Text( Text(
String text, /* 文字内容 */ const String& text, /* 文字内容 */
TextStyle textStyle /* 文字样式 */ TextStyle textStyle /* 文字样式 */
); );
Text( Text(
String text, /* 文字内容*/ const String& text, /* 文字内容*/
String fontFamily, /* 字体 */ const String& fontFamily, /* 字体 */
double fontSize = 22, /* 字号 */ double fontSize = 22, /* 字号 */
UINT32 color = Color::WHITE, /* 颜色 */ UINT32 color = Color::WHITE, /* 颜色 */
UINT32 fontWeight = FontWeight::NORMAL, /* 粗细值 */ UINT32 fontWeight = FontWeight::NORMAL, /* 粗细值 */
@ -645,7 +645,7 @@ public:
// 设置文本 // 设置文本
void setText( void setText(
String text const String& text
); );
// 设置文本样式 // 设置文本样式
@ -655,7 +655,7 @@ public:
// 设置字体 // 设置字体
void setFontFamily( void setFontFamily(
String fontFamily const String& fontFamily
); );
// 设置字号(默认值为 22 // 设置字号(默认值为 22
@ -791,7 +791,7 @@ public:
// 设置按钮启用或禁用 // 设置按钮启用或禁用
void setEnable( void setEnable(
bool bEnable bool enable
); );
// 设置一般情况下显示的按钮 // 设置一般情况下显示的按钮

View File

@ -60,70 +60,70 @@ class Music :
public: public:
// 预加载音乐资源 // 预加载音乐资源
static bool preload( static bool preload(
String strFilePath /* 音乐文件路径 */ const String& filePath /* 音乐文件路径 */
); );
// 预加载音乐资源 // 预加载音乐资源
static bool preload( static bool preload(
int resNameId, /* 音乐资源名称 */ int resNameId, /* 音乐资源名称 */
String resType /* 音乐资源类型 */ const String& resType /* 音乐资源类型 */
); );
// 播放音乐 // 播放音乐
static bool play( static bool play(
String strFilePath, /* 音乐文件路径 */ const String& filePath, /* 音乐文件路径 */
int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */ int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */
); );
// 播放音乐 // 播放音乐
static bool play( static bool play(
int resNameId, /* 音乐资源名称 */ int resNameId, /* 音乐资源名称 */
String resType, /* 音乐资源类型 */ const String& resType, /* 音乐资源类型 */
int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */ int nLoopCount = 0 /* 重复播放次数,设置 -1 为循环播放 */
); );
// 暂停音乐 // 暂停音乐
static void pause( static void pause(
String strFilePath /* 音乐文件路径 */ const String& filePath /* 音乐文件路径 */
); );
// 暂停音乐 // 暂停音乐
static void pause( static void pause(
int resNameId, /* 音乐资源名称 */ int resNameId, /* 音乐资源名称 */
String resType /* 音乐资源类型 */ const String& resType /* 音乐资源类型 */
); );
// 继续播放音乐 // 继续播放音乐
static void resume( static void resume(
String strFilePath /* 音乐文件路径 */ const String& filePath /* 音乐文件路径 */
); );
// 继续播放音乐 // 继续播放音乐
static void resume( static void resume(
int resNameId, /* 音乐资源名称 */ int resNameId, /* 音乐资源名称 */
String resType /* 音乐资源类型 */ const String& resType /* 音乐资源类型 */
); );
// 停止音乐 // 停止音乐
static void stop( static void stop(
String strFilePath /* 音乐文件路径 */ const String& filePath /* 音乐文件路径 */
); );
// 停止音乐 // 停止音乐
static void stop( static void stop(
int resNameId, /* 音乐资源名称 */ int resNameId, /* 音乐资源名称 */
String resType /* 音乐资源类型 */ const String& resType /* 音乐资源类型 */
); );
// 获取音乐播放状态 // 获取音乐播放状态
static bool isPlaying( static bool isPlaying(
String strFilePath /* 音乐文件路径 */ const String& filePath /* 音乐文件路径 */
); );
// 获取音乐播放状态 // 获取音乐播放状态
static bool isPlaying( static bool isPlaying(
int resNameId, /* 音乐资源名称 */ int resNameId, /* 音乐资源名称 */
String resType /* 音乐资源类型 */ const String& resType /* 音乐资源类型 */
); );
// 获取音量 // 获取音量
@ -131,7 +131,7 @@ public:
// 设置音量 // 设置音量
static void setVolume( static void setVolume(
double fVolume /* 音量范围为 -224 ~ 224其中 0 是静音1 是正常音量 */ double fVolume /* 音量范围为 -224 ~ 2240 是静音1 是正常音量 */
); );
// 暂停所有音乐 // 暂停所有音乐
@ -164,38 +164,38 @@ class Timer
public: public:
// 启动定时器 // 启动定时器
static void start( static void start(
Function func, /* 执行函数 */ Function func, /* 执行函数 */
String name /* 定时器名称 */ const String& name /* 定时器名称 */
); );
// 启动定时器 // 启动定时器
static void start( static void start(
Function func, /* 执行函数 */ Function func, /* 执行函数 */
double delay = 0, /* 时间间隔(秒) */ double delay = 0, /* 时间间隔(秒) */
int times = -1, /* 执行次数(设 -1 为永久执行) */ int times = -1, /* 执行次数(设 -1 为永久执行) */
bool paused = false, /* 是否暂停 */ bool paused = false, /* 是否暂停 */
String name = L"" /* 定时器名称 */ const String& name = L"" /* 定时器名称 */
); );
// 启动仅执行一次的定时器 // 启动仅执行一次的定时器
static void startOnce( static void startOnce(
Function func, /* 执行的函数 */ Function func, /* 执行的函数 */
double timeOut /* 等待的时长(秒) */ double timeOut /* 等待的时长(秒) */
); );
// 暂停具有相同名称的定时器 // 暂停具有相同名称的定时器
static void pause( static void pause(
String name const String& name
); );
// 继续具有相同名称的定时器 // 继续具有相同名称的定时器
static void resume( static void resume(
String name const String& name
); );
// 停止具有相同名称的定时器 // 停止具有相同名称的定时器
static void stop( static void stop(
String name const String& name
); );
// 暂停所有定时器 // 暂停所有定时器
@ -225,67 +225,67 @@ class Data
public: public:
// 保存 int 类型的值 // 保存 int 类型的值
static void saveInt( static void saveInt(
String key, /* 键值 */ const String& key, /* 键值 */
int value, /* 数据 */ int value, /* 数据 */
String field = L"Defalut" /* 字段名称 */ const String& field = L"Defalut" /* 字段名称 */
); );
// 保存 double 类型的值 // 保存 double 类型的值
static void saveDouble( static void saveDouble(
String key, /* 键值 */ const String& key, /* 键值 */
double value, /* 数据 */ double value, /* 数据 */
String field = L"Defalut" /* 字段名称 */ const String& field = L"Defalut" /* 字段名称 */
); );
// 保存 bool 类型的值 // 保存 bool 类型的值
static void saveBool( static void saveBool(
String key, /* 键值 */ const String& key, /* 键值 */
bool value, /* 数据 */ bool value, /* 数据 */
String field = L"Defalut" /* 字段名称 */ const String& field = L"Defalut" /* 字段名称 */
); );
// 保存 字符串 类型的值 // 保存 字符串 类型的值
static void saveString( static void saveString(
String key, /* 键值 */ const String& key, /* 键值 */
String value, /* 数据 */ const String& value, /* 数据 */
String field = L"Defalut" /* 字段名称 */ const String& field = L"Defalut" /* 字段名称 */
); );
// 获取 int 类型的值 // 获取 int 类型的值
// (若不存在则返回 defaultValue 参数的值) // (若不存在则返回 defaultValue 参数的值)
static int getInt( static int getInt(
String key, /* 键值 */ const String& key, /* 键值 */
int defaultValue, /* 默认值 */ int defaultValue, /* 默认值 */
String field = L"Defalut" /* 字段名称 */ const String& field = L"Defalut" /* 字段名称 */
); );
// 获取 double 类型的值 // 获取 double 类型的值
// (若不存在则返回 defaultValue 参数的值) // (若不存在则返回 defaultValue 参数的值)
static double getDouble( static double getDouble(
String key, /* 键值 */ const String& key, /* 键值 */
double defaultValue, /* 默认值 */ double defaultValue, /* 默认值 */
String field = L"Defalut" /* 字段名称 */ const String& field = L"Defalut" /* 字段名称 */
); );
// 获取 bool 类型的值 // 获取 bool 类型的值
// (若不存在则返回 defaultValue 参数的值) // (若不存在则返回 defaultValue 参数的值)
static bool getBool( static bool getBool(
String key, /* 键值 */ const String& key, /* 键值 */
bool defaultValue, /* 默认值 */ bool defaultValue, /* 默认值 */
String field = L"Defalut" /* 字段名称 */ const String& field = L"Defalut" /* 字段名称 */
); );
// 获取 字符串 类型的值 // 获取 字符串 类型的值
// (若不存在则返回 defaultValue 参数的值) // (若不存在则返回 defaultValue 参数的值)
static String getString( static String getString(
String key, /* 键值 */ const String& key, /* 键值 */
String defaultValue, /* 默认值 */ const String& defaultValue, /* 默认值 */
String field = L"Defalut" /* 字段名称 */ const String& field = L"Defalut" /* 字段名称 */
); );
// 修改数据文件的名称 // 修改数据文件的名称
static void setDataFileName( static void setDataFileName(
String strFileName /* 文件名称 */ const String& filePath /* 文件名称 */
); );
// 获取数据文件的完整路径 // 获取数据文件的完整路径
@ -307,18 +307,18 @@ public:
// 获取文件扩展名 // 获取文件扩展名
static String getFileExtension( static String getFileExtension(
String filePath const String& filePath
); );
// 打开保存文件对话框 // 打开保存文件对话框
static String getSaveFilePath( static String getSaveFilePath(
const String title = L"保存到", /* 对话框标题 */ const String& title = L"保存到", /* 对话框标题 */
const String defExt = L"" /* 默认扩展名 */ const String& defExt = L"" /* 默认扩展名 */
); );
// 创建文件夹 // 创建文件夹
static bool createFolder( static bool createFolder(
String strDirPath /* 文件夹路径 */ const String& dirPath /* 文件夹路径 */
); );
private: private: