public override void ccTouchMoved (UITouch touch)
{
if( scrollTouch_ != touch ) {
return;
}
Vector2 touchPoint = this.convertTouchToNodeSpace (touch);
touchPoint = this.convertToWorldSpace (touchPoint);
// If finger is dragged for more distance then minimum - start sliding and cancel pressed buttons.
// Of course only if we not already in sliding mode
if ( (state_ != kCCScrollLayerState.Sliding)
&& (Mathf.Abs(touchPoint.x-startSwipe_) >= this.minimumTouchLengthToSlide) )
{
state_ = kCCScrollLayerState.Sliding;
// Avoid jerk after state change.
startSwipe_ = touchPoint.x;
if (this.stealTouches)
{
this.claimTouch(touch);
}
if(this.delegate_ != null)
this.delegate_.scrollLayerDraging(this);
}
if (state_ == kCCScrollLayerState.Sliding)
{
float desiredX = (- currentScreen_ * (this.contentSize.x - this.pagesWidthOffset)) + touchPoint.x - startSwipe_;
int page = this.pageNumberForPosition(new Vector2(desiredX, 0));
float offset = desiredX - this.positionForPageWithNumber(page).x;
if ((page == 0 && FloatUtils.Big(offset , 0)) || (page == layers_.Count - 1 && FloatUtils.Small(offset , 0)))
offset -= marginOffset_ * offset / CCDirector.sharedDirector.winSize.x;
else
offset = 0;
this.position = new Vector2(desiredX - offset, 0);
}
}