Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jashmenn/shapes-panels

paged uiscrollview with cocos2d used in Jacob's Shapes
https://github.com/jashmenn/shapes-panels

Last synced: 3 months ago
JSON representation

paged uiscrollview with cocos2d used in Jacob's Shapes

Awesome Lists containing this project

README

        

# Paging UIScrollView with Previews in Cocos2D

This project shows how to create a paged UIScrollView with Previews
in Cocos2D. It looks like this ([video](http://www.youtube.com/watch?v=2IgbRzGfBHk&fmt=22))
![iPhone Preview](https://github.com/jashmenn/shapes-panels/raw/master/Resources/iphone-preview.jpg)

[Watch the video!](http://www.youtube.com/watch?v=2IgbRzGfBHk&fmt=22)

# 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](https://github.com/jashmenn/shapes-panels/raw/master/Resources/shapes-panels-post.jpg)

# 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](http://www.littlehiccup.com), an
iPhone game for toddlers.

It uses ideas and code from the following sites:

* [http://getsetgames.com/2009/08/21/cocos2d-and-uiscrollview/](http://getsetgames.com/2009/08/21/cocos2d-and-uiscrollview/)
* [http://blog.proculo.de/archives/180-Paging-enabled-UIScrollView-With-Previews.html](http://blog.proculo.de/archives/180-Paging-enabled-UIScrollView-With-Previews.html)

# CHANGELOG

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