ScrollView support for cocos2d for iphone. It provides scroll view functionalities to cocos2d projects natively.
Class CCScrollView
#include <Geode/cocos/extensions/GUI/CCScrollView/CCScrollView.h>Examples0
Public static methods2
staticcocos2d::extension::CCScrollView*create(cocos2d::CCSizesize,cocos2d::CCNode*container)
Returns an autoreleased scroll view object.
size
container
staticcocos2d::extension::CCScrollView*create()
Returns an autoreleased scroll view object.
size
container
Public member functions44
virtualboolinit()
virtualvoidregisterWithTouchDispatcher()
boolinitWithViewSize(cocos2d::CCSizesize,cocos2d::CCNode*container)
Returns a scroll view object
size
container
voidsetContentOffset(cocos2d::CCPointoffset,boolanimated)
Sets a new content offset. It ignores max/min offset. It just sets what’s given. (just like UIKit’s UIScrollView)
offset
If
cocos2d::CCPointgetContentOffset()
voidsetContentOffsetInDuration(cocos2d::CCPointoffset,floatdt)
Sets a new content offset. It ignores max/min offset. It just sets what’s given. (just like UIKit’s UIScrollView) You can override the animation duration with this method.
offset
animation
voidsetZoomScale(,boolanimated)
Sets a new scale and does that for a predefined duration.
s
animated
floatgetZoomScale()
voidsetZoomScaleInDuration(,floatdt)
Sets a new scale for container in a given duration.
s
animation
cocos2d::CCPointminContainerOffset()
Returns the current container’s minimum offset. You may want this while you animate scrolling by yourself
cocos2d::CCPointmaxContainerOffset()
Returns the current container’s maximum offset. You may want this while you animate scrolling by yourself
boolisNodeVisible(cocos2d::CCNode*node)
Determines if a given node’s bounding box is in visible bounds
voidpause(cocos2d::CCObject*sender)
Provided to make scroll view compatible with SWLayer’s pause method
voidresume(cocos2d::CCObject*sender)
Provided to make scroll view compatible with SWLayer’s resume method
boolisDragging()
boolisTouchMoved()
boolisBounceable()
cocos2d::CCSizegetViewSize()
size to clip. CCNode boundingBox uses contentSize directly. It’s semantically different what it actually means to common scroll views. Hence, this scroll view will use a separate size property.
voidsetViewSize(cocos2d::CCSizesize)
cocos2d::CCNode*getContainer()
voidsetContainer(cocos2d::CCNode*pContainer)
cocos2d::extension::CCScrollViewDirectiongetDirection()
direction allowed to scroll. CCScrollViewDirectionBoth by default.
virtualvoidsetDirection()
cocos2d::extension::CCScrollViewDelegate*getDelegate()
voidsetDelegate()
virtualboolccTouchBegan(cocos2d::CCTouch*pTouch,cocos2d::CCEvent*pEvent)
override functions
virtualvoidccTouchMoved(cocos2d::CCTouch*pTouch,cocos2d::CCEvent*pEvent)
virtualvoidccTouchEnded(cocos2d::CCTouch*pTouch,cocos2d::CCEvent*pEvent)
virtualvoidccTouchCancelled(cocos2d::CCTouch*pTouch,cocos2d::CCEvent*pEvent)
virtualvoidsetContentSize()
virtualcocos2d::CCSizeconst&getContentSize()const
voidupdateInset()
boolisClippingToBounds()
Determines whether it clips its children or not.
virtualvoidvisit()
virtualvoidaddChild(cocos2d::CCNode*child,intzOrder,inttag)
virtualvoidaddChild(cocos2d::CCNode*child,intzOrder)
virtualvoidaddChild(cocos2d::CCNode*child)
Fields23
floatm_fZoomScale;
current zoom scale
floatm_fMinZoomScale;
min zoom scale
floatm_fMaxZoomScale;
max zoom scale
cocos2d::extension::CCScrollViewDelegate*m_pDelegate;
scroll view delegate
cocos2d::extension::CCScrollViewDirectionm_eDirection;
boolm_bDragging;
If YES, the view is being dragged.
cocos2d::CCPointm_tContentOffset;
Content offset. Note that left-bottom point is the origin
cocos2d::CCNode*m_pContainer;
Container holds scroll view contents, Sets the scrollable container object of the scroll view
boolm_bTouchMoved;
Determiens whether user touch is moved after begin phase.
cocos2d::CCPointm_fMaxInset;
max inset point to limit scrolling by touch
cocos2d::CCPointm_fMinInset;
min inset point to limit scrolling by touch
boolm_bBounceable;
Determines whether the scroll view is allowed to bounce or not.
boolm_bClippingToBounds;
cocos2d::CCPointm_tScrollDistance;
scroll speed
cocos2d::CCPointm_tTouchPoint;
Touch point
floatm_fTouchLength;
length between two fingers
cocos2d::CCArray*m_pTouches;
UITouch objects to detect multitouch
cocos2d::CCSizem_tViewSize;
size to clip. CCNode boundingBox uses contentSize directly. It’s semantically different what it actually means to common scroll views. Hence, this scroll view will use a separate size property.
floatm_fMinScale;
max and min scale
floatm_fMaxScale;
max and min scale
cocos2d::CCRectm_tParentScissorRect;
scissor rect for parent, just for restoring GL_SCISSOR_BOX