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
-
delegate
property -
minimumTouchLengthToSlide
Calibration property. Minimum moving touch length that is enough to cancel menu items and start scrolling a layer.
property -
minimumTouchLengthToChangePage
Calibration property. Minimum moving touch length that is enough to change the page, without snapping back to the previous selected page.
property -
marginOffset
Offset that can be used to let user see empty space over first or last page.
property -
stealTouches
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 -
showPagesIndicator
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 -
pagesIndicatorPosition
Position of dots center in parent coordinates. (Default value is screenWidth/2, screenHeight/4)
property -
pagesIndicatorSelectedColor
Color of dot, that represents current selected page(only one dot).
property -
pagesIndicatorNormalColor
Color of dots, that represents other pages.
property -
totalScreens
Total pages available in scrollLayer.
property -
currentScreen
Current page number, that is shown. Belongs to the [0, totalScreen] interval.
property -
pagesWidthOffset
Offset, that can be used to let user see next/previous page.
property -
pages
Returns 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.
-
– updatePages
Updates 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 currentScreen
Declared In
CCScrollLayer.h
marginOffset
Offset that can be used to let user see empty space over first or last page.
@property (readwrite, assign) CGFloat marginOffset
Declared In
CCScrollLayer.h
minimumTouchLengthToChangePage
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 minimumTouchLengthToChangePage
Declared In
CCScrollLayer.h
minimumTouchLengthToSlide
Calibration property. Minimum moving touch length that is enough to cancel menu items and start scrolling a layer.
@property (readwrite, assign) CGFloat minimumTouchLengthToSlide
Declared In
CCScrollLayer.h
pages
Returns array of pages CCLayer’s
@property (readonly) NSArray *pages
Declared In
CCScrollLayer.h
pagesIndicatorNormalColor
Color of dots, that represents other pages.
@property (readwrite, assign) ccColor4B pagesIndicatorNormalColor
Declared In
CCScrollLayer.h
pagesIndicatorPosition
Position of dots center in parent coordinates. (Default value is screenWidth/2, screenHeight/4)
@property (readwrite, assign) CGPoint pagesIndicatorPosition
Declared In
CCScrollLayer.h
pagesIndicatorSelectedColor
Color of dot, that represents current selected page(only one dot).
@property (readwrite, assign) ccColor4B pagesIndicatorSelectedColor
Declared In
CCScrollLayer.h
pagesWidthOffset
Offset, that can be used to let user see next/previous page.
@property (readwrite) CGFloat pagesWidthOffset
Declared In
CCScrollLayer.h
showPagesIndicator
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 showPagesIndicator
Declared In
CCScrollLayer.h
stealTouches
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 stealTouches
Declared In
CCScrollLayer.h
Class Methods
nodeWithLayers:widthOffset:
Creates new scrollLayer with given pages & width offset.
+ (id)nodeWithLayers:(NSArray *)layers widthOffset:(int)widthOffset
Parameters
- 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.h
Instance Methods
addPage:
Adds new page to the right end of the scroll layer.
- (void)addPage:(CCLayer *)aPage
Declared In
CCScrollLayer.h
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.
- (void)addPage:(CCLayer *)aPage withNumber:(int)pageNumber
Declared In
CCScrollLayer.h
initWithLayers:widthOffset:
Inits scrollLayer with given pages & width offset.
- (id)initWithLayers:(NSArray *)layers widthOffset:(int)widthOffset
Parameters
- 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.h
removePage:
Removes page if it’s one of scroll layers pages (not children) Does nothing if page not found.
- (void)removePage:(CCLayer *)aPage
Declared In
CCScrollLayer.h