中心点默认位置改为(0,0);新增ENode::setDefaultPivot函数设置默认中心点;修复了启用或禁用按钮后按钮消失的bug;更新了判断点是否在节点内的算法;修复了切换开关按钮状态不执行回调函数的bug;修复了子节点与父节点相对位置错误的bug;修复了其他的一些小bug。

This commit is contained in:
Nomango 2017-11-09 18:22:41 +08:00
parent 07abf5cf96
commit ee796af1df
12 changed files with 162 additions and 117 deletions

View File

@ -1,35 +1,53 @@
#include <easy2d.h> #include <easy2d.h>
class Scene2 :
public EScene
{
public:
Scene2()
{
auto text = new EText(L"²âÊÔ°´Å¥");
auto text2 = new EText(L"²âÊÔ°´Å¥", L"", 22, EColor::BLUE);
auto button = new EButton(text, text2, text);
button->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2);
button->setCallback([]() {
EApp::backScene(new ETransitionScaleEmerge(1, ETransitionScaleEmerge::ENTER));
});
this->add(button);
}
};
class Scene :
public EScene
{
public:
Scene()
{
/*auto sprite = new ESprite(L"test2.png");
auto button = new EButton(sprite);
button->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2);
button->setCallback([]() {
EApp::enterScene(new Scene2(), new ETransitionScaleEmerge(1, ETransitionScaleEmerge::ENTER));
});
this->add(button);*/
auto sprite = new ESprite(L"test2.png");
sprite->setPivot(-1, 0);
sprite->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2);
this->add(sprite);
sprite->runAction(new EActionLoop(new EActionRotateBy(1, 60)));
}
};
int main() int main()
{ {
EApp app; EApp app;
if (app.init(L"Easy2D Demo", 640, 480)) if (app.init(L"Easy2D Demo", 640, 480))
{ {
app.showConsole(); ENode::setDefaultPiovt(0.5f, 0.5f);
auto scene = new EScene();
// 创建一个文本
auto btnNormal = new EText(L"");
auto btnSelected = new EText(L"");
btnSelected->movePosY(2);
auto btnNormal2 = new EText(L"");
auto btnSelected2 = new EText(L"");
btnSelected2->movePosY(2);
// 创建一个按钮
auto button = new EButtonToggle(btnNormal, btnNormal2, btnSelected, btnSelected2);
button->setCallback([=]() {
//button->setEnable(false);
});
button->toggle();
button->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2);
scene->add(button);
// 创建按钮
auto button2 = new EButton(new EText(L"关闭"), [=]() { button->setEnable(!button->isEnable()); });
button2->setPos(40, 40);
scene->add(button2);
auto scene = new Scene();
app.enterScene(scene); app.enterScene(scene);
app.run(); app.run();

View File

@ -15,8 +15,8 @@ e2d::EScene::EScene()
m_pRoot->retain(); m_pRoot->retain();
m_pRoot->_onEnter(); m_pRoot->_onEnter();
m_pRoot->_setParentScene(this); m_pRoot->_setParentScene(this);
m_pRoot->setPivot(0, 0);
m_pRoot->_setSize(EApp::getWidth(), EApp::getHeight()); m_pRoot->_setSize(EApp::getWidth(), EApp::getHeight());
m_pRoot->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2);
} }
e2d::EScene::~EScene() e2d::EScene::~EScene()

View File

