代码优化
This commit is contained in:
parent
4540520acc
commit
a370685dd0
|
|
@ -207,7 +207,7 @@ void e2d::Renderer::endDraw()
|
||||||
|
|
||||||
e2d::Color e2d::Renderer::getBackgroundColor()
|
e2d::Color e2d::Renderer::getBackgroundColor()
|
||||||
{
|
{
|
||||||
return Color(_clearColor.r, _clearColor.g, _clearColor.b, _clearColor.a);
|
return _clearColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Renderer::setBackgroundColor(Color color)
|
void e2d::Renderer::setBackgroundColor(Color color)
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ bool e2d::Image::preload(const Resource& res)
|
||||||
|
|
||||||
bool e2d::Image::preload(const String & fileName)
|
bool e2d::Image::preload(const String & fileName)
|
||||||
{
|
{
|
||||||
String actualFilePath = File(fileName).getFilePath();
|
String actualFilePath = File(fileName).getPath();
|
||||||
if (actualFilePath.isEmpty())
|
if (actualFilePath.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
if (Old) this->removeChild(Old); \
|
if (Old) this->removeChild(Old); \
|
||||||
if (New) \
|
if (New) \
|
||||||
{ \
|
{ \
|
||||||
New->setPivot(_pivotX, _pivotY); \
|
New->setAnchor(_anchorX, _anchorY); \
|
||||||
this->addChild(New); \
|
this->addChild(New); \
|
||||||
} \
|
} \
|
||||||
Old = New; \
|
Old = New; \
|
||||||
|
|
@ -134,13 +134,13 @@ void e2d::Button::setClickFunc(const Function& func)
|
||||||
_func = func;
|
_func = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Button::setPivot(float pivotX, float pivotY)
|
void e2d::Button::setAnchor(float anchorX, float anchorY)
|
||||||
{
|
{
|
||||||
Node::setPivot(pivotX, pivotY);
|
Node::setAnchor(anchorX, anchorY);
|
||||||
SAFE_SET(_normal, setPivot, pivotX, pivotY);
|
SAFE_SET(_normal, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_mouseover, setPivot, pivotX, pivotY);
|
SAFE_SET(_mouseover, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_selected, setPivot, pivotX, pivotY);
|
SAFE_SET(_selected, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_disabled, setPivot, pivotX, pivotY);
|
SAFE_SET(_disabled, setAnchor, anchorX, anchorY);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Button::dispatch(const MouseEvent & e, bool handled)
|
bool e2d::Button::dispatch(const MouseEvent & e, bool handled)
|
||||||
|
|
|
||||||
|
|
@ -71,14 +71,14 @@ void e2d::Canvas::setStrokeStyle(Stroke strokeStyle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Color & e2d::Canvas::getLineColor() const
|
e2d::Color e2d::Canvas::getLineColor() const
|
||||||
{
|
{
|
||||||
return Color(_lineBrush->GetColor());
|
return _lineBrush->GetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
const e2d::Color & e2d::Canvas::getFillColor() const
|
e2d::Color e2d::Canvas::getFillColor() const
|
||||||
{
|
{
|
||||||
return Color(_fillBrush->GetColor());
|
return _fillBrush->GetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Canvas::getStrokeWidth() const
|
float e2d::Canvas::getStrokeWidth() const
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ e2d::Node::Property e2d::Node::Property::operator+(Property const & prop) const
|
||||||
result.posY = this->posY + prop.posY;
|
result.posY = this->posY + prop.posY;
|
||||||
result.width = this->width + prop.width;
|
result.width = this->width + prop.width;
|
||||||
result.height = this->height + prop.height;
|
result.height = this->height + prop.height;
|
||||||
result.pivotX = this->pivotX + prop.pivotX;
|
result.anchorX = this->anchorX + prop.anchorX;
|
||||||
result.pivotY = this->pivotY + prop.pivotY;
|
result.anchorY = this->anchorY + prop.anchorY;
|
||||||
result.scaleX = this->scaleX + prop.scaleX;
|
result.scaleX = this->scaleX + prop.scaleX;
|
||||||
result.scaleY = this->scaleY + prop.scaleY;
|
result.scaleY = this->scaleY + prop.scaleY;
|
||||||
result.rotation = this->rotation + prop.rotation;
|
result.rotation = this->rotation + prop.rotation;
|
||||||
|
|
@ -29,8 +29,8 @@ e2d::Node::Property e2d::Node::Property::operator-(Property const & prop) const
|
||||||
result.posY = this->posY - prop.posY;
|
result.posY = this->posY - prop.posY;
|
||||||
result.width = this->width - prop.width;
|
result.width = this->width - prop.width;
|
||||||
result.height = this->height - prop.height;
|
result.height = this->height - prop.height;
|
||||||
result.pivotX = this->pivotX - prop.pivotX;
|
result.anchorX = this->anchorX - prop.anchorX;
|
||||||
result.pivotY = this->pivotY - prop.pivotY;
|
result.anchorY = this->anchorY - prop.anchorY;
|
||||||
result.scaleX = this->scaleX - prop.scaleX;
|
result.scaleX = this->scaleX - prop.scaleX;
|
||||||
result.scaleY = this->scaleY - prop.scaleY;
|
result.scaleY = this->scaleY - prop.scaleY;
|
||||||
result.rotation = this->rotation - prop.rotation;
|
result.rotation = this->rotation - prop.rotation;
|
||||||
|
|
@ -53,8 +53,8 @@ e2d::Node::Node()
|
||||||
, _skewAngleY(0)
|
, _skewAngleY(0)
|
||||||
, _displayOpacity(1.f)
|
, _displayOpacity(1.f)
|
||||||
, _realOpacity(1.f)
|
, _realOpacity(1.f)
|
||||||
, _pivotX(0.f)
|
, _anchorX(0.f)
|
||||||
, _pivotY(0.f)
|
, _anchorY(0.f)
|
||||||
, _initialMatri(D2D1::Matrix3x2F::Identity())
|
, _initialMatri(D2D1::Matrix3x2F::Identity())
|
||||||
, _finalMatri(D2D1::Matrix3x2F::Identity())
|
, _finalMatri(D2D1::Matrix3x2F::Identity())
|
||||||
, _visible(true)
|
, _visible(true)
|
||||||
|
|
@ -197,26 +197,26 @@ void e2d::Node::_updateTransform()
|
||||||
|
|
||||||
_needTransform = false;
|
_needTransform = false;
|
||||||
|
|
||||||
// 计算中心点坐标
|
// 计算锚点坐标
|
||||||
D2D1_POINT_2F pivot = { _width * _pivotX, _height * _pivotY };
|
D2D1_POINT_2F anchor = { _width * _anchorX, _height * _anchorY };
|
||||||
// 变换 Initial 矩阵,子节点将根据这个矩阵进行变换
|
// 变换 Initial 矩阵,子节点将根据这个矩阵进行变换
|
||||||
_initialMatri = D2D1::Matrix3x2F::Scale(
|
_initialMatri = D2D1::Matrix3x2F::Scale(
|
||||||
_scaleX,
|
_scaleX,
|
||||||
_scaleY,
|
_scaleY,
|
||||||
pivot
|
anchor
|
||||||
) * D2D1::Matrix3x2F::Skew(
|
) * D2D1::Matrix3x2F::Skew(
|
||||||
_skewAngleX,
|
_skewAngleX,
|
||||||
_skewAngleY,
|
_skewAngleY,
|
||||||
pivot
|
anchor
|
||||||
) * D2D1::Matrix3x2F::Rotation(
|
) * D2D1::Matrix3x2F::Rotation(
|
||||||
_rotation,
|
_rotation,
|
||||||
pivot
|
anchor
|
||||||
) * D2D1::Matrix3x2F::Translation(
|
) * D2D1::Matrix3x2F::Translation(
|
||||||
_posX,
|
_posX,
|
||||||
_posY
|
_posY
|
||||||
);
|
);
|
||||||
// 根据自身中心点变换 Final 矩阵
|
// 根据自身锚点变换 Final 矩阵
|
||||||
_finalMatri = _initialMatri * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y);
|
_finalMatri = _initialMatri * D2D1::Matrix3x2F::Translation(-anchor.x, -anchor.y);
|
||||||
// 和父节点矩阵相乘
|
// 和父节点矩阵相乘
|
||||||
if (!_positionFixed && _parent)
|
if (!_positionFixed && _parent)
|
||||||
{
|
{
|
||||||
|
|
@ -302,7 +302,7 @@ bool e2d::Node::isVisible() const
|
||||||
return _visible;
|
return _visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::Node::getName() const
|
const e2d::String& e2d::Node::getName() const
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
@ -352,14 +352,14 @@ e2d::Size e2d::Node::getRealSize() const
|
||||||
return Size(_width, _height);
|
return Size(_width, _height);
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::getPivotX() const
|
float e2d::Node::getAnchorX() const
|
||||||
{
|
{
|
||||||
return _pivotX;
|
return _anchorX;
|
||||||
}
|
}
|
||||||
|
|
||||||
float e2d::Node::getPivotY() const
|
float e2d::Node::getAnchorY() const
|
||||||
{
|
{
|
||||||
return _pivotY;
|
return _anchorY;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Size e2d::Node::getSize() const
|
e2d::Size e2d::Node::getSize() const
|
||||||
|
|
@ -404,8 +404,8 @@ e2d::Node::Property e2d::Node::getProperty() const
|
||||||
prop.posY = _posY;
|
prop.posY = _posY;
|
||||||
prop.width = _width;
|
prop.width = _width;
|
||||||
prop.height = _height;
|
prop.height = _height;
|
||||||
prop.pivotX = _pivotX;
|
prop.anchorX = _anchorX;
|
||||||
prop.pivotY = _pivotY;
|
prop.anchorY = _anchorY;
|
||||||
prop.scaleX = _scaleX;
|
prop.scaleX = _scaleX;
|
||||||
prop.scaleY = _scaleY;
|
prop.scaleY = _scaleY;
|
||||||
prop.rotation = _rotation;
|
prop.rotation = _rotation;
|
||||||
|
|
@ -559,23 +559,23 @@ void e2d::Node::setOpacity(float opacity)
|
||||||
_updateOpacity();
|
_updateOpacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::setPivotX(float pivotX)
|
void e2d::Node::setAnchorX(float anchorX)
|
||||||
{
|
{
|
||||||
this->setPivot(pivotX, _pivotY);
|
this->setAnchor(anchorX, _anchorY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::setPivotY(float pivotY)
|
void e2d::Node::setAnchorY(float anchorY)
|
||||||
{
|
{
|
||||||
this->setPivot(_pivotX, pivotY);
|
this->setAnchor(_anchorX, anchorY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Node::setPivot(float pivotX, float pivotY)
|
void e2d::Node::setAnchor(float anchorX, float anchorY)
|
||||||
{
|
{
|
||||||
if (_pivotX == pivotX && _pivotY == pivotY)
|
if (_anchorX == anchorX && _anchorY == anchorY)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_pivotX = std::min(std::max(pivotX, 0.f), 1.f);
|
_anchorX = std::min(std::max(anchorX, 0.f), 1.f);
|
||||||
_pivotY = std::min(std::max(pivotY, 0.f), 1.f);
|
_anchorY = std::min(std::max(anchorY, 0.f), 1.f);
|
||||||
_needTransform = true;
|
_needTransform = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -608,7 +608,7 @@ void e2d::Node::setProperty(Property prop)
|
||||||
{
|
{
|
||||||
this->setPos(prop.posX, prop.posY);
|
this->setPos(prop.posX, prop.posY);
|
||||||
this->setSize(prop.width, prop.height);
|
this->setSize(prop.width, prop.height);
|
||||||
this->setPivot(prop.pivotX, prop.pivotY);
|
this->setAnchor(prop.anchorX, prop.anchorY);
|
||||||
this->setScale(prop.scaleX, prop.scaleY);
|
this->setScale(prop.scaleX, prop.scaleY);
|
||||||
this->setRotation(prop.rotation);
|
this->setRotation(prop.rotation);
|
||||||
this->setSkew(prop.skewAngleX, prop.skewAngleY);
|
this->setSkew(prop.skewAngleX, prop.skewAngleY);
|
||||||
|
|
|
||||||
|
|
@ -74,22 +74,22 @@ e2d::Text::~Text()
|
||||||
SafeRelease(_textLayout);
|
SafeRelease(_textLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::Text::getText() const
|
const e2d::String& e2d::Text::getText() const
|
||||||
{
|
{
|
||||||
return _text;
|
return _text;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Font e2d::Text::getFont() const
|
const e2d::Font& e2d::Text::getFont() const
|
||||||
{
|
{
|
||||||
return _font;
|
return _font;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Text::Style e2d::Text::getStyle() const
|
const e2d::Text::Style& e2d::Text::getStyle() const
|
||||||
{
|
{
|
||||||
return _style;
|
return _style;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::Text::getFontFamily() const
|
const e2d::String& e2d::Text::getFontFamily() const
|
||||||
{
|
{
|
||||||
return _font.family;
|
return _font.family;
|
||||||
}
|
}
|
||||||
|
|
@ -104,12 +104,12 @@ UINT e2d::Text::getFontWeight() const
|
||||||
return _font.weight;
|
return _font.weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color e2d::Text::getColor() const
|
const e2d::Color& e2d::Text::getColor() const
|
||||||
{
|
{
|
||||||
return _style.color;
|
return _style.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::Color e2d::Text::getOutlineColor() const
|
const e2d::Color& e2d::Text::getOutlineColor() const
|
||||||
{
|
{
|
||||||
return _style.outlineColor;
|
return _style.outlineColor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
if (Old) this->removeChild(Old); \
|
if (Old) this->removeChild(Old); \
|
||||||
if (New) \
|
if (New) \
|
||||||
{ \
|
{ \
|
||||||
New->setPivot(_pivotX, _pivotY); \
|
New->setAnchor(_anchorX, _anchorY); \
|
||||||
this->addChild(New); \
|
this->addChild(New); \
|
||||||
} \
|
} \
|
||||||
Old = New; \
|
Old = New; \
|
||||||
|
|
@ -166,17 +166,17 @@ void e2d::ToggleButton::setDisabledOff(Node * disabled)
|
||||||
SET_BUTTON_NODE(_disabledOff, disabled);
|
SET_BUTTON_NODE(_disabledOff, disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ToggleButton::setPivot(float pivotX, float pivotY)
|
void e2d::ToggleButton::setAnchor(float anchorX, float anchorY)
|
||||||
{
|
{
|
||||||
Node::setPivot(pivotX, pivotY);
|
Node::setAnchor(anchorX, anchorY);
|
||||||
SAFE_SET(_normalOn, setPivot, pivotX, pivotY);
|
SAFE_SET(_normalOn, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_mouseoverOn, setPivot, pivotX, pivotY);
|
SAFE_SET(_mouseoverOn, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_selectedOn, setPivot, pivotX, pivotY);
|
SAFE_SET(_selectedOn, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_disabledOn, setPivot, pivotX, pivotY);
|
SAFE_SET(_disabledOn, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_normalOff, setPivot, pivotX, pivotY);
|
SAFE_SET(_normalOff, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_mouseoverOff, setPivot, pivotX, pivotY);
|
SAFE_SET(_mouseoverOff, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_selectedOff, setPivot, pivotX, pivotY);
|
SAFE_SET(_selectedOff, setAnchor, anchorX, anchorY);
|
||||||
SAFE_SET(_disabledOff, setPivot, pivotX, pivotY);
|
SAFE_SET(_disabledOff, setAnchor, anchorX, anchorY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::ToggleButton::_updateStatus()
|
void e2d::ToggleButton::_updateStatus()
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ bool e2d::File::isFolder() const
|
||||||
return (_attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
return (_attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
e2d::String e2d::File::getFilePath() const
|
const e2d::String& e2d::File::getPath() const
|
||||||
{
|
{
|
||||||
return _fileName;
|
return _fileName;
|
||||||
}
|
}
|
||||||
|
|
@ -82,7 +82,7 @@ e2d::String e2d::File::getExtension() const
|
||||||
return fileExtension;
|
return fileExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::File::deleteFile()
|
bool e2d::File::del()
|
||||||
{
|
{
|
||||||
if (::DeleteFile((LPCWSTR)_fileName))
|
if (::DeleteFile((LPCWSTR)_fileName))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ bool e2d::Music::open(const e2d::String & filePath)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String actualFilePath = File(filePath).getFilePath();
|
String actualFilePath = File(filePath).getPath();
|
||||||
if (actualFilePath.isEmpty())
|
if (actualFilePath.isEmpty())
|
||||||
{
|
{
|
||||||
WARN("MusicInfo::open File not found.");
|
WARN("MusicInfo::open File not found.");
|
||||||
|
|
|
||||||
158
core/e2dnode.h
158
core/e2dnode.h
|
|
@ -68,8 +68,8 @@ public:
|
||||||
float posY; // Y 坐标
|
float posY; // Y 坐标
|
||||||
float width; // 宽度
|
float width; // 宽度
|
||||||
float height; // 高度
|
float height; // 高度
|
||||||
float pivotX; // 中心点 X 坐标
|
float anchorX; // 锚点 X 坐标
|
||||||
float pivotY; // 中心点 Y 坐标
|
float anchorY; // 锚点 Y 坐标
|
||||||
float scaleX; // 横向缩放
|
float scaleX; // 横向缩放
|
||||||
float scaleY; // 纵向缩放
|
float scaleY; // 纵向缩放
|
||||||
float rotation; // 旋转角度
|
float rotation; // 旋转角度
|
||||||
|
|
@ -88,20 +88,10 @@ public:
|
||||||
virtual ~Node();
|
virtual ~Node();
|
||||||
|
|
||||||
// 获取节点显示状态
|
// 获取节点显示状态
|
||||||
virtual bool isVisible() const;
|
bool isVisible() const;
|
||||||
|
|
||||||
// 判断点是否在节点内
|
|
||||||
bool containsPoint(
|
|
||||||
const Point& point
|
|
||||||
);
|
|
||||||
|
|
||||||
// 判断两物体是否相交
|
|
||||||
bool intersects(
|
|
||||||
Node * node
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取节点名称
|
// 获取节点名称
|
||||||
String getName() const;
|
const String& getName() const;
|
||||||
|
|
||||||
// 获取节点名称的 Hash 值
|
// 获取节点名称的 Hash 值
|
||||||
size_t getHashName() const;
|
size_t getHashName() const;
|
||||||
|
|
@ -133,11 +123,11 @@ public:
|
||||||
// 获取节点大小(不考虑缩放)
|
// 获取节点大小(不考虑缩放)
|
||||||
Size getRealSize() const;
|
Size getRealSize() const;
|
||||||
|
|
||||||
// 获取节点的中心点
|
// 获取节点的锚点
|
||||||
float getPivotX() const;
|
float getAnchorX() const;
|
||||||
|
|
||||||
// 获取节点的中心点
|
// 获取节点的锚点
|
||||||
float getPivotY() const;
|
float getAnchorY() const;
|
||||||
|
|
||||||
// 获取节点大小
|
// 获取节点大小
|
||||||
Size getSize() const;
|
Size getSize() const;
|
||||||
|
|
@ -175,38 +165,6 @@ public:
|
||||||
// 获取节点所在场景
|
// 获取节点所在场景
|
||||||
Scene * getParentScene() const;
|
Scene * getParentScene() const;
|
||||||
|
|
||||||
// 获取所有名称相同的子节点
|
|
||||||
std::vector<Node*> getChildren(
|
|
||||||
const String& name
|
|
||||||
) const;
|
|
||||||
|
|
||||||
// 获取名称相同的子节点
|
|
||||||
Node* getChild(
|
|
||||||
const String& name
|
|
||||||
) const;
|
|
||||||
|
|
||||||
// 获取所有子节点
|
|
||||||
const std::vector<Node*>& getAllChildren() const;
|
|
||||||
|
|
||||||
// 获取子节点数量
|
|
||||||
int getChildrenCount() const;
|
|
||||||
|
|
||||||
// 移除子节点
|
|
||||||
bool removeChild(
|
|
||||||
Node * child
|
|
||||||
);
|
|
||||||
|
|
||||||
// 移除所有名称相同的子节点
|
|
||||||
void removeChildren(
|
|
||||||
const String& childName
|
|
||||||
);
|
|
||||||
|
|
||||||
// 移除所有节点
|
|
||||||
void removeAllChildren();
|
|
||||||
|
|
||||||
// 从父节点移除
|
|
||||||
void removeFromParent();
|
|
||||||
|
|
||||||
// 设置节点是否显示
|
// 设置节点是否显示
|
||||||
void setVisible(
|
void setVisible(
|
||||||
bool value
|
bool value
|
||||||
|
|
@ -326,23 +284,23 @@ public:
|
||||||
float opacity
|
float opacity
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置中心点的横向位置
|
// 设置锚点的横向位置
|
||||||
// 默认为 0, 范围 [0, 1]
|
// 默认为 0, 范围 [0, 1]
|
||||||
virtual void setPivotX(
|
virtual void setAnchorX(
|
||||||
float pivotX
|
float anchorX
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置中心点的纵向位置
|
// 设置锚点的纵向位置
|
||||||
// 默认为 0, 范围 [0, 1]
|
// 默认为 0, 范围 [0, 1]
|
||||||
virtual void setPivotY(
|
virtual void setAnchorY(
|
||||||
float pivotY
|
float anchorY
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置中心点位置
|
// 设置锚点位置
|
||||||
// 默认为 (0, 0), 范围 [0, 1]
|
// 默认为 (0, 0), 范围 [0, 1]
|
||||||
virtual void setPivot(
|
virtual void setAnchor(
|
||||||
float pivotX,
|
float anchorX,
|
||||||
float pivotY
|
float anchorY
|
||||||
);
|
);
|
||||||
|
|
||||||
// 修改节点宽度
|
// 修改节点宽度
|
||||||
|
|
@ -376,6 +334,16 @@ public:
|
||||||
bool enabled
|
bool enabled
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 判断点是否在节点内
|
||||||
|
bool containsPoint(
|
||||||
|
const Point& point
|
||||||
|
);
|
||||||
|
|
||||||
|
// 判断两物体是否相交
|
||||||
|
bool intersects(
|
||||||
|
Node * node
|
||||||
|
);
|
||||||
|
|
||||||
// 添加子节点
|
// 添加子节点
|
||||||
void addChild(
|
void addChild(
|
||||||
Node * child,
|
Node * child,
|
||||||
|
|
@ -388,6 +356,38 @@ public:
|
||||||
int order = 0 /* 渲染顺序 */
|
int order = 0 /* 渲染顺序 */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 获取所有名称相同的子节点
|
||||||
|
std::vector<Node*> getChildren(
|
||||||
|
const String& name
|
||||||
|
) const;
|
||||||
|
|
||||||
|
// 获取名称相同的子节点
|
||||||
|
Node* getChild(
|
||||||
|
const String& name
|
||||||
|
) const;
|
||||||
|
|
||||||
|
// 获取所有子节点
|
||||||
|
const std::vector<Node*>& getAllChildren() const;
|
||||||
|
|
||||||
|
// 获取子节点数量
|
||||||
|
int getChildrenCount() const;
|
||||||
|
|
||||||
|
// 移除子节点
|
||||||
|
bool removeChild(
|
||||||
|
Node * child
|
||||||
|
);
|
||||||
|
|
||||||
|
// 移除所有名称相同的子节点
|
||||||
|
void removeChildren(
|
||||||
|
const String& childName
|
||||||
|
);
|
||||||
|
|
||||||
|
// 移除所有节点
|
||||||
|
void removeAllChildren();
|
||||||
|
|
||||||
|
// 从父节点移除
|
||||||
|
void removeFromParent();
|
||||||
|
|
||||||
// 执行动作
|
// 执行动作
|
||||||
void runAction(
|
void runAction(
|
||||||
Action * action
|
Action * action
|
||||||
|
|
@ -473,8 +473,8 @@ protected:
|
||||||
float _skewAngleY;
|
float _skewAngleY;
|
||||||
float _displayOpacity;
|
float _displayOpacity;
|
||||||
float _realOpacity;
|
float _realOpacity;
|
||||||
float _pivotX;
|
float _anchorX;
|
||||||
float _pivotY;
|
float _anchorY;
|
||||||
int _order;
|
int _order;
|
||||||
bool _visible;
|
bool _visible;
|
||||||
bool _clipEnabled;
|
bool _clipEnabled;
|
||||||
|
|
@ -589,7 +589,7 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取 Image 对象
|
// 获取 Image 对象
|
||||||
virtual Image * getImage() const;
|
Image * getImage() const;
|
||||||
|
|
||||||
// 渲染精灵
|
// 渲染精灵
|
||||||
virtual void draw(
|
virtual void draw(
|
||||||
|
|
@ -664,16 +664,16 @@ public:
|
||||||
virtual ~Text();
|
virtual ~Text();
|
||||||
|
|
||||||
// 获取文本
|
// 获取文本
|
||||||
String getText() const;
|
const String& getText() const;
|
||||||
|
|
||||||
// 获取字体
|
// 获取字体
|
||||||
Font getFont() const;
|
const Font& getFont() const;
|
||||||
|
|
||||||
// 获取文本样式
|
// 获取文本样式
|
||||||
Style getStyle() const;
|
const Style& getStyle() const;
|
||||||
|
|
||||||
// 获取字体族
|
// 获取字体族
|
||||||
String getFontFamily() const;
|
const String& getFontFamily() const;
|
||||||
|
|
||||||
// 获取当前字号
|
// 获取当前字号
|
||||||
float getFontSize() const;
|
float getFontSize() const;
|
||||||
|
|
@ -682,10 +682,10 @@ public:
|
||||||
UINT getFontWeight() const;
|
UINT getFontWeight() const;
|
||||||
|
|
||||||
// 获取文字颜色
|
// 获取文字颜色
|
||||||
Color getColor() const;
|
const Color& getColor() const;
|
||||||
|
|
||||||
// 获取描边颜色
|
// 获取描边颜色
|
||||||
Color getOutlineColor() const;
|
const Color& getOutlineColor() const;
|
||||||
|
|
||||||
// 获取描边线宽
|
// 获取描边线宽
|
||||||
float getOutlineWidth() const;
|
float getOutlineWidth() const;
|
||||||
|
|
@ -889,11 +889,11 @@ public:
|
||||||
const Function& func
|
const Function& func
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置中心点位置
|
// 设置锚点位置
|
||||||
// 默认为 (0, 0), 范围 [0, 1]
|
// 默认为 (0, 0), 范围 [0, 1]
|
||||||
virtual void setPivot(
|
virtual void setAnchor(
|
||||||
float pivotX,
|
float anchorX,
|
||||||
float pivotY
|
float anchorY
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
// 分发鼠标消息
|
// 分发鼠标消息
|
||||||
|
|
@ -1024,11 +1024,11 @@ public:
|
||||||
Node * disabled
|
Node * disabled
|
||||||
);
|
);
|
||||||
|
|
||||||
// 设置中心点位置
|
// 设置锚点位置
|
||||||
// 默认为 (0, 0), 范围 [0, 1]
|
// 默认为 (0, 0), 范围 [0, 1]
|
||||||
virtual void setPivot(
|
virtual void setAnchor(
|
||||||
float pivotX,
|
float anchorX,
|
||||||
float pivotY
|
float anchorY
|
||||||
) override;
|
) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -1130,10 +1130,10 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取线条颜色
|
// 获取线条颜色
|
||||||
const Color& getLineColor() const;
|
Color getLineColor() const;
|
||||||
|
|
||||||
// 获取填充颜色
|
// 获取填充颜色
|
||||||
const Color& getFillColor() const;
|
Color getFillColor() const;
|
||||||
|
|
||||||
// 获取线条宽度
|
// 获取线条宽度
|
||||||
float getStrokeWidth() const;
|
float getStrokeWidth() const;
|
||||||
|
|
|
||||||
|
|
@ -458,10 +458,10 @@ public:
|
||||||
bool isFolder() const;
|
bool isFolder() const;
|
||||||
|
|
||||||
// 删除文件
|
// 删除文件
|
||||||
bool deleteFile();
|
bool del();
|
||||||
|
|
||||||
// 获取文件路径
|
// 获取文件路径
|
||||||
String getFilePath() const;
|
const String& getPath() const;
|
||||||
|
|
||||||
// 获取文件扩展名
|
// 获取文件扩展名
|
||||||
String getExtension() const;
|
String getExtension() const;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue