Giter Site home page Giter Site logo

shapes-panels's Introduction

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

shapes-panels's People

Contributors

jashmenn avatar

Stargazers

Ahmed El khateeb avatar

Watchers

James Cloos avatar Ahmed El khateeb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.