mirror of https://github.com/axmolengine/axmol.git
[dispatcher] Adding 'Node::updateEventPriorityIndex' and making 'Node::addEventId(removeEventId)' method to be private.
This commit is contained in:
parent
06bc92ff19
commit
6f37529236
|
@ -826,7 +826,7 @@ void Node::visit()
|
|||
}
|
||||
// self draw
|
||||
this->draw();
|
||||
_eventPriority = ++_globalEventPriorityIndex;
|
||||
this->updateEventPriorityIndex();
|
||||
|
||||
for( ; i < _children->count(); i++ )
|
||||
{
|
||||
|
@ -838,7 +838,7 @@ void Node::visit()
|
|||
else
|
||||
{
|
||||
this->draw();
|
||||
_eventPriority = ++_globalEventPriorityIndex;
|
||||
this->updateEventPriorityIndex();
|
||||
}
|
||||
|
||||
// reset for next frame
|
||||
|
@ -1296,6 +1296,11 @@ void Node::resetEventPriorityIndex()
|
|||
_globalEventPriorityIndex = 0;
|
||||
}
|
||||
|
||||
void Node::updateEventPriorityIndex()
|
||||
{
|
||||
_eventPriority = ++_globalEventPriorityIndex;
|
||||
}
|
||||
|
||||
void Node::addEventId(int eventId)
|
||||
{
|
||||
_eventIds.insert(eventId);
|
||||
|
|
|
@ -1307,18 +1307,21 @@ public:
|
|||
virtual void removeAllComponents();
|
||||
/// @} end of component functions
|
||||
|
||||
|
||||
private:
|
||||
friend class Director;
|
||||
friend class EventDispatcher;
|
||||
|
||||
void addEventId(int eventId);
|
||||
void removeEventId(int eventId);
|
||||
|
||||
private:
|
||||
friend class Director;
|
||||
|
||||
static void resetEventPriorityIndex();
|
||||
|
||||
std::set<int> _eventIds;
|
||||
|
||||
protected:
|
||||
|
||||
void updateEventPriorityIndex();
|
||||
|
||||
/// lazy allocs
|
||||
void childrenAlloc(void);
|
||||
|
||||
|
|
|
@ -465,7 +465,8 @@ void RenderTexture::visit()
|
|||
transform();
|
||||
_sprite->visit();
|
||||
draw();
|
||||
|
||||
updateEventPriorityIndex();
|
||||
|
||||
if (_grid && _grid->isActive())
|
||||
{
|
||||
_grid->afterDraw(this);
|
||||
|
|
|
@ -144,7 +144,8 @@ void ParticleBatchNode::visit()
|
|||
transform();
|
||||
|
||||
draw();
|
||||
|
||||
updateEventPriorityIndex();
|
||||
|
||||
if ( _grid && _grid->isActive())
|
||||
{
|
||||
_grid->afterDraw(this);
|
||||
|
|
|
@ -156,7 +156,8 @@ void SpriteBatchNode::visit(void)
|
|||
transform();
|
||||
|
||||
draw();
|
||||
|
||||
updateEventPriorityIndex();
|
||||
|
||||
if (_grid && _grid->isActive())
|
||||
{
|
||||
_grid->afterDraw(this);
|
||||
|
|
|
@ -511,6 +511,7 @@ void Armature::visit()
|
|||
transform();
|
||||
sortAllChildren();
|
||||
draw();
|
||||
updateEventPriorityIndex();
|
||||
|
||||
// reset for next frame
|
||||
_orderOfArrival = 0;
|
||||
|
|
|
@ -79,6 +79,7 @@ void BatchNode::visit()
|
|||
transform();
|
||||
sortAllChildren();
|
||||
draw();
|
||||
updateEventPriorityIndex();
|
||||
|
||||
// reset for next frame
|
||||
_orderOfArrival = 0;
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "CCScrollView.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
NS_CC_EXT_BEGIN
|
||||
|
||||
#define SCROLL_DEACCEL_RATE 0.95f
|
||||
|
@ -571,7 +573,8 @@ void ScrollView::visit()
|
|||
|
||||
// this draw
|
||||
this->draw();
|
||||
|
||||
updateEventPriorityIndex();
|
||||
|
||||
// draw children zOrder >= 0
|
||||
for( ; i < _children->count(); i++ )
|
||||
{
|
||||
|
@ -583,6 +586,7 @@ void ScrollView::visit()
|
|||
else
|
||||
{
|
||||
this->draw();
|
||||
updateEventPriorityIndex();
|
||||
}
|
||||
|
||||
this->afterDraw();
|
||||
|
|
|
@ -90,8 +90,6 @@ public:
|
|||
*/
|
||||
bool initWithViewSize(Size size, Node* container = NULL);
|
||||
|
||||
// virtual void registerWithTouchDispatcher();
|
||||
|
||||
/**
|
||||
* Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView)
|
||||
*
|
||||
|
|
|
@ -95,10 +95,12 @@ bool HelloWorld::init()
|
|||
auto layerTouchListener = TouchEventListener::create(Touch::DispatchMode::ALL_AT_ONCE);
|
||||
layerTouchListener->onTouchesBegan = [=](const std::vector<Touch*>& touches, Event* event){
|
||||
CCLOG("layer touches began... count = %d", (int)touches.size());
|
||||
// dispatcher->removeAllListeners();
|
||||
};
|
||||
|
||||
|
||||
int layerTouchId = dispatcher->registerEventListenerWithSceneGraphPriority(layerTouchListener, this);
|
||||
int layerTouchId2 = dispatcher->registerEventListenerWithSceneGraphPriority(layerTouchListener, this);
|
||||
|
||||
auto spriteTouchListener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE);
|
||||
spriteTouchListener->setSwallowTouches(true);
|
||||
|
@ -106,6 +108,7 @@ bool HelloWorld::init()
|
|||
spriteTouchListener->onTouchBegan = [=](Touch* touch, Event* evt){
|
||||
CCLOG("Touch sprite.... began... %d, drawOrder = %d", sprite->getZOrder(), sprite->getEventPriority());
|
||||
dispatcher->unregisterEventListener(layerTouchId);
|
||||
dispatcher->unregisterEventListener(layerTouchId2);
|
||||
return false;
|
||||
};
|
||||
|
||||
|
@ -147,6 +150,7 @@ bool HelloWorld::init()
|
|||
|
||||
CCLOG("Touch sprite222.... began..zorder: %d. drawOrder: %d", sprite1->getZOrder(), sprite1->getEventPriority());
|
||||
sprite1->setColor(Color3B::BLACK);
|
||||
event->stopPropagation();
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue