CCScrollLayer Class Reference
Overview
Scrolling layer for Menus, like iOS Springboard Screen.
It is a very clean and elegant subclass of CCLayer that lets you pass-in an array of layers and it will then create a smooth scroller. Complete with the “snapping” effect. You can create screens with anything that can be added to a CCLayer.
Tasks
-
delegateproperty -
minimumTouchLengthToSlideCalibration property. Minimum moving touch length that is enough to cancel menu items and start scrolling a layer.
property -
minimumTouchLengthToChangePageCalibration property. Minimum moving touch length that is enough to change the page, without snapping back to the previous selected page.
property -
marginOffsetOffset that can be used to let user see empty space over first or last page.
property -
stealTouchesIf YES – when starting scrolling CCScrollLayer will claim touches, that are already claimed by others targetedTouchDelegates by calling CCTouchDispatcher#touchesCancelled Usefull to have ability to scroll with touch above menus in pages. If NO – scrolling will start, but no touches will be cancelled. Default is YES.
property -
showPagesIndicatorWhenever show or not white/grey dots under the scroll layer. If yes – dots will be rendered in parents transform (rendered after scroller visit).
property -
pagesIndicatorPositionPosition of dots center in parent coordinates. (Default value is screenWidth/2, screenHeight/4)
property -
pagesIndicatorSelectedColorColor of dot, that represents current selected page(only one dot).
property -
pagesIndicatorNormalColorColor of dots, that represents other pages.
property -
totalScreensTotal pages available in scrollLayer.
property -
currentScreenCurrent page number, that is shown. Belongs to the [0, totalScreen] interval.
property -
pagesWidthOffsetOffset, that can be used to let user see next/previous page.
property -
pagesReturns array of pages CCLayer’s
property -
+ nodeWithLayers:widthOffset:Creates new scrollLayer with given pages & width offset.
-
– initWithLayers:widthOffset:Inits scrollLayer with given pages & width offset.
-
– updatePagesUpdates all pages positions & adds them as children if needed. Can be used to update position of pages after screen reshape, or for update after dynamic page add/remove.
-
– addPage:withNumber:Adds new page and reorders pages trying to set given number for newly added page. If number > pages count – adds new page to the right end of the scroll layer. If number <= 0 – adds new page to the left end of the scroll layer. @attention Designated addPage method.
-
– addPage:Adds new page to the right end of the scroll layer.
-
– removePage:Removes page if it’s one of scroll layers pages (not children) Does nothing if page not found.
-
– removePageWithNumber:Removes page with given number. Doesn nothing if there’s no page for such number.
-
– moveToPage: -
– selectPage:
Properties
currentScreen
Current page number, that is shown. Belongs to the [0, totalScreen] interval.
@property (readonly) int currentScreenDeclared In
CCScrollLayer.hmarginOffset
Offset that can be used to let user see empty space over first or last page.
@property (readwrite, assign) CGFloat marginOffsetDeclared In
CCScrollLayer.hminimumTouchLengthToChangePage
Calibration property. Minimum moving touch length that is enough to change the page, without snapping back to the previous selected page.
@property (readwrite, assign) CGFloat minimumTouchLengthToChangePageDeclared In
CCScrollLayer.hminimumTouchLengthToSlide
Calibration property. Minimum moving touch length that is enough to cancel menu items and start scrolling a layer.
@property (readwrite, assign) CGFloat minimumTouchLengthToSlideDeclared In
CCScrollLayer.hpages
Returns array of pages CCLayer’s
@property (readonly) NSArray *pagesDeclared In
CCScrollLayer.hpagesIndicatorNormalColor
Color of dots, that represents other pages.
@property (readwrite, assign) ccColor4B pagesIndicatorNormalColorDeclared In
CCScrollLayer.hpagesIndicatorPosition
Position of dots center in parent coordinates. (Default value is screenWidth/2, screenHeight/4)
@property (readwrite, assign) CGPoint pagesIndicatorPositionDeclared In
CCScrollLayer.hpagesIndicatorSelectedColor
Color of dot, that represents current selected page(only one dot).
@property (readwrite, assign) ccColor4B pagesIndicatorSelectedColorDeclared In
CCScrollLayer.hpagesWidthOffset
Offset, that can be used to let user see next/previous page.
@property (readwrite) CGFloat pagesWidthOffsetDeclared In
CCScrollLayer.hshowPagesIndicator
Whenever show or not white/grey dots under the scroll layer. If yes – dots will be rendered in parents transform (rendered after scroller visit).
@property (readwrite, assign) BOOL showPagesIndicatorDeclared In
CCScrollLayer.hstealTouches
If YES – when starting scrolling CCScrollLayer will claim touches, that are already claimed by others targetedTouchDelegates by calling CCTouchDispatcher#touchesCancelled Usefull to have ability to scroll with touch above menus in pages. If NO – scrolling will start, but no touches will be cancelled. Default is YES.
@property (readwrite) BOOL stealTouchesDeclared In
CCScrollLayer.hClass Methods
nodeWithLayers:widthOffset:
Creates new scrollLayer with given pages & width offset.
+ (id)nodeWithLayers:(NSArray *)layers widthOffset:(int)widthOffsetParameters
- layers
NSArray of CCLayers, that will be used as pages.
- widthOffset
Length in X-coord, that describes length of possible pages intersection.
Declared In
CCScrollLayer.hInstance Methods
addPage:
Adds new page to the right end of the scroll layer.
- (void)addPage:(CCLayer *)aPageDeclared In
CCScrollLayer.haddPage:withNumber:
Adds new page and reorders pages trying to set given number for newly added page. If number > pages count – adds new page to the right end of the scroll layer. If number <= 0 – adds new page to the left end of the scroll layer. @attention Designated addPage method.
- (void)addPage:(CCLayer *)aPage withNumber:(int)pageNumberDeclared In
CCScrollLayer.hinitWithLayers:widthOffset:
Inits scrollLayer with given pages & width offset.
- (id)initWithLayers:(NSArray *)layers widthOffset:(int)widthOffsetParameters
- layers
NSArray of CCLayers, that will be used as pages.
- widthOffset
Length in X-coord, that describes length of possible pages intersection.
Declared In
CCScrollLayer.hremovePage:
Removes page if it’s one of scroll layers pages (not children) Does nothing if page not found.
- (void)removePage:(CCLayer *)aPageDeclared In
CCScrollLayer.h