Merge branch 'newRenderer' of github.com:darkdukey/cocos2d-x into newRenderer

This commit is contained in:
Ricardo Quesada 2013-12-16 20:43:51 -08:00
commit 8bd838ddfc
2 changed files with 33 additions and 0 deletions

View File

@ -124,9 +124,15 @@ void ExtensionsMainLayer::onEnter()
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
auto mouseListener = EventListenerMouse::create();
mouseListener->onMouseScroll = CC_CALLBACK_1(ExtensionsMainLayer::onMouseScroll, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this);
addChild(_itemMenu);
}
void ExtensionsMainLayer::onTouchesBegan(const std::vector<Touch*>& touches, Event *event)
{
auto touch = static_cast<Touch*>(touches[0]);
@ -161,6 +167,30 @@ void ExtensionsMainLayer::onTouchesMoved(const std::vector<Touch*>& touches, Eve
s_tCurPos = nextPos;
}
void ExtensionsMainLayer::onMouseScroll(Event* event)
{
auto mouseEvent = static_cast<EventMouse*>(event);
float nMoveY = mouseEvent->getScrollY() * 6;
auto curPos = _itemMenu->getPosition();
auto nextPos = Point(curPos.x, curPos.y + nMoveY);
if (nextPos.y < 0.0f)
{
_itemMenu->setPosition(Point::ZERO);
return;
}
if (nextPos.y > ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height))
{
_itemMenu->setPosition(Point(0, ((g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height)));
return;
}
_itemMenu->setPosition(nextPos);
s_tCurPos = nextPos;
}
////////////////////////////////////////////////////////
//
// ExtensionsTestScene

View File

@ -15,6 +15,9 @@ public:
Menu* _itemMenu;
int _testcount;
protected:
void onMouseScroll(Event* event);
};
class ExtensionsTestScene : public TestScene