@ -46,7 +46,7 @@ bool e2d::EFont::isItalic() const
return m_bItalic; return m_bItalic;
} }
void e2d::EFont::setFamily(EString fontFamily) void e2d::EFont::setFamily(const EString & fontFamily)
{ {
m_sFontFamily = fontFamily; m_sFontFamily = fontFamily;
m_bRecreateNeeded = true; m_bRecreateNeeded = true;

View File

@ -101,7 +101,7 @@
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>None</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
</ClCompile> </ClCompile>
<Link> <Link>

View File

@ -4,8 +4,7 @@
#include "..\Win\winbase.h" #include "..\Win\winbase.h"
e2d::EGeometry::EGeometry() e2d::EGeometry::EGeometry()
: m_bTransformed(false) : m_nCategoryBitmask(0)
, m_nCategoryBitmask(0)
, m_nCollisionBitmask(0) , m_nCollisionBitmask(0)
, m_bIsVisiable(true) , m_bIsVisiable(true)
, m_nColor(EColor::RED) , m_nColor(EColor::RED)
@ -105,7 +104,7 @@ void e2d::EGeometry::_transform()
// 根据父节点转换几何图形 // 根据父节点转换几何图形
GetFactory()->CreateTransformedGeometry( GetFactory()->CreateTransformedGeometry(
_getD2dGeometry(), _getD2dGeometry(),
m_pParentNode->m_Matri, m_pParentNode->m_MatriFinal,
&m_pTransformedGeometry &m_pTransformedGeometry
); );

View File

@ -73,6 +73,7 @@ void e2d::EButton::setNormal(ENode * normal)
this->addChild(normal); this->addChild(normal);
} }
m_pNormal = normal; m_pNormal = normal;
_updateVisiable(); _updateVisiable();
} }
} }
@ -139,6 +140,7 @@ void e2d::EButton::setEnable(bool bEnable)
if (m_bEnable != bEnable) if (m_bEnable != bEnable)
{ {
m_bEnable = bEnable; m_bEnable = bEnable;
_updateVisiable();
_updateStatus(); _updateStatus();
} }
} }
@ -159,6 +161,12 @@ void e2d::EButton::_setStatus(STATUS status)
} }
} }
void e2d::EButton::_updateTransform()
{
ENode::_updateTransform();
_updateStatus();
}
void e2d::EButton::_updateVisiable() void e2d::EButton::_updateVisiable()
{ {
if (m_pNormal) m_pNormal->setVisiable(false); if (m_pNormal) m_pNormal->setVisiable(false);

View File

@ -63,9 +63,13 @@ e2d::EButtonToggle::EButtonToggle(ENode * toggleOnNormal, ENode * toggleOffNorma
void e2d::EButtonToggle::toggle() void e2d::EButtonToggle::toggle()
{ {
m_bToggle = !m_bToggle; // 设置按钮状态
_updateToggle(); setToggle(!m_bToggle);
_updateVisiable(); // 执行回调函数
if (m_Callback)
{
m_Callback();
}
} }
bool e2d::EButtonToggle::isToggleOn() const bool e2d::EButtonToggle::isToggleOn() const
@ -79,6 +83,7 @@ void e2d::EButtonToggle::setToggle(bool toggle)
{ {
m_bToggle = toggle; m_bToggle = toggle;
_updateToggle(); _updateToggle();
_updateVisiable();
} }
} }

View File

@ -6,6 +6,10 @@
#include "..\Win\winbase.h" #include "..\Win\winbase.h"
#include <algorithm> #include <algorithm>
// 默认中心点位置
static float s_fDefaultPiovtX = 0;
static float s_fDefaultPiovtY = 0;
e2d::ENode::ENode() e2d::ENode::ENode()
: m_nOrder(0) : m_nOrder(0)
, m_fScaleX(1.0f) , m_fScaleX(1.0f)
@ -15,9 +19,10 @@ e2d::ENode::ENode()
, m_fSkewAngleY(0) , m_fSkewAngleY(0)
, m_fDisplayOpacity(1.0f) , m_fDisplayOpacity(1.0f)
, m_fRealOpacity(1.0f) , m_fRealOpacity(1.0f)
, m_fPivotX(0.5f) , m_fPivotX(s_fDefaultPiovtX)
, m_fPivotY(0.5f) , m_fPivotY(s_fDefaultPiovtY)
, m_Matri(D2D1::Matrix3x2F::Identity()) , m_MatriInitial(D2D1::Matrix3x2F::Identity())
, m_MatriFinal(D2D1::Matrix3x2F::Identity())
, m_bVisiable(true) , m_bVisiable(true)
, m_bDisplayedInScene(false) , m_bDisplayedInScene(false)
, m_pGeometry(nullptr) , m_pGeometry(nullptr)
@ -25,7 +30,7 @@ e2d::ENode::ENode()
, m_pParentScene(nullptr) , m_pParentScene(nullptr)
, m_nHashName(0) , m_nHashName(0)
, m_bSortChildrenNeeded(false) , m_bSortChildrenNeeded(false)
, m_bTransformChildrenNeeded(false) , m_bTransformNeeded(false)
{ {
} }
@ -64,7 +69,7 @@ void e2d::ENode::_callOn()
return; return;
} }
if (m_bTransformChildrenNeeded) if (m_bTransformNeeded)
{ {
_updateTransform(this); _updateTransform(this);
} }
@ -89,7 +94,7 @@ void e2d::ENode::_callOn()
} }
} }
GetRenderTarget()->SetTransform(m_Matri); GetRenderTarget()->SetTransform(m_MatriFinal);
// 渲染自身 // 渲染自身
this->_onRender(); this->_onRender();
@ -99,7 +104,7 @@ void e2d::ENode::_callOn()
} }
else else
{ {
GetRenderTarget()->SetTransform(m_Matri); GetRenderTarget()->SetTransform(m_MatriFinal);
// 渲染自身 // 渲染自身
this->_onRender(); this->_onRender();
} }
@ -169,20 +174,15 @@ void e2d::ENode::_sortChildren()
} }
} }
void e2d::ENode::_updateTransformToReal() void e2d::ENode::_updateTransform()
{ {
// 计算点坐标 // 计算中心点坐标
D2D1_POINT_2F pivot = D2D1::Point2F( D2D1_POINT_2F pivot = D2D1::Point2F(
getRealWidth() * m_fPivotX, getRealWidth() * m_fPivotX,
getRealHeight() * m_fPivotY getRealHeight() * m_fPivotY
); );
// 计算左上角坐标 // 初步的二维矩形变换,子节点将根据这个矩阵进行变换
D2D1_POINT_2F upperLeftCorner = D2D1::Point2F( m_MatriInitial = D2D1::Matrix3x2F::Scale(
m_Pos.x - getRealWidth() * m_fPivotX,
m_Pos.y - getRealHeight() * m_fPivotY
);
// 二维矩形变换
m_Matri = D2D1::Matrix3x2F::Scale(
m_fScaleX, m_fScaleX,
m_fScaleY, m_fScaleY,
pivot pivot
@ -194,9 +194,16 @@ void e2d::ENode::_updateTransformToReal()
m_fRotation, m_fRotation,
pivot pivot
) * D2D1::Matrix3x2F::Translation( ) * D2D1::Matrix3x2F::Translation(
upperLeftCorner.x, m_Pos.x,
upperLeftCorner.y m_Pos.y
); );
// 和父节点矩阵相乘
if (m_pParent)
{
m_MatriInitial = m_MatriInitial * m_pParent->m_MatriInitial;
}
// 根据自身中心点做最终变换
m_MatriFinal = m_MatriInitial * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y);
} }
void e2d::ENode::_updateChildrenTransform() void e2d::ENode::_updateChildrenTransform()
@ -210,13 +217,8 @@ void e2d::ENode::_updateChildrenTransform()
void e2d::ENode::_updateTransform(ENode * node) void e2d::ENode::_updateTransform(ENode * node)
{ {
// 计算自身的转换矩阵 // 计算自身的转换矩阵
node->_updateTransformToReal(); node->_updateTransform();
// 和父节点矩阵相乘 // 绑定于自身的形状也进行相应转换
if (node->m_pParent)
{
node->m_Matri = node->m_Matri * node->m_pParent->m_Matri;
}
// 转换几何形状
if (node->m_pGeometry) if (node->m_pGeometry)
{ {
node->m_pGeometry->_transform(); node->m_pGeometry->_transform();
@ -224,12 +226,7 @@ void e2d::ENode::_updateTransform(ENode * node)
// 遍历子节点下的所有节点 // 遍历子节点下的所有节点
node->_updateChildrenTransform(); node->_updateChildrenTransform();
// 标志已执行过变换 // 标志已执行过变换
node->m_bTransformChildrenNeeded = false; node->m_bTransformNeeded = false;
// 绑定于自身的形状也进行相应转换
if (node->m_pGeometry)
{
node->m_pGeometry->m_bTransformed = true;
}
} }
void e2d::ENode::_updateChildrenOpacity() void e2d::ENode::_updateChildrenOpacity()
@ -376,7 +373,7 @@ void e2d::ENode::setPos(float x, float y)
m_Pos.x = x; m_Pos.x = x;
m_Pos.y = y; m_Pos.y = y;
m_bTransformChildrenNeeded = true; m_bTransformNeeded = true;
} }
void e2d::ENode::movePosX(float x) void e2d::ENode::movePosX(float x)
@ -421,7 +418,7 @@ void e2d::ENode::_setSize(float width, float height)
m_Size.width = width; m_Size.width = width;
m_Size.height = height; m_Size.height = height;
m_bTransformChildrenNeeded = true; m_bTransformNeeded = true;
} }
void e2d::ENode::setScaleX(float scaleX) void e2d::ENode::setScaleX(float scaleX)
@ -446,7 +443,7 @@ void e2d::ENode::setScale(float scaleX, float scaleY)
m_fScaleX = scaleX; m_fScaleX = scaleX;
m_fScaleY = scaleY; m_fScaleY = scaleY;
m_bTransformChildrenNeeded = true; m_bTransformNeeded = true;
} }
void e2d::ENode::setSkewX(float angleX) void e2d::ENode::setSkewX(float angleX)
@ -466,7 +463,7 @@ void e2d::ENode::setSkew(float angleX, float angleY)
m_fSkewAngleX = angleX; m_fSkewAngleX = angleX;
m_fSkewAngleY = angleY; m_fSkewAngleY = angleY;
m_bTransformChildrenNeeded = true; m_bTransformNeeded = true;
} }
void e2d::ENode::setRotation(float angle) void e2d::ENode::setRotation(float angle)
@ -475,7 +472,7 @@ void e2d::ENode::setRotation(float angle)
return; return;
m_fRotation = angle; m_fRotation = angle;
m_bTransformChildrenNeeded = true; m_bTransformNeeded = true;
} }
void e2d::ENode::setOpacity(float opacity) void e2d::ENode::setOpacity(float opacity)
@ -505,7 +502,7 @@ void e2d::ENode::setPivot(float pivotX, float pivotY)
m_fPivotX = min(max(pivotX, 0), 1); m_fPivotX = min(max(pivotX, 0), 1);
m_fPivotY = min(max(pivotY, 0), 1); m_fPivotY = min(max(pivotY, 0), 1);
m_bTransformChildrenNeeded = true; m_bTransformNeeded = true;
} }
void e2d::ENode::setGeometry(EGeometry * geometry) void e2d::ENode::setGeometry(EGeometry * geometry)
@ -547,8 +544,6 @@ void e2d::ENode::addChild(ENode * child, int order /* = 0 */)
child->m_pParent = this; child->m_pParent = this;
_updateOpacity(child);
if (this->m_pParentScene) if (this->m_pParentScene)
{ {
child->_setParentScene(this->m_pParentScene); child->_setParentScene(this->m_pParentScene);
@ -559,6 +554,11 @@ void e2d::ENode::addChild(ENode * child, int order /* = 0 */)
child->_onEnter(); child->_onEnter();
} }
// 更新子节点透明度
_updateOpacity(child);
// 更新节点转换
child->m_bTransformNeeded = true;
// 更新子节点排序
m_bSortChildrenNeeded = true; m_bSortChildrenNeeded = true;
} }
} }
@ -710,27 +710,26 @@ void e2d::ENode::pauseAction(EAction * action)
bool e2d::ENode::isPointIn(EPoint point) bool e2d::ENode::isPointIn(EPoint point)
{ {
if (m_bTransformChildrenNeeded) if (m_bTransformNeeded)
{ {
_updateTransform(this); _updateTransform(this);
} }
// 保存节点所在矩形 // 为节点创建一个形状
D2D1_POINT_2F leftTop = m_Matri.TransformPoint( ID2D1RectangleGeometry * rect;
D2D1::Point2F(0, 0) GetFactory()->CreateRectangleGeometry(
D2D1::RectF(0, 0, getRealWidth(), getRealHeight()),
&rect
); );
D2D1_POINT_2F rightBottom = m_Matri.TransformPoint( // 判断点是否在形状内
D2D1::Point2F(getRealWidth(), getRealHeight()) BOOL ret;
rect->FillContainsPoint(
D2D1::Point2F(
point.x,
point.y),
&m_MatriFinal,
&ret
); );
D2D1_RECT_F rt = D2D1::RectF( if (ret)
leftTop.x,
leftTop.y,
rightBottom.x,
rightBottom.y
);
if (point.x >= rt.left &&
point.x <= rt.right &&
point.y >= rt.top &&
point.y <= rt.bottom)
{ {
return true; return true;
} }
@ -743,6 +742,12 @@ bool e2d::ENode::isPointIn(EPoint point)
return false; return false;
} }
void e2d::ENode::setDefaultPiovt(float defaultPiovtX, float defaultPiovtY)
{
s_fDefaultPiovtX = min(max(defaultPiovtX, 0), 1);
s_fDefaultPiovtY = min(max(defaultPiovtY, 0), 1);
}
void e2d::ENode::stopAction(EAction * action) void e2d::ENode::stopAction(EAction * action)
{ {
if (action->getTarget() == this) if (action->getTarget() == this)

View File

@ -10,44 +10,44 @@ e2d::ETransitionScaleEmerge::ETransitionScaleEmerge(float duration, SCALE_EMERGE
void e2d::ETransitionScaleEmerge::_setTarget(EScene * prev, EScene * next, bool & transitional) void e2d::ETransitionScaleEmerge::_setTarget(EScene * prev, EScene * next, bool & transitional)
{ {
float prevScaleTo; float prevScaleBy;
float nextScaleStart; float nextScaleBy;
if (m_Mode == SCALE_EMERGE_MODE::ENTER) if (m_Mode == SCALE_EMERGE_MODE::ENTER)
{ {
prevScaleTo = 1.2f; prevScaleBy = 0.2f;
nextScaleStart = 0.8f; nextScaleBy = -0.2f;
} }
else else
{ {
prevScaleTo = 0.8f; prevScaleBy = -0.2f;
nextScaleStart = 1.2f; nextScaleBy = 0.2f;
} }
// 初始化场景属性 // 初始化场景属性
next->getRoot()->setScale(nextScaleStart); next->getRoot()->setScale(next->getRoot()->getScaleX() - nextScaleBy, next->getRoot()->getScaleY() - nextScaleBy);
next->getRoot()->setOpacity(0); next->getRoot()->setOpacity(0);
// 第一个场景淡出 // 第一个场景淡出
auto prevActionFadeOut = new EActionFadeOut(m_fDuration); auto prevActionFadeOut = new EActionFadeOut(m_fDuration);
auto prevActionScaleTo = new EActionScaleTo(m_fDuration, prevScaleTo); auto prevActionScaleBy = new EActionScaleBy(m_fDuration, prevScaleBy);
auto action1 = new EActionTwoAtSameTime( auto action1 = new EActionTwoAtSameTime(
prevActionFadeOut, prevActionFadeOut,
prevActionScaleTo); prevActionScaleBy);
if (prev) if (prev)
{ {
prevActionFadeOut->setTarget(prev->getRoot()); prevActionFadeOut->setTarget(prev->getRoot());
prevActionScaleTo->setTarget(prev->getRoot()); prevActionScaleBy->setTarget(prev->getRoot());
} }
// 第二个场景淡入 // 第二个场景淡入
auto nextActionFadeOut = new EActionFadeIn(m_fDuration); auto nextActionFadeOut = new EActionFadeIn(m_fDuration);
auto nextActionScaleTo = new EActionScaleTo(m_fDuration, 1); auto nextActionScaleBy = new EActionScaleBy(m_fDuration, nextScaleBy);
auto action2 = new EActionTwoAtSameTime( auto action2 = new EActionTwoAtSameTime(
nextActionFadeOut, nextActionFadeOut,
nextActionScaleTo); nextActionScaleBy);
nextActionFadeOut->setTarget(next->getRoot()); nextActionFadeOut->setTarget(next->getRoot());
nextActionScaleTo->setTarget(next->getRoot()); nextActionScaleBy->setTarget(next->getRoot());
// 标志动画结束 // 标志动画结束
auto action3 = new EActionCallback([&, prev, next] { auto action3 = new EActionCallback([&, prev, next] {

View File

@ -395,7 +395,7 @@ public:
// ÉèÖÃ×ÖÌå // ÉèÖÃ×ÖÌå
void setFamily( void setFamily(
EString fontFamily const EString & fontFamily
); );
// ÉèÖÃ×ֺŠ// ÉèÖÃ×ÖºÅ

View File

@ -69,7 +69,6 @@ protected:
virtual ID2D1Geometry * _getD2dGeometry() const = 0; virtual ID2D1Geometry * _getD2dGeometry() const = 0;
protected: protected:
bool m_bTransformed;
bool m_bIsVisiable; bool m_bIsVisiable;
UINT32 m_nCategoryBitmask; UINT32 m_nCategoryBitmask;
UINT32 m_nCollisionBitmask; UINT32 m_nCollisionBitmask;

View File

@ -68,10 +68,10 @@ public:
// 获取节点大小(不考虑缩放) // 获取节点大小(不考虑缩放)
virtual ESize getRealSize() const; virtual ESize getRealSize() const;
// 获取节点的 // 获取节点的中心
virtual float getPivotX() const; virtual float getPivotX() const;
// 获取节点的 // 获取节点的中心
virtual float getPivotY() const; virtual float getPivotY() const;
// 获取节点大小 // 获取节点大小
@ -226,20 +226,20 @@ public:
float opacity float opacity
); );
// 设置点的横向位置 // 设置中心点的横向位置
// 默认为 0.5f, 范围 [0, 1] // 默认为 0, 范围 [0, 1]
virtual void setPivotX( virtual void setPivotX(
float pivotX float pivotX
); );
// 设置点的纵向位置 // 设置中心点的纵向位置
// 默认为 0.5f, 范围 [0, 1] // 默认为 0, 范围 [0, 1]
virtual void setPivotY( virtual void setPivotY(
float pivotY float pivotY
); );
// 设置点位置 // 设置中心点位置
// 默认为 (0.5f, 0.5f), 范围 [0, 1] // 默认为 (0, 0), 范围 [0, 1]
virtual void setPivot( virtual void setPivot(
float pivotX, float pivotX,
float pivotY float pivotY
@ -306,6 +306,12 @@ public:
EPoint point EPoint point
); );
// 修改节点的默认中心点位置
static void setDefaultPiovt(
float defaultPiovtX,
float defaultPiovtY
);
protected: protected:
// 访问节点 // 访问节点
virtual void _callOn(); virtual void _callOn();
@ -330,14 +336,14 @@ protected:
EScene * scene EScene * scene
); );
// 只考虑自身进行二维矩阵变换 // 自身进行二维矩阵变换
void _updateTransformToReal(); virtual void _updateTransform();
// 更新所有子节点矩阵 // 更新所有子节点矩阵
void _updateChildrenTransform(); virtual void _updateChildrenTransform();
// 更新所有子节点透明度 // 更新所有子节点透明度
void _updateChildrenOpacity(); virtual void _updateChildrenOpacity();
// 更新节点矩阵 // 更新节点矩阵
static void _updateTransform(ENode * node); static void _updateTransform(ENode * node);
@ -384,11 +390,12 @@ protected:
bool m_bVisiable; bool m_bVisiable;
bool m_bDisplayedInScene; bool m_bDisplayedInScene;
bool m_bSortChildrenNeeded; bool m_bSortChildrenNeeded;
bool m_bTransformChildrenNeeded; bool m_bTransformNeeded;
EGeometry * m_pGeometry; EGeometry * m_pGeometry;
EScene * m_pParentScene; EScene * m_pParentScene;
ENode * m_pParent; ENode * m_pParent;
D2D1::Matrix3x2F m_Matri; D2D1::Matrix3x2F m_MatriInitial;
D2D1::Matrix3x2F m_MatriFinal;
EVector<ENode*> m_vChildren; EVector<ENode*> m_vChildren;
}; };
@ -646,6 +653,9 @@ protected:
// 设置按钮状态 // 设置按钮状态
virtual void _setStatus(STATUS status); virtual void _setStatus(STATUS status);
// 对自身进行二维矩阵变换
virtual void _updateTransform() override;
// 刷新按钮显示 // 刷新按钮显示
virtual void _updateVisiable(); virtual void _updateVisiable();
@ -715,13 +725,14 @@ public:
const BUTTON_CLICK_CALLBACK & callback = nullptr const BUTTON_CLICK_CALLBACK & callback = nullptr
); );
// 切换开关状态 // 切换开关状态,并执行回调函数
void toggle(); void toggle();
// 获取开关状态 // 获取开关状态
bool isToggleOn() const; bool isToggleOn() const;
// 打开或关闭开关 // 打开或关闭开关
// 仅设置按钮状态,不执行回调函数
void setToggle( void setToggle(
bool toggle bool toggle
); );