mirror of https://github.com/axmolengine/axmol.git
Merge branch 'newRenderer' of github.com:darkdukey/cocos2d-x into newRenderer
This commit is contained in:
commit
8bd838ddfc
|
@ -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
|
||||
|
|
|
@ -15,6 +15,9 @@ public:
|
|||
Menu* _itemMenu;
|
||||
|
||||
int _testcount;
|
||||
|
||||
protected:
|
||||
void onMouseScroll(Event* event);
|
||||
};
|
||||
|
||||
class ExtensionsTestScene : public TestScene
|
||||
|
|
Loading…
Reference in New Issue