Taking and using screenshots
As hinted in the last recipe, in-game screenshots can be taken and used in-game to create cool effects like a blurred background for a pause menu. For an example of this in a published app, take a look at the pause menu in 2K Sports NHL 2K11.
Getting ready
Please refer to the project RecipeCollection01
for full working code of this recipe. Also note the included library Screenshot
that is not included in the book itself.
How to do it...
Execute the following code:
#import "Screenshot.h" @implementation Ch1_TakingScreenshots -(CCLayer*) runRecipe { CCSprite* sprite = [CCSprite spriteWithTexture:[Screenshot takeAsTexture2D]]; ...
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.