修复了锚点的设置问题

This commit is contained in:
Nomango 2017-11-04 11:11:16 +08:00
parent 5c8d6fb8b0
commit 55e1846d68
3 changed files with 8 additions and 14 deletions

View File

@ -4,13 +4,12 @@ int main()
{
EApp app;
if (app.init(L"Easy2D Demo", 320, 320))
if (app.init(L"Easy2D Demo", 640, 640))
{
app.showConsole();
auto scene = new EScene();
auto sprite = new ESprite(L"elyse.png");
sprite->setScale(0.3f);
auto sprite = new ESprite(L"test2.png");
sprite->setAnchor(-1, 0);
// 获取窗口宽度
float width = EApp::getWidth();
// 获取窗口高度
@ -18,14 +17,9 @@ int main()
// 移动精灵的位置
sprite->setPos(width / 2, height / 2);
//sprite->setAnchor(0, 0);
//scene->add(sprite);
auto text = new EText(L"balabalabalabalabala", L"ËÎÌå", 80, EColor::BLUE);
scene->add(text, -1);
sprite->setName(L"test");
auto button = new EButton(sprite, [=] {
EApp::enterScene(new EScene);
});
scene->add(button);
scene->add(sprite);
sprite->runAction(new EActionLoop(new EActionRotateBy(1, 60)));
app.enterScene(scene);

BIN
ConsoleDemo/test2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -503,8 +503,8 @@ void e2d::ENode::setAnchor(float anchorX, float anchorY)
if (m_fAnchorX == anchorX && m_fAnchorY == anchorY)
return;
m_fAnchorX = min(max(anchorX, 0), 1);
m_fAnchorY = min(max(anchorY, 0), 1);
m_fAnchorX = anchorX;
m_fAnchorY = anchorY;
m_bTransformChildrenNeeded = true;
}