Skip to content

paged uiscrollview with cocos2d used in Jacob's Shapes

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE.cocos2d
Unknown
LICENSE.cocosdenshion
Notifications You must be signed in to change notification settings

yiminlong/shapes-panels

 
 

Repository files navigation

Paging UIScrollView with Previews in Cocos2D

This project shows how to create a paged UIScrollView with Previews in Cocos2D. It looks like this (video) iPhone Preview

Watch the video!

The Problem

Apple's UIScrollView paging doesn't support an arbitrary width argument. If you make a UIScrollView with a width smaller than the whole screen, then that view won't capture touches outside of that area.

Additionally, we are mixing Cocoa views and Cocos2d/OpenGL, and how they interact is not always obvious.

Basic Idea

We create a subclass of CCMenu and add panels as items. The CCMenu is scrolled as the UIScrollView is scrolled. The UIScrollView is set to be smaller than the whole screen: this gives us previews on either side of the current page. We create a full-screen TouchDelegatingView under the UIScrollView and use that to delegate touches that lie outside the UIScrollView.

There are a few custom classes mixed in, but that is the basic idea.

Panels Layers

Setup

This project uses cocos2d as a referenced project. You can see that in

Project > Edit Project Settings > User Header Search Paths

we have the environment variable $(COCOS2D_SRC). You set up this variable in:

Xcode > Preferences > Source Trees 

Then hit the plus '+' and add a variable COCOS2D_SRC to point to your cocos2d installation.

Credits

Written by Nate Murray for Jacob's Shapes, an iPhone game for toddlers.

It uses ideas and code from the following sites:

CHANGELOG

2010-09-17 - fixed how ios 4.1 deals with canceling touches

About

paged uiscrollview with cocos2d used in Jacob's Shapes

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE.cocos2d
Unknown
LICENSE.cocosdenshion

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published