Dragging and collision filtering
In a previous recipe, we handled user input to allow the user to drag an object. In this example, we see a bowl filled with pieces of fruit that can be dragged across the screen. A piece of fruit does not collide with another piece of fruit.
Getting ready
Please refer to the project RecipeCollection02 for full working code of this recipe.
How to do it...
Execute the following code:
enum { //Collision bits for filtering CB_GROUND = 1<<0, CB_FRUIT = 1<<2, CB_BOWL = 1<<4 }; @implementation Ch4_DraggingAndFiltering -(CCLayer*) runRecipe { [super runRecipe]; [message setString:@"Pick up the fruit."]; //Create level boundaries ...
Get Cocos2d for iPhone 1 Game Development Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.