Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to zoom and pan a 2D cocos2d iphone game

What's the best way to implement a pan-able zoomable game map with Cocos2d for iPhone. It would be like Mobile Safari except with a game map that doesn't fit completely on screen. Or like how it's done with Angry Birds, Cut the rope, etc.

This would not be a side scrolling game, just a fixed game area that you can zoom in/out of.

I'm new so if there are tutorials for this that would be great.

Thanks

like image 643
Chris Avatar asked Oct 15 '10 07:10

Chris


1 Answers

You absolutely should not follow the advice by Joao Caxaria, who seems to have unnecessarily reimplemented the entire UIGestureRecognizer API himself!

You can simply use UIKit's available gesture recognizers and attach them to the sharedDirector's openGLView, as specified in the chosen answer in the link below. These allow for pan, pinch, tap etc. detection. You can even use a UILongPressGestureRecognizer to detect dragging.

cocos2d-iOS - Gesture recognisers

like image 171
KomodoDave Avatar answered Sep 21 '22 06:09

KomodoDave