Change to comply to Cocos2d-x convention

This commit is contained in:
Neo Kim 2015-06-20 17:32:39 +09:00
parent 6c212a7ddb
commit 85fc5b3f89
2 changed files with 26 additions and 38 deletions

View File

@ -55,16 +55,14 @@ _bePressed(false),
_slidTime(0.0f), _slidTime(0.0f),
_childFocusCancelOffset(5.0f), _childFocusCancelOffset(5.0f),
_bounceEnabled(false), _bounceEnabled(false),
_bouncingBack(false),
_bounceBackAttenuate(true),
_bounceBackDuration(0),
_bounceBackAccumulatedTime(0),
_inertiaScrollEnabled(true), _inertiaScrollEnabled(true),
_scrollViewEventListener(nullptr), _scrollViewEventListener(nullptr),
_scrollViewEventSelector(nullptr), _scrollViewEventSelector(nullptr),
_eventCallback(nullptr) _eventCallback(nullptr)
, m_bBouncingBack(false)
, m_bBounceBackAttenuate(true)
, m_fBounceBackDuration(0)
, m_fBounceBackAccumulatedTime(0)
{ {
setTouchEnabled(true); setTouchEnabled(true);
} }
@ -357,11 +355,11 @@ void ScrollView::startBounceBack()
{ {
static const float DEFAULT_BOUNCE_BACK_DURATION = 0.3f; static const float DEFAULT_BOUNCE_BACK_DURATION = 0.3f;
m_bBouncingBack = true; _bouncingBack = true;
m_bBounceBackAttenuate = true; _bounceBackAttenuate = true;
m_bounceBackStartPosition = _innerContainer->getPosition(); _bounceBackStartPosition = _innerContainer->getPosition();
m_fBounceBackDuration = DEFAULT_BOUNCE_BACK_DURATION; _bounceBackDuration = DEFAULT_BOUNCE_BACK_DURATION;
m_fBounceBackAccumulatedTime = 0; _bounceBackAccumulatedTime = 0;
// Calculate bounce back destination // Calculate bounce back destination
{ {
@ -382,26 +380,26 @@ void ScrollView::startBounceBack()
{ {
y = _bottomBoundary - _innerContainer->getBottomBoundary(); y = _bottomBoundary - _innerContainer->getBottomBoundary();
} }
m_bounceBackTargetDelta = Vec2(x, y); _bounceBackTargetDelta = Vec2(x, y);
} }
} }
void ScrollView::processBounceBack(float deltaTime) void ScrollView::processBounceBack(float deltaTime)
{ {
m_fBounceBackAccumulatedTime += deltaTime; _bounceBackAccumulatedTime += deltaTime;
float percentage = m_fBounceBackAccumulatedTime / m_fBounceBackDuration; float percentage = _bounceBackAccumulatedTime / _bounceBackDuration;
if(percentage >= 1) if(percentage >= 1)
{ {
_innerContainer->setPosition(m_bounceBackStartPosition + m_bounceBackTargetDelta); _innerContainer->setPosition(_bounceBackStartPosition + _bounceBackTargetDelta);
m_bBouncingBack = false; _bouncingBack = false;
} }
else else
{ {
if(m_bBounceBackAttenuate) if(_bounceBackAttenuate)
{ {
percentage = tweenfunc::expoEaseOut(percentage); percentage = tweenfunc::expoEaseOut(percentage);
} }
Vec2 moveDelta = m_bounceBackTargetDelta * percentage; Vec2 moveDelta = _bounceBackTargetDelta * percentage;
// Dispatch related events // Dispatch related events
if(moveDelta.x > 0) if(moveDelta.x > 0)
@ -420,7 +418,7 @@ void ScrollView::processBounceBack(float deltaTime)
{ {
processScrollEvent(MoveDirection::BOTTOM, true); processScrollEvent(MoveDirection::BOTTOM, true);
} }
_innerContainer->setPosition(m_bounceBackStartPosition + moveDelta); _innerContainer->setPosition(_bounceBackStartPosition + moveDelta);
} }
} }
@ -921,9 +919,9 @@ void ScrollView::startRecordSlidAction()
{ {
stopAutoScrollChildren(); stopAutoScrollChildren();
} }
if (m_bBouncingBack) if (_bouncingBack)
{ {
m_bBouncingBack = false; _bouncingBack = false;
} }
_slidTime = 0.0f; _slidTime = 0.0f;
} }
@ -1048,7 +1046,7 @@ void ScrollView::update(float dt)
{ {
autoScrollChildren(dt); autoScrollChildren(dt);
} }
if(m_bBouncingBack) if(_bouncingBack)
{ {
processBounceBack(dt); processBounceBack(dt);
} }

View File

@ -494,6 +494,12 @@ protected:
float _childFocusCancelOffset; float _childFocusCancelOffset;
bool _bounceEnabled; bool _bounceEnabled;
bool _bouncingBack;
bool _bounceBackAttenuate;
Vec2 _bounceBackStartPosition;
Vec2 _bounceBackTargetDelta;
float _bounceBackDuration;
float _bounceBackAccumulatedTime;
bool _inertiaScrollEnabled; bool _inertiaScrollEnabled;
@ -511,22 +517,6 @@ protected:
#pragma warning (pop) #pragma warning (pop)
#endif #endif
ccScrollViewCallback _eventCallback; ccScrollViewCallback _eventCallback;
// Working on new auto scroll
void startBounceBack();
void processBounceBack(float deltaTime);
bool m_bBouncingBack;
bool m_bBounceBackAttenuate;
Vec2 m_bounceBackStartPosition;
Vec2 m_bounceBackTargetDelta;
float m_fBounceBackDuration;
float m_fBounceBackAccumulatedTime;
}; };
} }