I’m trying to create a level loader screen.
I would like to show a list of items, each item might have an image, level name, best time, #stars etc.
I would also like to be able to touch the item (effectively the whole row) to load that level.
I would also like to be able to scroll the screen.
I already have a Scene / CCLayer that would show the levels list and load / show the correct level (replaceScene).
I plan on scrolling this by just changing the layer position.
I was thinking of creating a new class inheriting from CCNode (lets say BBLevelListItem).
This class would have the level id / file names, and add the sprites / text etc to itself (this~~>addChild).
The positioning of these sprites / text would be relative to itself.
The LevelLoaderScreen would add an array of BBLevelListItem, passing the info to the BBLevelListItem.
I would like BBLevelListItem to notify the LevelLoaderScreen that a level was clicked and pass the required info back.
I could loop round all BBLevelListItems (in onBeginTouch) and do a rectContainsPoint test, if a match occurs, get the info.
This seems an inelegant way to do it.
Is it possible to register the BBLevelListItem for touch and give it a function in LevelLoaderScreen to call passing the BBLevelListItems*
Another option I though of is to register each BBLevelListItem for targetedTouchDelegate and just replace the scene from that BBLevelListItem class. Is there any issue with this?