├── .gitattributes ├── .gitignore ├── Classes ├── AdRootViewController.h ├── AdRootViewController.m ├── GameConfig.h ├── HelloWorldScene.h ├── HelloWorldScene.m ├── iAdsTestAppDelegate.h └── iAdsTestAppDelegate.m ├── GoogleAdMobAdsSDK ├── GADBannerView.h ├── GADBannerViewDelegate.h ├── GADInterstitial.h ├── GADInterstitialDelegate.h ├── GADRequest.h ├── GADRequestError.h ├── README.txt └── libGoogleAdMobAds.a ├── LICENSE.cocos2d ├── LICENSE.cocosdenshion ├── README.markdown ├── Resources ├── Info.plist └── fps_images.png ├── iAdsTest.xcodeproj ├── jandrad.mode1v3 ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── jandrad.xcuserdatad │ ├── xcdebugger │ └── Breakpoints.xcbkptlist │ └── xcschemes │ ├── cocos2d libraries.xcscheme │ ├── iAdsTest.xcscheme │ └── xcschememanagement.plist ├── iAdsTest_Prefix.pch ├── libs ├── FontLabel │ ├── FontLabel.h │ ├── FontLabel.m │ ├── FontLabelStringDrawing.h │ ├── FontLabelStringDrawing.m │ ├── FontManager.h │ ├── FontManager.m │ ├── ZAttributedString.h │ ├── ZAttributedString.m │ ├── ZAttributedStringPrivate.h │ ├── ZFont.h │ └── ZFont.m ├── TouchJSON │ ├── CDataScanner.h │ ├── CDataScanner.m │ ├── Extensions │ │ ├── CDataScanner_Extensions.h │ │ ├── CDataScanner_Extensions.m │ │ ├── NSDictionary_JSONExtensions.h │ │ └── NSDictionary_JSONExtensions.m │ └── JSON │ │ ├── CJSONDeserializer.h │ │ ├── CJSONDeserializer.m │ │ ├── CJSONScanner.h │ │ ├── CJSONScanner.m │ │ ├── CJSONSerializer.h │ │ ├── CJSONSerializer.m │ │ └── JSONRepresentation.h └── cocos2d │ ├── CCAction.h │ ├── CCAction.m │ ├── CCActionCamera.h │ ├── CCActionCamera.m │ ├── CCActionEase.h │ ├── CCActionEase.m │ ├── CCActionGrid.h │ ├── CCActionGrid.m │ ├── CCActionGrid3D.h │ ├── CCActionGrid3D.m │ ├── CCActionInstant.h │ ├── CCActionInstant.m │ ├── CCActionInterval.h │ ├── CCActionInterval.m │ ├── CCActionManager.h │ ├── CCActionManager.m │ ├── CCActionPageTurn3D.h │ ├── CCActionPageTurn3D.m │ ├── CCActionProgressTimer.h │ ├── CCActionProgressTimer.m │ ├── CCActionTiledGrid.h │ ├── CCActionTiledGrid.m │ ├── CCActionTween.h │ ├── CCActionTween.m │ ├── CCAnimation.h │ ├── CCAnimation.m │ ├── CCAnimationCache.h │ ├── CCAnimationCache.m │ ├── CCAtlasNode.h │ ├── CCAtlasNode.m │ ├── CCBlockSupport.h │ ├── CCBlockSupport.m │ ├── CCCamera.h │ ├── CCCamera.m │ ├── CCConfiguration.h │ ├── CCConfiguration.m │ ├── CCDirector.h │ ├── CCDirector.m │ ├── CCDrawingPrimitives.h │ ├── CCDrawingPrimitives.m │ ├── CCGrabber.h │ ├── CCGrabber.m │ ├── CCGrid.h │ ├── CCGrid.m │ ├── CCLabelAtlas.h │ ├── CCLabelAtlas.m │ ├── CCLabelBMFont.h │ ├── CCLabelBMFont.m │ ├── CCLabelTTF.h │ ├── CCLabelTTF.m │ ├── CCLayer.h │ ├── CCLayer.m │ ├── CCMenu.h │ ├── CCMenu.m │ ├── CCMenuItem.h │ ├── CCMenuItem.m │ ├── CCMotionStreak.h │ ├── CCMotionStreak.m │ ├── CCNode.h │ ├── CCNode.m │ ├── CCParallaxNode.h │ ├── CCParallaxNode.m │ ├── CCParticleExamples.h │ ├── CCParticleExamples.m │ ├── CCParticleSystem.h │ ├── CCParticleSystem.m │ ├── CCParticleSystemPoint.h │ ├── CCParticleSystemPoint.m │ ├── CCParticleSystemQuad.h │ ├── CCParticleSystemQuad.m │ ├── CCProgressTimer.h │ ├── CCProgressTimer.m │ ├── CCProtocols.h │ ├── CCRenderTexture.h │ ├── CCRenderTexture.m │ ├── CCRibbon.h │ ├── CCRibbon.m │ ├── CCScene.h │ ├── CCScene.m │ ├── CCScheduler.h │ ├── CCScheduler.m │ ├── CCSprite.h │ ├── CCSprite.m │ ├── CCSpriteBatchNode.h │ ├── CCSpriteBatchNode.m │ ├── CCSpriteFrame.h │ ├── CCSpriteFrame.m │ ├── CCSpriteFrameCache.h │ ├── CCSpriteFrameCache.m │ ├── CCTMXLayer.h │ ├── CCTMXLayer.m │ ├── CCTMXObjectGroup.h │ ├── CCTMXObjectGroup.m │ ├── CCTMXTiledMap.h │ ├── CCTMXTiledMap.m │ ├── CCTMXXMLParser.h │ ├── CCTMXXMLParser.m │ ├── CCTexture2D.h │ ├── CCTexture2D.m │ ├── CCTextureAtlas.h │ ├── CCTextureAtlas.m │ ├── CCTextureCache.h │ ├── CCTextureCache.m │ ├── CCTexturePVR.h │ ├── CCTexturePVR.m │ ├── CCTileMapAtlas.h │ ├── CCTileMapAtlas.m │ ├── CCTransition.h │ ├── CCTransition.m │ ├── CCTransitionPageTurn.h │ ├── CCTransitionPageTurn.m │ ├── CCTransitionRadial.h │ ├── CCTransitionRadial.m │ ├── Platforms │ ├── CCGL.h │ ├── CCNS.h │ ├── Mac │ │ ├── CCDirectorMac.h │ │ ├── CCDirectorMac.m │ │ ├── CCEventDispatcher.h │ │ ├── CCEventDispatcher.m │ │ ├── MacGLView.h │ │ ├── MacGLView.m │ │ ├── MacWindow.h │ │ └── MacWindow.m │ └── iOS │ │ ├── CCDirectorIOS.h │ │ ├── CCDirectorIOS.m │ │ ├── CCTouchDelegateProtocol.h │ │ ├── CCTouchDispatcher.h │ │ ├── CCTouchDispatcher.m │ │ ├── CCTouchHandler.h │ │ ├── CCTouchHandler.m │ │ ├── EAGLView.h │ │ ├── EAGLView.m │ │ ├── ES1Renderer.h │ │ ├── ES1Renderer.m │ │ ├── ESRenderer.h │ │ ├── glu.c │ │ └── glu.h │ ├── Support │ ├── CCArray.h │ ├── CCArray.m │ ├── CCFileUtils.h │ ├── CCFileUtils.m │ ├── CCProfiling.h │ ├── CCProfiling.m │ ├── CGPointExtension.h │ ├── CGPointExtension.m │ ├── OpenGL_Internal.h │ ├── TGAlib.h │ ├── TGAlib.m │ ├── TransformUtils.h │ ├── TransformUtils.m │ ├── ZipUtils.h │ ├── ZipUtils.m │ ├── base64.c │ ├── base64.h │ ├── ccCArray.h │ ├── ccUtils.c │ ├── ccUtils.h │ ├── uthash.h │ └── utlist.h │ ├── ccConfig.h │ ├── ccMacros.h │ ├── ccTypes.h │ ├── cocos2d.h │ └── cocos2d.m └── main.m /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -crlf -diff -merge -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # XCode noise 2 | PLBlocks.framework/* 3 | *.pbxuser 4 | *.mode1v3 5 | *.pyc 6 | *~.nib/ 7 | *.perspective 8 | *.perspectivev3 9 | *.xcworkspace/ 10 | xcuserdata/ 11 | build/ 12 | 13 | # old school 14 | .svn 15 | 16 | # osx noise 17 | .DS_store 18 | .DS_Store 19 | *.xcuserstate 20 | 21 | /iAdsTest.xcodeproj/project.xcworkspace/xcuserdata/jandrad.xcuserdatad/UserInterfaceState.xcuserstate 22 | /libs/.DS_Store -------------------------------------------------------------------------------- /Classes/AdRootViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AdRootViewController.h 3 | // iAdsTest 4 | // 5 | // Created by Jose Andrade on 2/1/11. 6 | // Copyright Jose Andrade 2011. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "GADBannerViewDelegate.h" 12 | #import "GADInterstitialDelegate.h" 13 | 14 | enum 15 | { 16 | kAdBannerPositionTop = 0, 17 | kAdBannerPositionBottom, 18 | }; 19 | 20 | @protocol AdViewControllerDelegate; 21 | 22 | @interface AdRootViewController : UIViewController 23 | { 24 | id adDelegate; 25 | 26 | //Banners: 27 | id adBannerView; 28 | GADBannerView* adMobAd; 29 | UIView* adContainerView; 30 | 31 | //Interstitial Ads: 32 | GADInterstitial *interstitialAd; 33 | 34 | 35 | int adBannerPosition; 36 | BOOL adBannerViewIsVisible; 37 | } 38 | 39 | @property (nonatomic, assign) id adDelegate; 40 | @property(nonatomic, readwrite, assign) int adBannerPosition; 41 | 42 | - (void)addBannerAd; 43 | - (void)removeBannerAd; 44 | 45 | - (void)addInterstitialAd; 46 | - (void)removeInterstitialAd; 47 | 48 | - (void)rotateBannerViewWithDirector:(UIDeviceOrientation)toDeviceOrientation animate:(BOOL)animate; 49 | - (void)rotateBannerViewWithUIViewController:(UIInterfaceOrientation)toInterfaceOrientation animate:(BOOL)animate; 50 | 51 | - (void)updateBannerViewOrientation; 52 | - (void)updateBannerViewOrientationWithAnimation:(BOOL)animate; 53 | 54 | @end 55 | 56 | @protocol AdViewControllerDelegate 57 | 58 | @optional 59 | - (void)adController:(AdRootViewController*)controller didLoadiAd:(id)iadBanner; 60 | - (void)adController:(AdRootViewController*)controller didFailedToRecieveiAd:(id)iadBanner; 61 | 62 | - (void)adController:(AdRootViewController*)controller didLoadAdMobAd:(GADBannerView*)adMobBanner; 63 | - (void)adController:(AdRootViewController*)controller didFailedToRecieveAdMobAd:(GADBannerView*)adMobBanner; 64 | 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Classes/GameConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // GameConfig.h 3 | // iAdsTest 4 | // 5 | // Created by Jose Andrade on 2/1/11. 6 | // Copyright Jose Andrade 2011. All rights reserved. 7 | // 8 | 9 | #ifndef __GAME_CONFIG_H 10 | #define __GAME_CONFIG_H 11 | 12 | // 13 | // Supported Autorotations: 14 | // None, 15 | // UIViewController, 16 | // CCDirector 17 | // 18 | #define kGameAutorotationNone 0 19 | #define kGameAutorotationCCDirector 1 20 | #define kGameAutorotationUIViewController 2 21 | 22 | // 23 | // Define here the type of autorotation that you want for your game 24 | // 25 | //#define GAME_AUTOROTATION kGameAutorotationCCDirector 26 | #define GAME_AUTOROTATION kGameAutorotationUIViewController 27 | //#define GAME_AUTOROTATION kGameAutorotationNone 28 | 29 | #endif // __GAME_CONFIG_H 30 | -------------------------------------------------------------------------------- /Classes/HelloWorldScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // HelloWorldScene.h 3 | // iAdsTest 4 | // 5 | // Created by Jose Andrade on 2/1/11. 6 | // Copyright Jose Andrade 2011. All rights reserved. 7 | // 8 | 9 | 10 | // When you import this file, you import all the cocos2d classes 11 | #import "cocos2d.h" 12 | 13 | // HelloWorld Layer 14 | @interface HelloWorld : CCLayerColor 15 | { 16 | } 17 | 18 | // returns a Scene that contains the HelloWorld as the only child 19 | +(id) scene; 20 | 21 | -(void)updatePositions; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /Classes/iAdsTestAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // iAdsTestAppDelegate.h 3 | // iAdsTest 4 | // 5 | // Created by Jose Andrade on 2/1/11. 6 | // Copyright Jose Andrade 2011. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class AdRootViewController; 12 | 13 | @interface iAdsTestAppDelegate : NSObject 14 | { 15 | UIWindow *window; 16 | AdRootViewController *viewController; 17 | } 18 | 19 | @property (nonatomic, retain) UIWindow *window; 20 | @property (nonatomic, retain) AdRootViewController *viewController; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /GoogleAdMobAdsSDK/GADBannerViewDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // GADBannerViewDelegate.h 3 | // Google AdMob Ads SDK 4 | // 5 | // Copyright 2011 Google Inc. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @class GADRequestError; 11 | @class GADBannerView; 12 | 13 | // Delegate for receiving state change messages from a GADBannerView such as ad 14 | // requests succeeding/failing or when an ad has been clicked. 15 | @protocol GADBannerViewDelegate 16 | 17 | @optional 18 | 19 | #pragma mark Ad Request Lifecycle Notifications 20 | 21 | // Sent when an ad request loaded an ad. This is a good opportunity to add this 22 | // view to the hierarchy if it has not yet been added. If the ad was received 23 | // as a part of the server-side auto refreshing, you can examine the 24 | // hasAutoRefreshed property of the view. 25 | - (void)adViewDidReceiveAd:(GADBannerView *)view; 26 | 27 | // Sent when an ad request failed. Normally this is because no network 28 | // connection was available or no ads were available (i.e. no fill). If the 29 | // error was received as a part of the server-side auto refreshing, you can 30 | // examine the hasAutoRefreshed property of the view. 31 | - (void)adView:(GADBannerView *)view 32 | didFailToReceiveAdWithError:(GADRequestError *)error; 33 | 34 | #pragma mark Click-Time Lifecycle Notifications 35 | 36 | // Sent just before presenting the user a full screen view, such as a browser, 37 | // in response to clicking on an ad. Use this opportunity to stop animations, 38 | // time sensitive interactions, etc. 39 | // 40 | // Normally the user looks at the ad, dismisses it, and control returns to your 41 | // application by calling adViewDidDismissScreen:. However if the user hits the 42 | // Home button or clicks on an App Store link your application will end. On iOS 43 | // 4.0+ the next method called will be applicationWillResignActive: of your 44 | // UIViewController (UIApplicationWillResignActiveNotification). Immediately 45 | // after that adViewWillLeaveApplication: is called. 46 | - (void)adViewWillPresentScreen:(GADBannerView *)adView; 47 | 48 | // Sent just before dismissing a full screen view. 49 | - (void)adViewWillDismissScreen:(GADBannerView *)adView; 50 | 51 | // Sent just after dismissing a full screen view. Use this opportunity to 52 | // restart anything you may have stopped as part of adViewWillPresentScreen:. 53 | - (void)adViewDidDismissScreen:(GADBannerView *)adView; 54 | 55 | // Sent just before the application will background or terminate because the 56 | // user clicked on an ad that will launch another application (such as the App 57 | // Store). The normal UIApplicationDelegate methods, like 58 | // applicationDidEnterBackground:, will be called immediately before this. 59 | - (void)adViewWillLeaveApplication:(GADBannerView *)adView; 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /GoogleAdMobAdsSDK/GADInterstitial.h: -------------------------------------------------------------------------------- 1 | // 2 | // GADInterstitial.h 3 | // Google AdMob Ads SDK 4 | // 5 | // Copyright 2011 Google Inc. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import "GADInterstitialDelegate.h" 11 | #import "GADRequest.h" 12 | #import "GADRequestError.h" 13 | 14 | // An interstitial ad. This is a full-screen advertisement shown at natural 15 | // transition points in your application such as between game levels or news 16 | // stories. 17 | // 18 | // Interstitials are shown sparingly. Expect low to no fill. 19 | @interface GADInterstitial : NSObject 20 | 21 | #pragma mark Pre-Request 22 | 23 | // Required value created in the AdSense website. Create a new ad unit for 24 | // every unique placement of an ad in your application. Set this to the ID 25 | // assigned for this placement. Ad units are important for targeting and stats. 26 | // Example values for different request types: 27 | // AdMob: a0123456789ABCD 28 | // DFP: /0123/ca-pub-0123456789012345/my-ad-identifier 29 | // AdSense: ca-mb-app-pub-0123456789012345/my-ad-identifier 30 | @property (nonatomic, copy) NSString *adUnitID; 31 | 32 | // Optional delegate object that receives state change notifications from this 33 | // GADInterstitalAd. Remember to nil the delegate before deallocating this 34 | // object. 35 | @property (nonatomic, assign) NSObject *delegate; 36 | 37 | #pragma mark Making an Ad Request 38 | 39 | // Makes an interstitial ad request. Additional targeting options can be 40 | // supplied with a request object. Only one interstitial request is allowed at 41 | // a time. 42 | // 43 | // This is best to do several seconds before the interstitial is needed to 44 | // preload its content. Then when transitioning between view controllers show 45 | // the interstital with presentFromViewController. 46 | - (void)loadRequest:(GADRequest *)request; 47 | 48 | #pragma mark Request at Application Launch 49 | 50 | // The |window| will be shown with the |image| displayed until either the 51 | // |request| interstitial is shown or a timeout occurs. The delegate will 52 | // receive an interstitialDidDismissScreen: callback to indicate that your app 53 | // should continue when the interstitial has finished. 54 | - (void)loadAndDisplayRequest:(GADRequest *)request 55 | usingWindow:(UIWindow *)window 56 | initialImage:(UIImage *)image; 57 | 58 | #pragma mark Post-Request 59 | 60 | // Returns YES if the interstitial is ready to be displayed. The delegate's 61 | // interstitialAdDidReceiveAd: will be called when this switches from NO to YES. 62 | @property (nonatomic, readonly) BOOL isReady; 63 | 64 | // Presents the interstitial ad which takes over the entire screen until the 65 | // user dismisses it. This has no effect unless isReady returns YES and/or the 66 | // delegate's interstitialDidReceiveAd: has been received. 67 | // 68 | // Set rootViewController to the current view controller at the time this method 69 | // is called. If your application does not use view controllers pass in nil and 70 | // your views will be removed from the window to show the interstitial and 71 | // restored when done. After the interstitial has been removed, the delegate's 72 | // interstitialDidDismissScreen: will be called. 73 | - (void)presentFromRootViewController:(UIViewController *)rootViewController; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /GoogleAdMobAdsSDK/GADInterstitialDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // GADInterstitialDelegate.h 3 | // Google AdMob Ads SDK 4 | // 5 | // Copyright 2011 Google Inc. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @class GADInterstitial; 11 | @class GADRequestError; 12 | 13 | // Delegate for receiving state change messages from a GADInterstitial such as 14 | // interstitial ad requests succeeding/failing. 15 | @protocol GADInterstitialDelegate 16 | 17 | @optional 18 | 19 | #pragma mark Ad Request Lifecycle Notifications 20 | 21 | // Sent when an interstitial ad request succeeded. Show it at the next 22 | // transition point in your application such as when transitioning between view 23 | // controllers. 24 | - (void)interstitialDidReceiveAd:(GADInterstitial *)ad; 25 | 26 | // Sent when an interstitial ad request completed without an interstitial to 27 | // show. This is common since interstitials are shown sparingly to users. 28 | - (void)interstitial:(GADInterstitial *)ad 29 | didFailToReceiveAdWithError:(GADRequestError *)error; 30 | 31 | #pragma mark Display-Time Lifecycle Notifications 32 | 33 | // Sent just before presenting an interstitial. After this method finishes the 34 | // interstitial will animate onto the screen. Use this opportunity to stop 35 | // animations and save the state of your application in case the user leaves 36 | // while the interstitial is on screen (e.g. to visit the App Store from a link 37 | // on the interstitial). 38 | - (void)interstitialWillPresentScreen:(GADInterstitial *)ad; 39 | 40 | // Sent before the interstitial is to be animated off the screen. 41 | - (void)interstitialWillDismissScreen:(GADInterstitial *)ad; 42 | 43 | // Sent just after dismissing an interstitial and it has animated off the 44 | // screen. 45 | - (void)interstitialDidDismissScreen:(GADInterstitial *)ad; 46 | 47 | // Sent just before the application will background or terminate because the 48 | // user clicked on an ad that will launch another application (such as the App 49 | // Store). The normal UIApplicationDelegate methods, like 50 | // applicationDidEnterBackground:, will be called immediately before this. 51 | - (void)interstitialWillLeaveApplication:(GADInterstitial *)ad; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /GoogleAdMobAdsSDK/GADRequest.h: -------------------------------------------------------------------------------- 1 | // 2 | // GADRequest.h 3 | // Google AdMob Ads SDK 4 | // 5 | // Copyright 2011 Google Inc. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | // Constant for getting test ads on the simulator using the testDevices method. 12 | #define GAD_SIMULATOR_ID @"Simulator" 13 | 14 | // Genders to help deliver more relevant ads. 15 | typedef enum { 16 | kGADGenderUnknown, 17 | kGADGenderMale, 18 | kGADGenderFemale 19 | } GADGender; 20 | 21 | // Specifies optional parameters for ad requests. 22 | @interface GADRequest : NSObject 23 | 24 | // Creates an autoreleased GADRequest. 25 | + (GADRequest *)request; 26 | 27 | // Reserved for future use. 28 | @property (nonatomic, retain) NSDictionary *additionalParameters; 29 | 30 | #pragma mark Collecting SDK Information 31 | 32 | // Returns the version of the SDK. 33 | + (NSString *)sdkVersion; 34 | 35 | #pragma mark Testing 36 | 37 | // Test ads are returned to these devices. Device identifiers are the same used 38 | // to register as a development device with Apple. To obtain a value open the 39 | // Organizer (Window -> Organizer from Xcode), control-click or right-click on 40 | // the device's name, and choose "Copy Device Identifier". Alternatively you 41 | // can obtain it through code using [[UIDevice currentDevice] uniqueIdentifier]. 42 | // 43 | // For example: 44 | // request.testDevices = [NSArray arrayWithObjects: 45 | // GAD_SIMULATOR_ID, // Simulator 46 | // //@"28ab37c3902621dd572509110745071f0101b124", // Test iPhone 3G 3.0.1 47 | // @"8cf09e81ef3ec5418c3450f7954e0e95db8ab200", // Test iPod 4.3.1 48 | // nil]; 49 | @property (nonatomic, retain) NSArray *testDevices; 50 | 51 | #pragma mark User Information 52 | 53 | // The user's gender may be used to deliver more relevant ads. 54 | @property (nonatomic, assign) GADGender gender; 55 | 56 | // The user's birthday may be used to deliver more relevant ads. 57 | @property (nonatomic, retain) NSDate *birthday; 58 | - (void)setBirthdayWithMonth:(NSInteger)m day:(NSInteger)d year:(NSInteger)y; 59 | 60 | // The user's current location may be used to deliver more relevant ads. 61 | // However do not use Core Location just for advertising, make sure it is used 62 | // for more beneficial reasons as well. It is both a good idea and part of 63 | // Apple's guidelines. 64 | - (void)setLocationWithLatitude:(CGFloat)latitude longitude:(CGFloat)longitude 65 | accuracy:(CGFloat)accuracyInMeters; 66 | 67 | // When Core Location isn't available but the user's location is known supplying 68 | // it here may deliver more relevant ads. It can be any free-form text such as 69 | // @"Champs-Elysees Paris" or @"94041 US". 70 | - (void)setLocationWithDescription:(NSString *)locationDescription; 71 | 72 | #pragma mark Contextual Information 73 | 74 | // A keyword is a word or phrase describing the current activity of the user 75 | // such as @"Sports Scores". Each keyword is an NSString in the NSArray. To 76 | // clear the keywords set this to nil. 77 | @property (nonatomic, retain) NSMutableArray *keywords; 78 | 79 | // Convenience method for adding keywords one at a time such as @"Sports Scores" 80 | // and then @"Football". 81 | - (void)addKeyword:(NSString *)keyword; 82 | 83 | #pragma mark - 84 | #pragma mark Deprecated Methods 85 | 86 | // Please use testDevices instead. 87 | @property (nonatomic, getter=isTesting) BOOL testing; 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /GoogleAdMobAdsSDK/GADRequestError.h: -------------------------------------------------------------------------------- 1 | // 2 | // GADRequestError.h 3 | // Google AdMob Ads SDK 4 | // 5 | // Copyright 2011 Google Inc. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @class GADRequest; 11 | 12 | extern NSString *kGADErrorDomain; 13 | 14 | // NSError codes for GAD error domain. 15 | typedef enum { 16 | // The ad request is invalid. The localizedFailureReason error description 17 | // will have more details. Typically this is because the ad did not have the 18 | // ad unit ID or root view controller set. 19 | kGADErrorInvalidRequest, 20 | 21 | // The ad request was successful, but no ad was returned. 22 | kGADErrorNoFill, 23 | 24 | // There was an error loading data from the network. 25 | kGADErrorNetworkError, 26 | 27 | // The ad server experienced a failure processing the request. 28 | kGADErrorServerError, 29 | 30 | // The current device's OS is below the minimum required version. 31 | kGADErrorOSVersionTooLow, 32 | 33 | // The request was unable to be loaded before being timed out. 34 | kGADErrorTimeout, 35 | 36 | } GADErrorCode; 37 | 38 | // This class represents the error generated due to invalid request parameters. 39 | @interface GADRequestError : NSError 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /GoogleAdMobAdsSDK/README.txt: -------------------------------------------------------------------------------- 1 | ============================ 2 | Google AdMob Ads SDK for iOS 3 | ============================ 4 | 5 | This is the Google AdMob Ad SDK for iOS. 6 | 7 | Requirements: 8 | - A Google AdSense or AdMob publisher ID. 9 | - Xcode 3.2 or later; iOS SDK 4.2 or later. 10 | - Runtime of iOS 3.0 or later. 11 | 12 | The latest documentation and code samples are available at: 13 | http://code.google.com/mobile/ads/docs/ios 14 | -------------------------------------------------------------------------------- /GoogleAdMobAdsSDK/libGoogleAdMobAds.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jandrad/AdRootViewController/2f1de2b30d48ae0266de3e54525840573e36fafb/GoogleAdMobAdsSDK/libGoogleAdMobAds.a -------------------------------------------------------------------------------- /LICENSE.cocos2d: -------------------------------------------------------------------------------- 1 | cocos2d for iPhone: http://www.cocos2d-iphone.org 2 | 3 | Copyright (c) 2008-2010 - Ricardo Quesada and contributors 4 | (see each file to see the different copyright owners) 5 | 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /LICENSE.cocosdenshion: -------------------------------------------------------------------------------- 1 | CocosDenshion Sound Engine 2 | 3 | Copyright (c) 2010 Steve Oldmeadow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | AdRootViewController 2 | ================== 3 | 4 | RootViewController replacement for Cocos2d that supports iAds and AdMob. 5 | 6 | 7 | Features 8 | ------------- 9 | 10 | * Two Positions to set the Ads (Top, or Bottom) 11 | * Autorotation support, using CCDirector or UIViewController 12 | * Universal support (iPhone + iPad) 13 | * Interstitial ads (AdMob Only) 14 | * Easy to use 15 | 16 | 17 | Usage 18 | ----------------------- 19 | 20 | Replace the RootViewController in the Cocos2d project with the AdRootViewController. 21 | 22 | Define your AdMob publisher Id 23 | 24 | #define ADMOB_PUBLISHER_ID @"your_publisher_id" 25 | 26 | To add the ad to the controller's view call: 27 | 28 | [viewController addBannerAd]; 29 | 30 | To remove the ad call: 31 | 32 | [viewController removeBannerAd]; 33 | 34 | Interstitial Ads are shown calling: 35 | 36 | [viewController addInterstitialAd]; 37 | 38 | You can set the position of the ad at the Top or Bottom of the Screen, just call: 39 | 40 | [viewController setAdBannerPosition:kAdBannerPositionBottom] 41 | 42 | or 43 | 44 | [viewController setAdBannerPosition:kAdBannerPositionTop] 45 | 46 | 47 | Hope it helps, suggestions and corrections are always welcome. -------------------------------------------------------------------------------- /Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | Icon files 26 | 27 | Icon.png 28 | Icon@2x.png 29 | Icon-72.png 30 | Icon-Small-50.png 31 | Icon-Small.png 32 | Icon-Small@2x.png 33 | 34 | LSRequiresIPhoneOS 35 | 36 | UIPrerenderedIcon 37 | 38 | UIRequiredDeviceCapabilities 39 | 40 | accelerometer 41 | 42 | opengles-1 43 | 44 | 45 | UIStatusBarHidden 46 | 47 | UISupportedInterfaceOrientations 48 | 49 | UISupportedInterfaceOrientations~ipad 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Resources/fps_images.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jandrad/AdRootViewController/2f1de2b30d48ae0266de3e54525840573e36fafb/Resources/fps_images.png -------------------------------------------------------------------------------- /iAdsTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /iAdsTest.xcodeproj/xcuserdata/jandrad.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /iAdsTest.xcodeproj/xcuserdata/jandrad.xcuserdatad/xcschemes/cocos2d libraries.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 40 | 41 | 42 | 43 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /iAdsTest.xcodeproj/xcuserdata/jandrad.xcuserdatad/xcschemes/iAdsTest.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 36 | 37 | 38 | 39 | 47 | 48 | 54 | 55 | 56 | 57 | 61 | 62 | 63 | 64 | 65 | 66 | 73 | 74 | 80 | 81 | 82 | 83 | 87 | 88 | 89 | 90 | 92 | 93 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /iAdsTest.xcodeproj/xcuserdata/jandrad.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | iAdsTest.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | cocos2d libraries.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 1D6058900D05DD3D006BFB54 21 | 22 | primary 23 | 24 | 25 | 506EE05D10304ED200A389B3 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /iAdsTest_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'iAdsTest' target in the 'iAdsTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /libs/FontLabel/FontLabel.h: -------------------------------------------------------------------------------- 1 | // 2 | // FontLabel.h 3 | // FontLabel 4 | // 5 | // Created by Kevin Ballard on 5/8/09. 6 | // Copyright © 2009 Zynga Game Networks 7 | // 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | 22 | #import 23 | #import 24 | 25 | @class ZFont; 26 | @class ZAttributedString; 27 | 28 | @interface FontLabel : UILabel { 29 | void *reserved; // works around a bug in UILabel 30 | ZFont *zFont; 31 | ZAttributedString *zAttributedText; 32 | } 33 | @property (nonatomic, setter=setCGFont:) CGFontRef cgFont __AVAILABILITY_INTERNAL_DEPRECATED; 34 | @property (nonatomic, assign) CGFloat pointSize __AVAILABILITY_INTERNAL_DEPRECATED; 35 | @property (nonatomic, retain, setter=setZFont:) ZFont *zFont; 36 | // if attributedText is nil, fall back on using the inherited UILabel properties 37 | // if attributedText is non-nil, the font/text/textColor 38 | // in addition, adjustsFontSizeToFitWidth does not work with attributed text 39 | @property (nonatomic, copy) ZAttributedString *zAttributedText; 40 | // -initWithFrame:fontName:pointSize: uses FontManager to look up the font name 41 | - (id)initWithFrame:(CGRect)frame fontName:(NSString *)fontName pointSize:(CGFloat)pointSize; 42 | - (id)initWithFrame:(CGRect)frame zFont:(ZFont *)font; 43 | - (id)initWithFrame:(CGRect)frame font:(CGFontRef)font pointSize:(CGFloat)pointSize __AVAILABILITY_INTERNAL_DEPRECATED; 44 | @end 45 | -------------------------------------------------------------------------------- /libs/FontLabel/FontManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // FontManager.h 3 | // FontLabel 4 | // 5 | // Created by Kevin Ballard on 5/5/09. 6 | // Copyright © 2009 Zynga Game Networks 7 | // 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | 22 | #import 23 | #import 24 | 25 | @class ZFont; 26 | 27 | @interface FontManager : NSObject { 28 | CFMutableDictionaryRef fonts; 29 | NSMutableDictionary *urls; 30 | } 31 | + (FontManager *)sharedManager; 32 | /*! 33 | @method 34 | @abstract Loads a TTF font from the main bundle 35 | @param filename The name of the font file to load (with or without extension). 36 | @return YES if the font was loaded, NO if an error occurred 37 | @discussion If the font has already been loaded, this method does nothing and returns YES. 38 | This method first attempts to load the font by appending .ttf to the filename. 39 | If that file does not exist, it tries the filename exactly as given. 40 | */ 41 | - (BOOL)loadFont:(NSString *)filename; 42 | /*! 43 | @method 44 | @abstract Loads a font from the given file URL 45 | @param url A file URL that points to a font file 46 | @return YES if the font was loaded, NO if an error occurred 47 | @discussion If the font has already been loaded, this method does nothing and returns YES. 48 | */ 49 | - (BOOL)loadFontURL:(NSURL *)url; 50 | /*! 51 | @method 52 | @abstract Returns the loaded font with the given filename 53 | @param filename The name of the font file that was given to -loadFont: 54 | @return A CGFontRef, or NULL if the specified font cannot be found 55 | @discussion If the font has not been loaded yet, -loadFont: will be 56 | called with the given name first. 57 | */ 58 | - (CGFontRef)fontWithName:(NSString *)filename __AVAILABILITY_INTERNAL_DEPRECATED; 59 | /*! 60 | @method 61 | @abstract Returns a ZFont object corresponding to the loaded font with the given filename and point size 62 | @param filename The name of the font file that was given to -loadFont: 63 | @param pointSize The point size of the font 64 | @return A ZFont, or NULL if the specified font cannot be found 65 | @discussion If the font has not been loaded yet, -loadFont: will be 66 | called with the given name first. 67 | */ 68 | - (ZFont *)zFontWithName:(NSString *)filename pointSize:(CGFloat)pointSize; 69 | /*! 70 | @method 71 | @abstract Returns a ZFont object corresponding to the loaded font with the given file URL and point size 72 | @param url A file URL that points to a font file 73 | @param pointSize The point size of the font 74 | @return A ZFont, or NULL if the specified font cannot be loaded 75 | @discussion If the font has not been loaded yet, -loadFontURL: will be called with the given URL first. 76 | */ 77 | - (ZFont *)zFontWithURL:(NSURL *)url pointSize:(CGFloat)pointSize; 78 | /*! 79 | @method 80 | @abstract Returns a CFArrayRef of all loaded CGFont objects 81 | @return A CFArrayRef of all loaded CGFont objects 82 | @description You are responsible for releasing the CFArrayRef 83 | */ 84 | - (CFArrayRef)copyAllFonts; 85 | @end 86 | -------------------------------------------------------------------------------- /libs/FontLabel/ZAttributedString.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZAttributedString.h 3 | // FontLabel 4 | // 5 | // Created by Kevin Ballard on 9/22/09. 6 | // Copyright 2009 Zynga Game Networks. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #if NS_BLOCKS_AVAILABLE 12 | #define Z_BLOCKS 1 13 | #else 14 | // set this to 1 if you are using PLBlocks 15 | #define Z_BLOCKS 0 16 | #endif 17 | 18 | #if Z_BLOCKS 19 | enum { 20 | ZAttributedStringEnumerationReverse = (1UL << 1), 21 | ZAttributedStringEnumerationLongestEffectiveRangeNotRequired = (1UL << 20) 22 | }; 23 | typedef NSUInteger ZAttributedStringEnumerationOptions; 24 | #endif 25 | 26 | @interface ZAttributedString : NSObject { 27 | NSMutableString *_buffer; 28 | NSMutableArray *_attributes; 29 | } 30 | @property (nonatomic, readonly) NSUInteger length; 31 | @property (nonatomic, readonly) NSString *string; 32 | - (id)initWithAttributedString:(ZAttributedString *)attr; 33 | - (id)initWithString:(NSString *)str; 34 | - (id)initWithString:(NSString *)str attributes:(NSDictionary *)attributes; 35 | - (id)attribute:(NSString *)attributeName atIndex:(NSUInteger)index effectiveRange:(NSRangePointer)aRange; 36 | - (id)attribute:(NSString *)attributeName atIndex:(NSUInteger)index longestEffectiveRange:(NSRangePointer)aRange inRange:(NSRange)rangeLimit; 37 | - (ZAttributedString *)attributedSubstringFromRange:(NSRange)aRange; 38 | - (NSDictionary *)attributesAtIndex:(NSUInteger)index effectiveRange:(NSRangePointer)aRange; 39 | - (NSDictionary *)attributesAtIndex:(NSUInteger)index longestEffectiveRange:(NSRangePointer)aRange inRange:(NSRange)rangeLimit; 40 | #if Z_BLOCKS 41 | - (void)enumerateAttribute:(NSString *)attrName inRange:(NSRange)enumerationRange options:(ZAttributedStringEnumerationOptions)opts 42 | usingBlock:(void (^)(id value, NSRange range, BOOL *stop))block; 43 | - (void)enumerateAttributesInRange:(NSRange)enumerationRange options:(ZAttributedStringEnumerationOptions)opts 44 | usingBlock:(void (^)(NSDictionary *attrs, NSRange range, BOOL *stop))block; 45 | #endif 46 | - (BOOL)isEqualToAttributedString:(ZAttributedString *)otherString; 47 | @end 48 | 49 | @interface ZMutableAttributedString : ZAttributedString { 50 | } 51 | - (void)addAttribute:(NSString *)name value:(id)value range:(NSRange)range; 52 | - (void)addAttributes:(NSDictionary *)attributes range:(NSRange)range; 53 | - (void)appendAttributedString:(ZAttributedString *)str; 54 | - (void)deleteCharactersInRange:(NSRange)range; 55 | - (void)insertAttributedString:(ZAttributedString *)str atIndex:(NSUInteger)idx; 56 | - (void)removeAttribute:(NSString *)name range:(NSRange)range; 57 | - (void)replaceCharactersInRange:(NSRange)range withAttributedString:(ZAttributedString *)str; 58 | - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str; 59 | - (void)setAttributedString:(ZAttributedString *)str; 60 | - (void)setAttributes:(NSDictionary *)attributes range:(NSRange)range; 61 | @end 62 | 63 | extern NSString * const ZFontAttributeName; 64 | extern NSString * const ZForegroundColorAttributeName; 65 | extern NSString * const ZBackgroundColorAttributeName; 66 | extern NSString * const ZUnderlineStyleAttributeName; 67 | 68 | enum { 69 | ZUnderlineStyleNone = 0x00, 70 | ZUnderlineStyleSingle = 0x01 71 | }; 72 | #define ZUnderlineStyleMask 0x00FF 73 | 74 | enum { 75 | ZUnderlinePatternSolid = 0x0000 76 | }; 77 | #define ZUnderlinePatternMask 0xFF00 78 | -------------------------------------------------------------------------------- /libs/FontLabel/ZAttributedStringPrivate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZAttributedStringPrivate.h 3 | // FontLabel 4 | // 5 | // Created by Kevin Ballard on 9/23/09. 6 | // Copyright 2009 Zynga Game Networks. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ZAttributedString.h" 11 | 12 | @interface ZAttributeRun : NSObject { 13 | NSUInteger _index; 14 | NSMutableDictionary *_attributes; 15 | } 16 | @property (nonatomic, readonly) NSUInteger index; 17 | @property (nonatomic, readonly) NSMutableDictionary *attributes; 18 | + (id)attributeRunWithIndex:(NSUInteger)idx attributes:(NSDictionary *)attrs; 19 | - (id)initWithIndex:(NSUInteger)idx attributes:(NSDictionary *)attrs; 20 | @end 21 | 22 | @interface ZAttributedString (ZAttributedStringPrivate) 23 | @property (nonatomic, readonly) NSArray *attributes; 24 | @end 25 | -------------------------------------------------------------------------------- /libs/FontLabel/ZFont.h: -------------------------------------------------------------------------------- 1 | // 2 | // ZFont.h 3 | // FontLabel 4 | // 5 | // Created by Kevin Ballard on 7/2/09. 6 | // Copyright © 2009 Zynga Game Networks 7 | // 8 | // 9 | // Licensed under the Apache License, Version 2.0 (the "License"); 10 | // you may not use this file except in compliance with the License. 11 | // You may obtain a copy of the License at 12 | // 13 | // http://www.apache.org/licenses/LICENSE-2.0 14 | // 15 | // Unless required by applicable law or agreed to in writing, software 16 | // distributed under the License is distributed on an "AS IS" BASIS, 17 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | // See the License for the specific language governing permissions and 19 | // limitations under the License. 20 | // 21 | 22 | #import 23 | #import 24 | 25 | @interface ZFont : NSObject { 26 | CGFontRef _cgFont; 27 | CGFloat _pointSize; 28 | CGFloat _ratio; 29 | NSString *_familyName; 30 | NSString *_fontName; 31 | NSString *_postScriptName; 32 | } 33 | @property (nonatomic, readonly) CGFontRef cgFont; 34 | @property (nonatomic, readonly) CGFloat pointSize; 35 | @property (nonatomic, readonly) CGFloat ascender; 36 | @property (nonatomic, readonly) CGFloat descender; 37 | @property (nonatomic, readonly) CGFloat leading; 38 | @property (nonatomic, readonly) CGFloat xHeight; 39 | @property (nonatomic, readonly) CGFloat capHeight; 40 | @property (nonatomic, readonly) NSString *familyName; 41 | @property (nonatomic, readonly) NSString *fontName; 42 | @property (nonatomic, readonly) NSString *postScriptName; 43 | + (ZFont *)fontWithCGFont:(CGFontRef)cgFont size:(CGFloat)fontSize; 44 | + (ZFont *)fontWithUIFont:(UIFont *)uiFont; 45 | - (id)initWithCGFont:(CGFontRef)cgFont size:(CGFloat)fontSize; 46 | - (ZFont *)fontWithSize:(CGFloat)fontSize; 47 | @end 48 | -------------------------------------------------------------------------------- /libs/TouchJSON/CDataScanner.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDataScanner.h 3 | // TouchCode 4 | // 5 | // Created by Jonathan Wight on 04/16/08. 6 | // Copyright 2008 toxicsoftware.com. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | // NSScanner 33 | 34 | @interface CDataScanner : NSObject { 35 | NSData *data; 36 | 37 | u_int8_t *start; 38 | u_int8_t *end; 39 | u_int8_t *current; 40 | NSUInteger length; 41 | } 42 | 43 | @property (readwrite, nonatomic, retain) NSData *data; 44 | @property (readwrite, nonatomic, assign) NSUInteger scanLocation; 45 | @property (readonly, nonatomic, assign) NSUInteger bytesRemaining; 46 | @property (readonly, nonatomic, assign) BOOL isAtEnd; 47 | 48 | - (id)initWithData:(NSData *)inData; 49 | 50 | - (unichar)currentCharacter; 51 | - (unichar)scanCharacter; 52 | - (BOOL)scanCharacter:(unichar)inCharacter; 53 | 54 | - (BOOL)scanUTF8String:(const char *)inString intoString:(NSString **)outValue; 55 | - (BOOL)scanString:(NSString *)inString intoString:(NSString **)outValue; 56 | - (BOOL)scanCharactersFromSet:(NSCharacterSet *)inSet intoString:(NSString **)outValue; // inSet must only contain 7-bit ASCII characters 57 | 58 | - (BOOL)scanUpToString:(NSString *)string intoString:(NSString **)outValue; 59 | - (BOOL)scanUpToCharactersFromSet:(NSCharacterSet *)set intoString:(NSString **)outValue; // inSet must only contain 7-bit ASCII characters 60 | 61 | - (BOOL)scanNumber:(NSNumber **)outValue; 62 | - (BOOL)scanDecimalNumber:(NSDecimalNumber **)outValue; 63 | 64 | - (BOOL)scanDataOfLength:(NSUInteger)inLength intoData:(NSData **)outData; 65 | 66 | - (void)skipWhitespace; 67 | 68 | - (NSString *)remainingString; 69 | - (NSData *)remainingData; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /libs/TouchJSON/Extensions/CDataScanner_Extensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDataScanner_Extensions.h 3 | // TouchCode 4 | // 5 | // Created by Jonathan Wight on 12/08/2005. 6 | // Copyright 2005 toxicsoftware.com. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "CDataScanner.h" 31 | 32 | @interface CDataScanner (CDataScanner_Extensions) 33 | 34 | - (BOOL)scanCStyleComment:(NSString **)outComment; 35 | - (BOOL)scanCPlusPlusStyleComment:(NSString **)outComment; 36 | 37 | - (NSUInteger)lineOfScanLocation; 38 | - (NSDictionary *)userInfoForScanLocation; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /libs/TouchJSON/Extensions/NSDictionary_JSONExtensions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary_JSONExtensions.h 3 | // TouchCode 4 | // 5 | // Created by Jonathan Wight on 04/17/08. 6 | // Copyright 2008 toxicsoftware.com. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | @interface NSDictionary (NSDictionary_JSONExtensions) 33 | 34 | + (id)dictionaryWithJSONData:(NSData *)inData error:(NSError **)outError; 35 | + (id)dictionaryWithJSONString:(NSString *)inJSON error:(NSError **)outError; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /libs/TouchJSON/Extensions/NSDictionary_JSONExtensions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary_JSONExtensions.m 3 | // TouchCode 4 | // 5 | // Created by Jonathan Wight on 04/17/08. 6 | // Copyright 2008 toxicsoftware.com. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import "NSDictionary_JSONExtensions.h" 31 | 32 | #import "CJSONDeserializer.h" 33 | 34 | @implementation NSDictionary (NSDictionary_JSONExtensions) 35 | 36 | + (id)dictionaryWithJSONData:(NSData *)inData error:(NSError **)outError 37 | { 38 | return([[CJSONDeserializer deserializer] deserialize:inData error:outError]); 39 | } 40 | 41 | + (id)dictionaryWithJSONString:(NSString *)inJSON error:(NSError **)outError; 42 | { 43 | NSData *theData = [inJSON dataUsingEncoding:NSUTF8StringEncoding]; 44 | return([self dictionaryWithJSONData:theData error:outError]); 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /libs/TouchJSON/JSON/CJSONDeserializer.h: -------------------------------------------------------------------------------- 1 | // 2 | // CJSONDeserializer.h 3 | // TouchCode 4 | // 5 | // Created by Jonathan Wight on 12/15/2005. 6 | // Copyright 2005 toxicsoftware.com. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | #import "CJSONScanner.h" 33 | 34 | extern NSString *const kJSONDeserializerErrorDomain /* = @"CJSONDeserializerErrorDomain" */; 35 | 36 | enum { 37 | kJSONDeserializationOptions_MutableContainers = kJSONScannerOptions_MutableContainers, 38 | kJSONDeserializationOptions_MutableLeaves = kJSONScannerOptions_MutableLeaves, 39 | }; 40 | typedef NSUInteger EJSONDeserializationOptions; 41 | 42 | @class CJSONScanner; 43 | 44 | @interface CJSONDeserializer : NSObject { 45 | CJSONScanner *scanner; 46 | EJSONDeserializationOptions options; 47 | } 48 | 49 | @property (readwrite, nonatomic, retain) CJSONScanner *scanner; 50 | /// Object to return instead when a null encountered in the JSON. Defaults to NSNull. Setting to null causes the scanner to skip null values. 51 | @property (readwrite, nonatomic, retain) id nullObject; 52 | /// JSON must be encoded in Unicode (UTF-8, UTF-16 or UTF-32). Use this if you expect to get the JSON in another encoding. 53 | @property (readwrite, nonatomic, assign) NSStringEncoding allowedEncoding; 54 | @property (readwrite, nonatomic, assign) EJSONDeserializationOptions options; 55 | 56 | + (id)deserializer; 57 | 58 | - (id)deserialize:(NSData *)inData error:(NSError **)outError; 59 | 60 | - (id)deserializeAsDictionary:(NSData *)inData error:(NSError **)outError; 61 | - (id)deserializeAsArray:(NSData *)inData error:(NSError **)outError; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /libs/TouchJSON/JSON/CJSONSerializer.h: -------------------------------------------------------------------------------- 1 | // 2 | // CJSONSerializer.h 3 | // TouchCode 4 | // 5 | // Created by Jonathan Wight on 12/07/2005. 6 | // Copyright 2005 toxicsoftware.com. All rights reserved. 7 | // 8 | // Permission is hereby granted, free of charge, to any person 9 | // obtaining a copy of this software and associated documentation 10 | // files (the "Software"), to deal in the Software without 11 | // restriction, including without limitation the rights to use, 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the 14 | // Software is furnished to do so, subject to the following 15 | // conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | // OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | @interface CJSONSerializer : NSObject { 33 | } 34 | 35 | + (id)serializer; 36 | 37 | - (BOOL)isValidJSONObject:(id)inObject; 38 | 39 | /// Take any JSON compatible object (generally NSNull, NSNumber, NSString, NSArray and NSDictionary) and produce an NSData containing the serialized JSON. 40 | - (NSData *)serializeObject:(id)inObject error:(NSError **)outError; 41 | 42 | - (NSData *)serializeNull:(NSNull *)inNull error:(NSError **)outError; 43 | - (NSData *)serializeNumber:(NSNumber *)inNumber error:(NSError **)outError; 44 | - (NSData *)serializeString:(NSString *)inString error:(NSError **)outError; 45 | - (NSData *)serializeArray:(NSArray *)inArray error:(NSError **)outError; 46 | - (NSData *)serializeDictionary:(NSDictionary *)inDictionary error:(NSError **)outError; 47 | 48 | @end 49 | 50 | typedef enum { 51 | CJSONSerializerErrorCouldNotSerializeDataType = -1, 52 | CJSONSerializerErrorCouldNotSerializeObject = -1 53 | } CJSONSerializerError; 54 | -------------------------------------------------------------------------------- /libs/TouchJSON/JSON/JSONRepresentation.h: -------------------------------------------------------------------------------- 1 | // 2 | // JSONRepresentation.h 3 | // TouchJSON 4 | // 5 | // Created by Jonathan Wight on 10/15/10. 6 | // Copyright 2010 toxicsoftware.com. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol JSONRepresentation 12 | 13 | @optional 14 | - (id)initWithJSONDataRepresentation:(NSData *)inJSONData; 15 | 16 | - (NSData *)JSONDataRepresentation; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /libs/cocos2d/CCActionCamera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #import "CCActionInterval.h" 28 | 29 | @class CCCamera; 30 | 31 | /** Base class for CCCamera actions 32 | */ 33 | @interface CCActionCamera : CCActionInterval 34 | { 35 | float centerXOrig_; 36 | float centerYOrig_; 37 | float centerZOrig_; 38 | 39 | float eyeXOrig_; 40 | float eyeYOrig_; 41 | float eyeZOrig_; 42 | 43 | float upXOrig_; 44 | float upYOrig_; 45 | float upZOrig_; 46 | } 47 | @end 48 | 49 | /** CCOrbitCamera action 50 | Orbits the camera around the center of the screen using spherical coordinates 51 | */ 52 | @interface CCOrbitCamera : CCActionCamera 53 | { 54 | float radius_; 55 | float deltaRadius_; 56 | float angleZ_; 57 | float deltaAngleZ_; 58 | float angleX_; 59 | float deltaAngleX_; 60 | 61 | float radZ_; 62 | float radDeltaZ_; 63 | float radX_; 64 | float radDeltaX_; 65 | 66 | } 67 | /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ 68 | +(id) actionWithDuration:(float) t radius:(float)r deltaRadius:(float) dr angleZ:(float)z deltaAngleZ:(float)dz angleX:(float)x deltaAngleX:(float)dx; 69 | /** initializes a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ 70 | -(id) initWithDuration:(float) t radius:(float)r deltaRadius:(float) dr angleZ:(float)z deltaAngleZ:(float)dz angleX:(float)x deltaAngleX:(float)dx; 71 | /** positions the camera according to spherical coordinates */ 72 | -(void) sphericalRadius:(float*) r zenith:(float*) zenith azimuth:(float*) azimuth; 73 | @end 74 | -------------------------------------------------------------------------------- /libs/cocos2d/CCActionPageTurn3D.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import "CCActionGrid3D.h" 28 | 29 | /** 30 | * This action simulates a page turn from the bottom right hand corner of the screen 31 | * It's not much use by itself but is used by the PageTurnTransition. 32 | * 33 | * Based on an original paper by L Hong et al. 34 | * http://www.parc.com/publication/1638/turning-pages-of-3d-electronic-books.html 35 | * 36 | * @since v0.8.2 37 | */ 38 | @interface CCPageTurn3D : CCGrid3DAction 39 | { 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /libs/cocos2d/CCActionPageTurn3D.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #import "CCActionPageTurn3D.h" 27 | 28 | @implementation CCPageTurn3D 29 | 30 | /* 31 | * Update each tick 32 | * Time is the percentage of the way through the duration 33 | */ 34 | -(void)update:(ccTime)time 35 | { 36 | float tt = MAX( 0, time - 0.25f ); 37 | float deltaAy = ( tt * tt * 500); 38 | float ay = -100 - deltaAy; 39 | 40 | float deltaTheta = - (float) M_PI_2 * sqrtf( time) ; 41 | float theta = /*0.01f*/ + (float) M_PI_2 +deltaTheta; 42 | 43 | float sinTheta = sinf(theta); 44 | float cosTheta = cosf(theta); 45 | 46 | for( int i = 0; i <=gridSize_.x; i++ ) 47 | { 48 | for( int j = 0; j <= gridSize_.y; j++ ) 49 | { 50 | // Get original vertex 51 | ccVertex3F p = [self originalVertex:ccg(i,j)]; 52 | 53 | float R = sqrtf(p.x*p.x + (p.y - ay) * (p.y - ay)); 54 | float r = R * sinTheta; 55 | float alpha = asinf( p.x / R ); 56 | float beta = alpha / sinTheta; 57 | float cosBeta = cosf( beta ); 58 | 59 | // If beta > PI then we've wrapped around the cone 60 | // Reduce the radius to stop these points interfering with others 61 | if( beta <= M_PI) 62 | p.x = ( r * sinf(beta)); 63 | else 64 | { 65 | // Force X = 0 to stop wrapped 66 | // points 67 | p.x = 0; 68 | } 69 | 70 | p.y = ( R + ay - ( r*(1 - cosBeta)*sinTheta)); 71 | 72 | // We scale z here to avoid the animation being 73 | // too much bigger than the screen due to perspectve transform 74 | p.z = (r * ( 1 - cosBeta ) * cosTheta) / 7; // "100" didn't work for 75 | 76 | // Stop z coord from dropping beneath underlying page in a transition 77 | // issue #751 78 | if( p.z<0.5f ) 79 | p.z = 0.5f; 80 | 81 | // Set new coords 82 | [self setVertex:ccg(i,j) vertex:p]; 83 | } 84 | } 85 | } 86 | @end 87 | -------------------------------------------------------------------------------- /libs/cocos2d/CCActionProgressTimer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (C) 2010 Lam Pham 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import 28 | #import "CCProgressTimer.h" 29 | #import "CCActionInterval.h" 30 | 31 | /** 32 | Progress to percentage 33 | @since v0.99.1 34 | */ 35 | @interface CCProgressTo : CCActionInterval 36 | { 37 | float to_; 38 | float from_; 39 | } 40 | /** Creates and initializes with a duration and a percent */ 41 | +(id) actionWithDuration:(ccTime)duration percent:(float)percent; 42 | /** Initializes with a duration and a percent */ 43 | -(id) initWithDuration:(ccTime)duration percent:(float)percent; 44 | @end 45 | 46 | /** 47 | Progress from a percentage to another percentage 48 | @since v0.99.1 49 | */ 50 | @interface CCProgressFromTo : CCActionInterval 51 | { 52 | float to_; 53 | float from_; 54 | } 55 | /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */ 56 | +(id) actionWithDuration:(ccTime)duration from:(float)fromPercentage to:(float) toPercentage; 57 | /** Initializes the action with a duration, a "from" percentage and a "to" percentage */ 58 | -(id) initWithDuration:(ccTime)duration from:(float)fromPercentage to:(float) toPercentage; 59 | @end 60 | -------------------------------------------------------------------------------- /libs/cocos2d/CCActionProgressTimer.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (C) 2010 Lam Pham 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import "CCActionProgressTimer.h" 28 | 29 | #define kProgressTimerCast CCProgressTimer* 30 | 31 | @implementation CCProgressTo 32 | +(id) actionWithDuration: (ccTime) t percent: (float) v 33 | { 34 | return [[[ self alloc] initWithDuration: t percent: v] autorelease]; 35 | } 36 | 37 | -(id) initWithDuration: (ccTime) t percent: (float) v 38 | { 39 | if( (self=[super initWithDuration: t] ) ) 40 | to_ = v; 41 | 42 | return self; 43 | } 44 | 45 | -(id) copyWithZone: (NSZone*) zone 46 | { 47 | CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration:duration_ percent:to_]; 48 | return copy; 49 | } 50 | 51 | -(void) startWithTarget:(id) aTarget; 52 | { 53 | [super startWithTarget:aTarget]; 54 | from_ = [(kProgressTimerCast)target_ percentage]; 55 | 56 | // XXX: Is this correct ? 57 | // Adding it to support CCRepeat 58 | if( from_ == 100) 59 | from_ = 0; 60 | } 61 | 62 | -(void) update: (ccTime) t 63 | { 64 | [(kProgressTimerCast)target_ setPercentage: from_ + ( to_ - from_ ) * t]; 65 | } 66 | @end 67 | 68 | @implementation CCProgressFromTo 69 | +(id) actionWithDuration: (ccTime) t from:(float)fromPercentage to:(float) toPercentage 70 | { 71 | return [[[self alloc] initWithDuration: t from: fromPercentage to: toPercentage] autorelease]; 72 | } 73 | 74 | -(id) initWithDuration: (ccTime) t from:(float)fromPercentage to:(float) toPercentage 75 | { 76 | if( (self=[super initWithDuration: t] ) ){ 77 | to_ = toPercentage; 78 | from_ = fromPercentage; 79 | } 80 | return self; 81 | } 82 | 83 | -(id) copyWithZone: (NSZone*) zone 84 | { 85 | CCAction *copy = [[[self class] allocWithZone: zone] initWithDuration:duration_ from:from_ to:to_]; 86 | return copy; 87 | } 88 | 89 | - (CCActionInterval *) reverse 90 | { 91 | return [[self class] actionWithDuration:duration_ from:to_ to:from_]; 92 | } 93 | 94 | -(void) startWithTarget:(id) aTarget; 95 | { 96 | [super startWithTarget:aTarget]; 97 | } 98 | 99 | -(void) update: (ccTime) t 100 | { 101 | [(kProgressTimerCast)target_ setPercentage: from_ + ( to_ - from_ ) * t]; 102 | } 103 | @end 104 | -------------------------------------------------------------------------------- /libs/cocos2d/CCActionTween.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright 2009 lhunath (Maarten Billemont) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import 28 | #import "CCActionInterval.h" 29 | 30 | /** CCActionTween 31 | 32 | CCActionTween is an action that lets you update any property of an object. 33 | For example, if you want to modify the "width" property of a target from 200 to 300 in 2 senconds, then: 34 | 35 | id modifyWidth = [CCActionTween actionWithDuration:2 key:@"width" from:200 to:300]; 36 | [target runAction:modifyWidth]; 37 | 38 | 39 | Another example: CCScaleTo action could be rewriten using CCPropertyAction: 40 | 41 | // scaleA and scaleB are equivalents 42 | id scaleA = [CCScaleTo actionWithDuration:2 scale:3]; 43 | id scaleB = [CCActionTween actionWithDuration:2 key:@"scale" from:1 to:3]; 44 | 45 | 46 | @since v0.99.2 47 | */ 48 | @interface CCActionTween : CCActionInterval 49 | { 50 | NSString *key_; 51 | 52 | float from_, to_; 53 | float delta_; 54 | } 55 | 56 | /** creates an initializes the action with the property name (key), and the from and to parameters. */ 57 | + (id)actionWithDuration:(ccTime)aDuration key:(NSString *)key from:(float)from to:(float)to; 58 | 59 | /** initializes the action with the property name (key), and the from and to parameters. */ 60 | - (id)initWithDuration:(ccTime)aDuration key:(NSString *)key from:(float)from to:(float)to; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /libs/cocos2d/CCActionTween.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright 2009 lhunath (Maarten Billemont) 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #import "CCActionTween.h" 27 | 28 | 29 | @implementation CCActionTween 30 | 31 | + (id)actionWithDuration:(ccTime)aDuration key:(NSString *)aKey from:(float)aFrom to:(float)aTo { 32 | 33 | return [[[[self class] alloc] initWithDuration:aDuration key:aKey from:aFrom to:aTo] autorelease]; 34 | } 35 | 36 | - (id)initWithDuration:(ccTime)aDuration key:(NSString *)key from:(float)from to:(float)to { 37 | 38 | if ((self = [super initWithDuration:aDuration])) { 39 | 40 | key_ = [key copy]; 41 | to_ = to; 42 | from_ = from; 43 | 44 | } 45 | 46 | return self; 47 | } 48 | 49 | - (void) dealloc 50 | { 51 | [key_ release]; 52 | [super dealloc]; 53 | } 54 | 55 | - (void)startWithTarget:aTarget 56 | { 57 | [super startWithTarget:aTarget]; 58 | delta_ = to_ - from_; 59 | } 60 | 61 | - (void) update:(ccTime) dt 62 | { 63 | [target_ setValue:[NSNumber numberWithFloat:to_ - delta_ * (1 - dt)] forKey:key_]; 64 | } 65 | 66 | - (CCActionInterval *) reverse 67 | { 68 | return [[self class] actionWithDuration:duration_ key:key_ from:to_ to:from_]; 69 | } 70 | 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /libs/cocos2d/CCAnimation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #import 28 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 29 | #import 30 | #endif // IPHONE 31 | 32 | @class CCSpriteFrame; 33 | @class CCTexture2D; 34 | 35 | /** A CCAnimation object is used to perform animations on the CCSprite objects. 36 | 37 | The CCAnimation object contains CCSpriteFrame objects, and a possible delay between the frames. 38 | You can animate a CCAnimation object by using the CCAnimate action. Example: 39 | 40 | [sprite runAction:[CCAnimate actionWithAnimation:animation]]; 41 | 42 | */ 43 | @interface CCAnimation : NSObject 44 | { 45 | NSString *name_; 46 | float delay_; 47 | NSMutableArray *frames_; 48 | } 49 | 50 | /** name of the animation */ 51 | @property (nonatomic,readwrite,retain) NSString *name; 52 | /** delay between frames in seconds. */ 53 | @property (nonatomic,readwrite,assign) float delay; 54 | /** array of frames */ 55 | @property (nonatomic,readwrite,retain) NSMutableArray *frames; 56 | 57 | /** Creates an animation 58 | @since v0.99.5 59 | */ 60 | +(id) animation; 61 | 62 | /** Creates an animation with frames. 63 | @since v0.99.5 64 | */ 65 | +(id) animationWithFrames:(NSArray*)frames; 66 | 67 | /* Creates an animation with frames and a delay between frames. 68 | @since v0.99.5 69 | */ 70 | +(id) animationWithFrames:(NSArray*)frames delay:(float)delay; 71 | 72 | /** Initializes a CCAnimation with frames. 73 | @since v0.99.5 74 | */ 75 | -(id) initWithFrames:(NSArray*)frames; 76 | 77 | /** Initializes a CCAnimation with frames and a delay between frames 78 | @since v0.99.5 79 | */ 80 | -(id) initWithFrames:(NSArray *)frames delay:(float)delay; 81 | 82 | /** Adds a frame to a CCAnimation. */ 83 | -(void) addFrame:(CCSpriteFrame*)frame; 84 | 85 | /** Adds a frame with an image filename. Internally it will create a CCSpriteFrame and it will add it. 86 | Added to facilitate the migration from v0.8 to v0.9. 87 | */ 88 | -(void) addFrameWithFilename:(NSString*)filename; 89 | 90 | /** Adds a frame with a texture and a rect. Internally it will create a CCSpriteFrame and it will add it. 91 | Added to facilitate the migration from v0.8 to v0.9. 92 | */ 93 | -(void) addFrameWithTexture:(CCTexture2D*)texture rect:(CGRect)rect; 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /libs/cocos2d/CCAnimation.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #import "ccMacros.h" 28 | #import "CCAnimation.h" 29 | #import "CCSpriteFrame.h" 30 | #import "CCTexture2D.h" 31 | #import "CCTextureCache.h" 32 | 33 | @implementation CCAnimation 34 | @synthesize name = name_, delay = delay_, frames = frames_; 35 | 36 | +(id) animation 37 | { 38 | return [[[self alloc] init] autorelease]; 39 | } 40 | 41 | +(id) animationWithFrames:(NSArray*)frames 42 | { 43 | return [[[self alloc] initWithFrames:frames] autorelease]; 44 | } 45 | 46 | +(id) animationWithFrames:(NSArray*)frames delay:(float)delay 47 | { 48 | return [[[self alloc] initWithFrames:frames delay:delay] autorelease]; 49 | } 50 | 51 | -(id) init 52 | { 53 | return [self initWithFrames:nil delay:0]; 54 | } 55 | 56 | -(id) initWithFrames:(NSArray*)frames 57 | { 58 | return [self initWithFrames:frames delay:0]; 59 | } 60 | 61 | -(id) initWithFrames:(NSArray*)array delay:(float)delay 62 | { 63 | if( (self=[super init]) ) { 64 | 65 | delay_ = delay; 66 | self.frames = [NSMutableArray arrayWithArray:array]; 67 | } 68 | return self; 69 | } 70 | 71 | - (NSString*) description 72 | { 73 | return [NSString stringWithFormat:@"<%@ = %08X | frames=%d, delay:%f>", [self class], self, 74 | [frames_ count], 75 | delay_ 76 | ]; 77 | } 78 | 79 | -(void) dealloc 80 | { 81 | CCLOGINFO( @"cocos2d: deallocing %@",self); 82 | [name_ release]; 83 | [frames_ release]; 84 | [super dealloc]; 85 | } 86 | 87 | -(void) addFrame:(CCSpriteFrame*)frame 88 | { 89 | [frames_ addObject:frame]; 90 | } 91 | 92 | -(void) addFrameWithFilename:(NSString*)filename 93 | { 94 | CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage:filename]; 95 | CGRect rect = CGRectZero; 96 | rect.size = texture.contentSize; 97 | CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:texture rect:rect]; 98 | [frames_ addObject:frame]; 99 | } 100 | 101 | -(void) addFrameWithTexture:(CCTexture2D*)texture rect:(CGRect)rect 102 | { 103 | CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:texture rect:rect]; 104 | [frames_ addObject:frame]; 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /libs/cocos2d/CCAnimationCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #import 28 | 29 | @class CCAnimation; 30 | 31 | /** Singleton that manages the Animations. 32 | It saves in a cache the animations. You should use this class if you want to save your animations in a cache. 33 | 34 | Before v0.99.5, the recommend way was to save them on the CCSprite. Since v0.99.5, you should use this class instead. 35 | 36 | @since v0.99.5 37 | */ 38 | @interface CCAnimationCache : NSObject 39 | { 40 | NSMutableDictionary *animations_; 41 | } 42 | 43 | /** Retruns ths shared instance of the Animation cache */ 44 | + (CCAnimationCache *) sharedAnimationCache; 45 | 46 | /** Purges the cache. It releases all the CCAnimation objects and the shared instance. 47 | */ 48 | +(void)purgeSharedAnimationCache; 49 | 50 | /** Adds a CCAnimation with a name. 51 | */ 52 | -(void) addAnimation:(CCAnimation*)animation name:(NSString*)name; 53 | 54 | /** Deletes a CCAnimation from the cache. 55 | */ 56 | -(void) removeAnimationByName:(NSString*)name; 57 | 58 | /** Returns a CCAnimation that was previously added. 59 | If the name is not found it will return nil. 60 | You should retain the returned copy if you are going to use it. 61 | */ 62 | -(CCAnimation*) animationByName:(NSString*)name; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /libs/cocos2d/CCAnimationCache.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #import "ccMacros.h" 28 | #import "CCAnimationCache.h" 29 | #import "CCAnimation.h" 30 | #import "CCSprite.h" 31 | 32 | 33 | @implementation CCAnimationCache 34 | 35 | #pragma mark CCAnimationCache - Alloc, Init & Dealloc 36 | 37 | static CCAnimationCache *sharedAnimationCache_=nil; 38 | 39 | + (CCAnimationCache *)sharedAnimationCache 40 | { 41 | if (!sharedAnimationCache_) 42 | sharedAnimationCache_ = [[CCAnimationCache alloc] init]; 43 | 44 | return sharedAnimationCache_; 45 | } 46 | 47 | +(id)alloc 48 | { 49 | NSAssert(sharedAnimationCache_ == nil, @"Attempted to allocate a second instance of a singleton."); 50 | return [super alloc]; 51 | } 52 | 53 | +(void)purgeSharedAnimationCache 54 | { 55 | [sharedAnimationCache_ release]; 56 | sharedAnimationCache_ = nil; 57 | } 58 | 59 | -(id) init 60 | { 61 | if( (self=[super init]) ) { 62 | animations_ = [[NSMutableDictionary alloc] initWithCapacity: 20]; 63 | } 64 | 65 | return self; 66 | } 67 | 68 | - (NSString*) description 69 | { 70 | return [NSString stringWithFormat:@"<%@ = %08X | num of animations = %i>", [self class], self, [animations_ count]]; 71 | } 72 | 73 | -(void) dealloc 74 | { 75 | CCLOGINFO(@"cocos2d: deallocing %@", self); 76 | 77 | [animations_ release]; 78 | [super dealloc]; 79 | } 80 | 81 | #pragma mark CCAnimationCache - load/get/del 82 | 83 | -(void) addAnimation:(CCAnimation*)animation name:(NSString*)name 84 | { 85 | [animations_ setObject:animation forKey:name]; 86 | } 87 | 88 | -(void) removeAnimationByName:(NSString*)name 89 | { 90 | if( ! name ) 91 | return; 92 | 93 | [animations_ removeObjectForKey:name]; 94 | } 95 | 96 | -(CCAnimation*) animationByName:(NSString*)name 97 | { 98 | return [animations_ objectForKey:name]; 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /libs/cocos2d/CCAtlasNode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | 28 | #import "CCTextureAtlas.h" 29 | #import "CCNode.h" 30 | #import "CCProtocols.h" 31 | 32 | /** CCAtlasNode is a subclass of CCNode that implements the CCRGBAProtocol and 33 | CCTextureProtocol protocol 34 | 35 | It knows how to render a TextureAtlas object. 36 | If you are going to render a TextureAtlas consider subclassing CCAtlasNode (or a subclass of CCAtlasNode) 37 | 38 | All features from CCNode are valid, plus the following features: 39 | - opacity and RGB colors 40 | */ 41 | @interface CCAtlasNode : CCNode 42 | { 43 | // texture atlas 44 | CCTextureAtlas *textureAtlas_; 45 | 46 | // chars per row 47 | NSUInteger itemsPerRow_; 48 | // chars per column 49 | NSUInteger itemsPerColumn_; 50 | 51 | // width of each char 52 | NSUInteger itemWidth_; 53 | // height of each char 54 | NSUInteger itemHeight_; 55 | 56 | // quads to draw 57 | NSUInteger quadsToDraw_; 58 | 59 | // blend function 60 | ccBlendFunc blendFunc_; 61 | 62 | // texture RGBA. 63 | GLubyte opacity_; 64 | ccColor3B color_; 65 | ccColor3B colorUnmodified_; 66 | BOOL opacityModifyRGB_; 67 | } 68 | 69 | /** conforms to CCTextureProtocol protocol */ 70 | @property (nonatomic,readwrite,retain) CCTextureAtlas *textureAtlas; 71 | 72 | /** conforms to CCTextureProtocol protocol */ 73 | @property (nonatomic,readwrite) ccBlendFunc blendFunc; 74 | 75 | /** conforms to CCRGBAProtocol protocol */ 76 | @property (nonatomic,readwrite) GLubyte opacity; 77 | /** conforms to CCRGBAProtocol protocol */ 78 | @property (nonatomic,readwrite) ccColor3B color; 79 | 80 | /** how many quads to draw */ 81 | @property (nonatomic,readwrite) NSUInteger quadsToDraw; 82 | 83 | /** creates a CCAtlasNode with an Atlas file the width and height of each item measured in points and the quantity of items to render*/ 84 | +(id) atlasWithTileFile:(NSString*)tile tileWidth:(NSUInteger)w tileHeight:(NSUInteger)h itemsToRender: (NSUInteger) c; 85 | 86 | /** initializes an CCAtlasNode with an Atlas file the width and height of each item measured in points and the quantity of items to render*/ 87 | -(id) initWithTileFile:(NSString*)tile tileWidth:(NSUInteger)w tileHeight:(NSUInteger)h itemsToRender: (NSUInteger) c; 88 | 89 | /** updates the Atlas (indexed vertex array). 90 | * Shall be overriden in subclasses 91 | */ 92 | -(void) updateAtlasValues; 93 | @end 94 | -------------------------------------------------------------------------------- /libs/cocos2d/CCBlockSupport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Stuart Carnie 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import 28 | 29 | /** @file 30 | cocos2d blocks support 31 | */ 32 | 33 | // To comply with Apple Objective C runtime (this is defined in NSObjCRuntime.h) 34 | #if !defined(NS_BLOCKS_AVAILABLE) 35 | #if __BLOCKS__ 36 | #define NS_BLOCKS_AVAILABLE 1 37 | #else 38 | #define NS_BLOCKS_AVAILABLE 0 39 | #endif 40 | #endif 41 | 42 | #if NS_BLOCKS_AVAILABLE 43 | 44 | @interface NSObject(CCBlocksAdditions) 45 | 46 | - (void)ccCallbackBlock; 47 | - (void)ccCallbackBlockWithSender:(id)sender; 48 | 49 | @end 50 | 51 | #endif // NS_BLOCKS_AVAILABLE 52 | -------------------------------------------------------------------------------- /libs/cocos2d/CCBlockSupport.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Stuart Carnie 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import "CCBlockSupport.h" 28 | 29 | #if NS_BLOCKS_AVAILABLE 30 | 31 | @implementation NSObject(CCBlocksAdditions) 32 | 33 | - (void)ccCallbackBlock { 34 | void (^block)(void) = (id)self; 35 | block(); 36 | } 37 | 38 | - (void)ccCallbackBlockWithSender:(id)sender { 39 | void (^block)(id) = (id)self; 40 | block(sender); 41 | } 42 | 43 | 44 | @end 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libs/cocos2d/CCCamera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | 27 | 28 | #import "CCNode.h" 29 | 30 | /** 31 | A CCCamera is used in every CCNode. 32 | Useful to look at the object from different views. 33 | The OpenGL gluLookAt() function is used to locate the 34 | camera. 35 | 36 | If the object is transformed by any of the scale, rotation or 37 | position attributes, then they will override the camera. 38 | 39 | IMPORTANT: Either your use the camera or the rotation/scale/position properties. You can't use both. 40 | World coordinates won't work if you use the camera. 41 | 42 | Limitations: 43 | 44 | - Some nodes, like CCParallaxNode, CCParticle uses world node coordinates, and they won't work properly if you move them (or any of their ancestors) 45 | using the camera. 46 | 47 | - It doesn't work on batched nodes like CCSprite objects when they are parented to a CCSpriteBatchNode object. 48 | 49 | - It is recommended to use it ONLY if you are going to create 3D effects. For 2D effecs, use the action CCFollow or position/scale/rotate. 50 | 51 | */ 52 | 53 | @interface CCCamera : NSObject 54 | { 55 | float eyeX_; 56 | float eyeY_; 57 | float eyeZ_; 58 | 59 | float centerX_; 60 | float centerY_; 61 | float centerZ_; 62 | 63 | float upX_; 64 | float upY_; 65 | float upZ_; 66 | 67 | BOOL dirty_; 68 | } 69 | 70 | /** whether of not the camera is dirty */ 71 | @property (nonatomic,readwrite) BOOL dirty; 72 | 73 | /** returns the Z eye */ 74 | +(float) getZEye; 75 | 76 | /** sets the camera in the defaul position */ 77 | -(void) restore; 78 | /** Sets the camera using gluLookAt using its eye, center and up_vector */ 79 | -(void) locate; 80 | /** sets the eye values in points */ 81 | -(void) setEyeX: (float)x eyeY:(float)y eyeZ:(float)z; 82 | /** sets the center values in points */ 83 | -(void) setCenterX: (float)x centerY:(float)y centerZ:(float)z; 84 | /** sets the up values */ 85 | -(void) setUpX: (float)x upY:(float)y upZ:(float)z; 86 | 87 | /** get the eye vector values in points */ 88 | -(void) eyeX:(float*)x eyeY:(float*)y eyeZ:(float*)z; 89 | /** get the center vector values in points */ 90 | -(void) centerX:(float*)x centerY:(float*)y centerZ:(float*)z; 91 | /** get the up vector values */ 92 | -(void) upX:(float*)x upY:(float*)y upZ:(float*)z; 93 | 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /libs/cocos2d/CCCamera.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | 27 | #import "Platforms/CCGL.h" 28 | #import "CCCamera.h" 29 | #import "ccMacros.h" 30 | #import "CCDrawingPrimitives.h" 31 | 32 | @implementation CCCamera 33 | 34 | @synthesize dirty = dirty_; 35 | 36 | -(id) init 37 | { 38 | if( (self=[super init]) ) 39 | [self restore]; 40 | 41 | return self; 42 | } 43 | 44 | - (NSString*) description 45 | { 46 | return [NSString stringWithFormat:@"<%@ = %08X | center = (%.2f,%.2f,%.2f)>", [self class], self, centerX_, centerY_, centerZ_]; 47 | } 48 | 49 | 50 | - (void) dealloc 51 | { 52 | CCLOGINFO(@"cocos2d: deallocing %@", self); 53 | [super dealloc]; 54 | } 55 | 56 | -(void) restore 57 | { 58 | eyeX_ = eyeY_ = 0; 59 | eyeZ_ = [CCCamera getZEye]; 60 | 61 | centerX_ = centerY_ = centerZ_ = 0; 62 | 63 | upX_ = 0.0f; 64 | upY_ = 1.0f; 65 | upZ_ = 0.0f; 66 | 67 | dirty_ = NO; 68 | } 69 | 70 | -(void) locate 71 | { 72 | if( dirty_ ) 73 | gluLookAt( eyeX_, eyeY_, eyeZ_, 74 | centerX_, centerY_, centerZ_, 75 | upX_, upY_, upZ_ 76 | ); 77 | } 78 | 79 | +(float) getZEye 80 | { 81 | return FLT_EPSILON; 82 | // CGSize s = [[CCDirector sharedDirector] displaySize]; 83 | // return ( s.height / 1.1566f ); 84 | } 85 | 86 | -(void) setEyeX: (float)x eyeY:(float)y eyeZ:(float)z 87 | { 88 | eyeX_ = x * CC_CONTENT_SCALE_FACTOR(); 89 | eyeY_ = y * CC_CONTENT_SCALE_FACTOR(); 90 | eyeZ_ = z * CC_CONTENT_SCALE_FACTOR(); 91 | dirty_ = YES; 92 | } 93 | 94 | -(void) setCenterX: (float)x centerY:(float)y centerZ:(float)z 95 | { 96 | centerX_ = x * CC_CONTENT_SCALE_FACTOR(); 97 | centerY_ = y * CC_CONTENT_SCALE_FACTOR(); 98 | centerZ_ = z * CC_CONTENT_SCALE_FACTOR(); 99 | dirty_ = YES; 100 | } 101 | 102 | -(void) setUpX: (float)x upY:(float)y upZ:(float)z 103 | { 104 | upX_ = x; 105 | upY_ = y; 106 | upZ_ = z; 107 | dirty_ = YES; 108 | } 109 | 110 | -(void) eyeX: (float*)x eyeY:(float*)y eyeZ:(float*)z 111 | { 112 | *x = eyeX_ / CC_CONTENT_SCALE_FACTOR(); 113 | *y = eyeY_ / CC_CONTENT_SCALE_FACTOR(); 114 | *z = eyeZ_ / CC_CONTENT_SCALE_FACTOR(); 115 | } 116 | 117 | -(void) centerX: (float*)x centerY:(float*)y centerZ:(float*)z 118 | { 119 | *x = centerX_ / CC_CONTENT_SCALE_FACTOR(); 120 | *y = centerY_ / CC_CONTENT_SCALE_FACTOR(); 121 | *z = centerZ_ / CC_CONTENT_SCALE_FACTOR(); 122 | } 123 | 124 | -(void) upX: (float*)x upY:(float*)y upZ:(float*)z 125 | { 126 | *x = upX_; 127 | *y = upY_; 128 | *z = upZ_; 129 | } 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /libs/cocos2d/CCDrawingPrimitives.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | 27 | #ifndef __CC_DRAWING_PRIMITIVES_H 28 | #define __CC_DRAWING_PRIMITIVES_H 29 | 30 | #import 31 | #import 32 | 33 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 34 | #import // for CGPoint 35 | #endif 36 | 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** 43 | @file 44 | Drawing OpenGL ES primitives. 45 | - ccDrawPoint 46 | - ccDrawLine 47 | - ccDrawPoly 48 | - ccDrawCircle 49 | - ccDrawQuadBezier 50 | - ccDrawCubicBezier 51 | 52 | You can change the color, width and other property by calling the 53 | glColor4ub(), glLineWidth(), glPointSize(). 54 | 55 | @warning These functions draws the Line, Point, Polygon, immediately. They aren't batched. If you are going to make a game that depends on these primitives, I suggest creating a batch. 56 | */ 57 | 58 | 59 | /** draws a point given x and y coordinate measured in points. */ 60 | void ccDrawPoint( CGPoint point ); 61 | 62 | /** draws an array of points. 63 | @since v0.7.2 64 | */ 65 | void ccDrawPoints( const CGPoint *points, NSUInteger numberOfPoints ); 66 | 67 | /** draws a line given the origin and destination point measured in points. */ 68 | void ccDrawLine( CGPoint origin, CGPoint destination ); 69 | 70 | /** draws a poligon given a pointer to CGPoint coordiantes and the number of vertices measured in points. 71 | The polygon can be closed or open 72 | */ 73 | void ccDrawPoly( const CGPoint *vertices, NSUInteger numOfVertices, BOOL closePolygon ); 74 | 75 | /** draws a circle given the center, radius and number of segments measured in points */ 76 | void ccDrawCircle( CGPoint center, float radius, float angle, NSUInteger segments, BOOL drawLineToCenter); 77 | 78 | /** draws a quad bezier path measured in points. 79 | @since v0.8 80 | */ 81 | void ccDrawQuadBezier(CGPoint origin, CGPoint control, CGPoint destination, NSUInteger segments); 82 | 83 | /** draws a cubic bezier path measured in points. 84 | @since v0.8 85 | */ 86 | void ccDrawCubicBezier(CGPoint origin, CGPoint control1, CGPoint control2, CGPoint destination, NSUInteger segments); 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif // __CC_DRAWING_PRIMITIVES_H 93 | -------------------------------------------------------------------------------- /libs/cocos2d/CCGrabber.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 On-Core 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import "Platforms/CCGL.h" 28 | #import 29 | 30 | @class CCTexture2D; 31 | 32 | /** FBO class that grabs the the contents of the screen */ 33 | @interface CCGrabber : NSObject 34 | { 35 | GLuint fbo; 36 | GLint oldFBO; 37 | } 38 | 39 | -(void)grab:(CCTexture2D*)texture; 40 | -(void)beforeRender:(CCTexture2D*)texture; 41 | -(void)afterRender:(CCTexture2D*)texture; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /libs/cocos2d/CCGrabber.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 On-Core 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import "Platforms/CCGL.h" 28 | #import "CCGrabber.h" 29 | #import "ccMacros.h" 30 | #import "CCTexture2D.h" 31 | #import "Support/OpenGL_Internal.h" 32 | 33 | @implementation CCGrabber 34 | 35 | -(id) init 36 | { 37 | if(( self = [super init] )) { 38 | // generate FBO 39 | ccglGenFramebuffers(1, &fbo); 40 | } 41 | return self; 42 | } 43 | 44 | -(void)grab:(CCTexture2D*)texture 45 | { 46 | glGetIntegerv(CC_GL_FRAMEBUFFER_BINDING, &oldFBO); 47 | 48 | // bind 49 | ccglBindFramebuffer(CC_GL_FRAMEBUFFER, fbo); 50 | 51 | // associate texture with FBO 52 | ccglFramebufferTexture2D(CC_GL_FRAMEBUFFER, CC_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.name, 0); 53 | 54 | // check if it worked (probably worth doing :) ) 55 | GLuint status = ccglCheckFramebufferStatus(CC_GL_FRAMEBUFFER); 56 | if (status != CC_GL_FRAMEBUFFER_COMPLETE) 57 | [NSException raise:@"Frame Grabber" format:@"Could not attach texture to framebuffer"]; 58 | 59 | ccglBindFramebuffer(CC_GL_FRAMEBUFFER, oldFBO); 60 | } 61 | 62 | -(void)beforeRender:(CCTexture2D*)texture 63 | { 64 | glGetIntegerv(CC_GL_FRAMEBUFFER_BINDING, &oldFBO); 65 | ccglBindFramebuffer(CC_GL_FRAMEBUFFER, fbo); 66 | 67 | // BUG XXX: doesn't work with RGB565. 68 | 69 | 70 | glClearColor(0,0,0,0); 71 | 72 | // BUG #631: To fix #631, uncomment the lines with #631 73 | // Warning: But it CCGrabber won't work with 2 effects at the same time 74 | // glClearColor(0.0f,0.0f,0.0f,1.0f); // #631 75 | 76 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 77 | 78 | // glColorMask(TRUE, TRUE, TRUE, FALSE); // #631 79 | 80 | } 81 | 82 | -(void)afterRender:(CCTexture2D*)texture 83 | { 84 | ccglBindFramebuffer(CC_GL_FRAMEBUFFER, oldFBO); 85 | // glColorMask(TRUE, TRUE, TRUE, TRUE); // #631 86 | } 87 | 88 | - (void) dealloc 89 | { 90 | CCLOGINFO(@"cocos2d: deallocing %@", self); 91 | ccglDeleteFramebuffers(1, &fbo); 92 | [super dealloc]; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /libs/cocos2d/CCLabelAtlas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | 28 | #import "CCAtlasNode.h" 29 | #import "CCTextureAtlas.h" 30 | 31 | /** CCLabelAtlas is a subclass of CCAtlasNode. 32 | 33 | It can be as a replacement of CCLabel since it is MUCH faster. 34 | 35 | CCLabelAtlas versus CCLabel: 36 | - CCLabelAtlas is MUCH faster than CCLabel 37 | - CCLabelAtlas "characters" have a fixed height and width 38 | - CCLabelAtlas "characters" can be anything you want since they are taken from an image file 39 | 40 | A more flexible class is CCLabelBMFont. It supports variable width characters and it also has a nice editor. 41 | */ 42 | @interface CCLabelAtlas : CCAtlasNode 43 | { 44 | // string to render 45 | NSString *string_; 46 | 47 | // the first char in the charmap 48 | unsigned char mapStartChar_; 49 | } 50 | 51 | 52 | /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element in points and the starting char of the atlas */ 53 | +(id) labelWithString:(NSString*) string charMapFile: (NSString*) charmapfile itemWidth:(NSUInteger)w itemHeight:(NSUInteger)h startCharMap:(unsigned char)c; 54 | 55 | /** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height in points of each element and the starting char of the atlas */ 56 | -(id) initWithString:(NSString*) string charMapFile: (NSString*) charmapfile itemWidth:(NSUInteger)w itemHeight:(NSUInteger)h startCharMap:(unsigned char)c; 57 | @end 58 | -------------------------------------------------------------------------------- /libs/cocos2d/CCMenu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | 28 | #import "CCMenuItem.h" 29 | #import "CCLayer.h" 30 | 31 | typedef enum { 32 | kCCMenuStateWaiting, 33 | kCCMenuStateTrackingTouch 34 | } tCCMenuState; 35 | 36 | enum { 37 | //* priority used by the menu for the touches 38 | kCCMenuTouchPriority = -128, 39 | 40 | //* priority used by the menu for the mouse 41 | kCCMenuMousePriority = -128, 42 | }; 43 | 44 | /** A CCMenu 45 | * 46 | * Features and Limitation: 47 | * - You can add MenuItem objects in runtime using addChild: 48 | * - But the only accecpted children are MenuItem objects 49 | */ 50 | @interface CCMenu : CCLayer 51 | { 52 | tCCMenuState state_; 53 | CCMenuItem *selectedItem_; 54 | GLubyte opacity_; 55 | ccColor3B color_; 56 | } 57 | 58 | /** creates a CCMenu with it's items */ 59 | + (id) menuWithItems: (CCMenuItem*) item, ... NS_REQUIRES_NIL_TERMINATION; 60 | 61 | /** initializes a CCMenu with it's items */ 62 | - (id) initWithItems: (CCMenuItem*) item vaList: (va_list) args; 63 | 64 | /** align items vertically */ 65 | -(void) alignItemsVertically; 66 | /** align items vertically with padding 67 | @since v0.7.2 68 | */ 69 | -(void) alignItemsVerticallyWithPadding:(float) padding; 70 | 71 | /** align items horizontally */ 72 | -(void) alignItemsHorizontally; 73 | /** align items horizontally with padding 74 | @since v0.7.2 75 | */ 76 | -(void) alignItemsHorizontallyWithPadding: (float) padding; 77 | 78 | 79 | /** align items in rows of columns */ 80 | -(void) alignItemsInColumns: (NSNumber *) columns, ... NS_REQUIRES_NIL_TERMINATION; 81 | -(void) alignItemsInColumns: (NSNumber *) columns vaList: (va_list) args; 82 | 83 | /** align items in columns of rows */ 84 | -(void) alignItemsInRows: (NSNumber *) rows, ... NS_REQUIRES_NIL_TERMINATION; 85 | -(void) alignItemsInRows: (NSNumber *) rows vaList: (va_list) args; 86 | 87 | 88 | /** conforms to CCRGBAProtocol protocol */ 89 | @property (nonatomic,readonly) GLubyte opacity; 90 | /** conforms to CCRGBAProtocol protocol */ 91 | @property (nonatomic,readonly) ccColor3B color; 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /libs/cocos2d/CCMotionStreak.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008, 2009 Jason Booth 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #import 27 | #import "CCNode.h" 28 | #import "CCRibbon.h" 29 | 30 | /** 31 | * CCMotionStreak manages a Ribbon based on it's motion in absolute space. 32 | * You construct it with a fadeTime, minimum segment size, texture path, texture 33 | * length and color. The fadeTime controls how long it takes each vertex in 34 | * the streak to fade out, the minimum segment size it how many pixels the 35 | * streak will move before adding a new ribbon segement, and the texture 36 | * length is the how many pixels the texture is stretched across. The texture 37 | * is vertically aligned along the streak segemnts. 38 | * 39 | * Limitations: 40 | * CCMotionStreak, by default, will use the GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA blending function. 41 | * This blending function might not be the correct one for certain textures. 42 | * But you can change it by using: 43 | * [obj setBlendFunc: (ccBlendfunc) {new_src_blend_func, new_dst_blend_func}]; 44 | * 45 | * @since v0.8.1 46 | */ 47 | @interface CCMotionStreak : CCNode 48 | { 49 | CCRibbon* ribbon_; 50 | float segThreshold_; 51 | float width_; 52 | CGPoint lastLocation_; 53 | } 54 | 55 | /** Ribbon used by MotionStreak (weak reference) */ 56 | @property (nonatomic,readonly) CCRibbon *ribbon; 57 | 58 | /** creates the a MotionStreak. The image will be loaded using the TextureMgr. */ 59 | +(id)streakWithFade:(float)fade minSeg:(float)seg image:(NSString*)path width:(float)width length:(float)length color:(ccColor4B)color; 60 | 61 | /** initializes a MotionStreak. The file will be loaded using the TextureMgr. */ 62 | -(id)initWithFade:(float)fade minSeg:(float)seg image:(NSString*)path width:(float)width length:(float)length color:(ccColor4B)color; 63 | 64 | /** polling function */ 65 | -(void)update:(ccTime)delta; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /libs/cocos2d/CCMotionStreak.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008, 2009 Jason Booth 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | * 25 | ********************************************************* 26 | * 27 | * Motion Streak manages a Ribbon based on it's motion in absolute space. 28 | * You construct it with a fadeTime, minimum segment size, texture path, texture 29 | * length and color. The fadeTime controls how long it takes each vertex in 30 | * the streak to fade out, the minimum segment size it how many pixels the 31 | * streak will move before adding a new ribbon segement, and the texture 32 | * length is the how many pixels the texture is stretched across. The texture 33 | * is vertically aligned along the streak segemnts. 34 | */ 35 | 36 | #import "CCMotionStreak.h" 37 | #import "Support/CGPointExtension.h" 38 | 39 | @implementation CCMotionStreak 40 | 41 | @synthesize ribbon = ribbon_; 42 | 43 | +(id)streakWithFade:(float)fade minSeg:(float)seg image:(NSString*)path width:(float)width length:(float)length color:(ccColor4B)color 44 | { 45 | return [[[self alloc] initWithFade:(float)fade minSeg:seg image:path width:width length:length color:color] autorelease]; 46 | } 47 | 48 | -(id)initWithFade:(float)fade minSeg:(float)seg image:(NSString*)path width:(float)width length:(float)length color:(ccColor4B)color 49 | { 50 | if( (self=[super init])) { 51 | segThreshold_ = seg; 52 | width_ = width; 53 | lastLocation_ = CGPointZero; 54 | ribbon_ = [CCRibbon ribbonWithWidth:width_ image:path length:length color:color fade:fade]; 55 | [self addChild:ribbon_]; 56 | 57 | // update ribbon position. Use schedule:interval and not scheduleUpdated. issue #1075 58 | [self schedule:@selector(update:) interval:0]; 59 | } 60 | return self; 61 | } 62 | 63 | -(void)update:(ccTime)delta 64 | { 65 | CGPoint location = [self convertToWorldSpace:CGPointZero]; 66 | [ribbon_ setPosition:ccp(-1*location.x, -1*location.y)]; 67 | float len = ccpLength(ccpSub(lastLocation_, location)); 68 | if (len > segThreshold_) 69 | { 70 | [ribbon_ addPointAt:location width:width_]; 71 | lastLocation_ = location; 72 | } 73 | [ribbon_ update:delta]; 74 | } 75 | 76 | 77 | -(void)dealloc 78 | { 79 | [super dealloc]; 80 | } 81 | 82 | #pragma mark MotionStreak - CocosNodeTexture protocol 83 | 84 | -(void) setTexture:(CCTexture2D*) texture 85 | { 86 | [ribbon_ setTexture: texture]; 87 | } 88 | 89 | -(CCTexture2D*) texture 90 | { 91 | return [ribbon_ texture]; 92 | } 93 | 94 | -(ccBlendFunc) blendFunc 95 | { 96 | return [ribbon_ blendFunc]; 97 | } 98 | 99 | -(void) setBlendFunc:(ccBlendFunc)blendFunc 100 | { 101 | [ribbon_ setBlendFunc:blendFunc]; 102 | } 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /libs/cocos2d/CCParallaxNode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #import "CCNode.h" 28 | #import "Support/ccCArray.h" 29 | 30 | /** CCParallaxNode: A node that simulates a parallax scroller 31 | 32 | The children will be moved faster / slower than the parent according the the parallax ratio. 33 | 34 | */ 35 | @interface CCParallaxNode : CCNode 36 | { 37 | ccArray *parallaxArray_; 38 | CGPoint lastPosition; 39 | } 40 | 41 | /** array that holds the offset / ratio of the children */ 42 | @property (nonatomic,readwrite) ccArray * parallaxArray; 43 | 44 | /** Adds a child to the container with a z-order, a parallax ratio and a position offset 45 | It returns self, so you can chain several addChilds. 46 | @since v0.8 47 | */ 48 | -(void) addChild: (CCNode*)node z:(NSInteger)z parallaxRatio:(CGPoint)c positionOffset:(CGPoint)positionOffset; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /libs/cocos2d/CCParticleExamples.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | 28 | #import 29 | 30 | #import "CCParticleSystemPoint.h" 31 | #import "CCParticleSystemQuad.h" 32 | 33 | // build each architecture with the optimal particle system 34 | 35 | // ARMv7, Mac or Simulator use "Quad" particle 36 | #if defined(__ARM_NEON__) || defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || TARGET_IPHONE_SIMULATOR 37 | #define ARCH_OPTIMAL_PARTICLE_SYSTEM CCParticleSystemQuad 38 | 39 | // ARMv6 use "Point" particle 40 | #elif __arm__ 41 | #define ARCH_OPTIMAL_PARTICLE_SYSTEM CCParticleSystemPoint 42 | #else 43 | #error(unknown architecture) 44 | #endif 45 | 46 | 47 | //! A fire particle system 48 | @interface CCParticleFire: ARCH_OPTIMAL_PARTICLE_SYSTEM 49 | { 50 | } 51 | @end 52 | 53 | //! A fireworks particle system 54 | @interface CCParticleFireworks : ARCH_OPTIMAL_PARTICLE_SYSTEM 55 | { 56 | } 57 | @end 58 | 59 | //! A sun particle system 60 | @interface CCParticleSun : ARCH_OPTIMAL_PARTICLE_SYSTEM 61 | { 62 | } 63 | @end 64 | 65 | //! A galaxy particle system 66 | @interface CCParticleGalaxy : ARCH_OPTIMAL_PARTICLE_SYSTEM 67 | { 68 | } 69 | @end 70 | 71 | //! A flower particle system 72 | @interface CCParticleFlower : ARCH_OPTIMAL_PARTICLE_SYSTEM 73 | { 74 | } 75 | @end 76 | 77 | //! A meteor particle system 78 | @interface CCParticleMeteor : ARCH_OPTIMAL_PARTICLE_SYSTEM 79 | { 80 | } 81 | @end 82 | 83 | //! An spiral particle system 84 | @interface CCParticleSpiral : ARCH_OPTIMAL_PARTICLE_SYSTEM 85 | { 86 | } 87 | @end 88 | 89 | //! An explosion particle system 90 | @interface CCParticleExplosion : ARCH_OPTIMAL_PARTICLE_SYSTEM 91 | { 92 | } 93 | @end 94 | 95 | //! An smoke particle system 96 | @interface CCParticleSmoke : ARCH_OPTIMAL_PARTICLE_SYSTEM 97 | { 98 | } 99 | @end 100 | 101 | //! An snow particle system 102 | @interface CCParticleSnow : ARCH_OPTIMAL_PARTICLE_SYSTEM 103 | { 104 | } 105 | @end 106 | 107 | //! A rain particle system 108 | @interface CCParticleRain : ARCH_OPTIMAL_PARTICLE_SYSTEM 109 | { 110 | } 111 | @end 112 | -------------------------------------------------------------------------------- /libs/cocos2d/CCParticleSystemPoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | 28 | #import 29 | #import "CCParticleSystem.h" 30 | 31 | #define CC_MAX_PARTICLE_SIZE 64 32 | 33 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 34 | 35 | /** CCParticleSystemPoint is a subclass of CCParticleSystem 36 | Attributes of a Particle System: 37 | * All the attributes of Particle System 38 | 39 | Features: 40 | * consumes small memory: uses 1 vertex (x,y) per particle, no need to assign tex coordinates 41 | * size can't be bigger than 64 42 | * the system can't be scaled since the particles are rendered using GL_POINT_SPRITE 43 | 44 | Limitations: 45 | * On 3rd gen iPhone devices and iPads, this node performs MUCH slower than CCParticleSystemQuad. 46 | */ 47 | @interface CCParticleSystemPoint : CCParticleSystem 48 | { 49 | // Array of (x,y,size) 50 | ccPointSprite *vertices; 51 | // vertices buffer id 52 | #if CC_USES_VBO 53 | GLuint verticesID; 54 | #endif 55 | } 56 | @end 57 | 58 | #elif __MAC_OS_X_VERSION_MAX_ALLOWED 59 | 60 | #import "CCParticleSystemQuad.h" 61 | 62 | @interface CCParticleSystemPoint : CCParticleSystemQuad 63 | @end 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libs/cocos2d/CCParticleSystemQuad.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Leonardo Kasperavičius 5 | * 6 | * Copyright (c) 2008-2010 Ricardo Quesada 7 | * Copyright (c) 2011 Zynga Inc. 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | * 27 | */ 28 | 29 | 30 | #import "CCParticleSystem.h" 31 | #import "ccConfig.h" 32 | 33 | @class CCSpriteFrame; 34 | 35 | /** CCParticleSystemQuad is a subclass of CCParticleSystem 36 | 37 | It includes all the features of ParticleSystem. 38 | 39 | Special features and Limitations: 40 | - Particle size can be any float number. 41 | - The system can be scaled 42 | - The particles can be rotated 43 | - On 1st and 2nd gen iPhones: It is only a bit slower that CCParticleSystemPoint 44 | - On 3rd gen iPhone and iPads: It is MUCH faster than CCParticleSystemPoint 45 | - It consumes more RAM and more GPU memory than CCParticleSystemPoint 46 | - It supports subrects 47 | @since v0.8 48 | */ 49 | @interface CCParticleSystemQuad : CCParticleSystem 50 | { 51 | ccV2F_C4B_T2F_Quad *quads_; // quads to be rendered 52 | GLushort *indices_; // indices 53 | #if CC_USES_VBO 54 | GLuint quadsID_; // VBO id 55 | #endif 56 | } 57 | 58 | /** initialices the indices for the vertices */ 59 | -(void) initIndices; 60 | 61 | /** initilizes the texture with a rectangle measured Points */ 62 | -(void) initTexCoordsWithRect:(CGRect)rect; 63 | 64 | /** Sets a new CCSpriteFrame as particle. 65 | WARNING: this method is experimental. Use setTexture:withRect instead. 66 | @since v0.99.4 67 | */ 68 | -(void)setDisplayFrame:(CCSpriteFrame*)spriteFrame; 69 | 70 | /** Sets a new texture with a rect. The rect is in Points. 71 | @since v0.99.4 72 | */ 73 | -(void) setTexture:(CCTexture2D *)texture withRect:(CGRect)rect; 74 | 75 | @end 76 | 77 | -------------------------------------------------------------------------------- /libs/cocos2d/CCProgressTimer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Lam Pham 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #import 27 | #import "CCSprite.h" 28 | 29 | /** Types of progress 30 | @since v0.99.1 31 | */ 32 | typedef enum { 33 | /// Radial Counter-Clockwise 34 | kCCProgressTimerTypeRadialCCW, 35 | /// Radial ClockWise 36 | kCCProgressTimerTypeRadialCW, 37 | /// Horizontal Left-Right 38 | kCCProgressTimerTypeHorizontalBarLR, 39 | /// Horizontal Right-Left 40 | kCCProgressTimerTypeHorizontalBarRL, 41 | /// Vertical Bottom-top 42 | kCCProgressTimerTypeVerticalBarBT, 43 | /// Vertical Top-Bottom 44 | kCCProgressTimerTypeVerticalBarTB, 45 | } CCProgressTimerType; 46 | 47 | /** 48 | CCProgresstimer is a subclass of CCNode. 49 | It renders the inner sprite according to the percentage. 50 | The progress can be Radial, Horizontal or vertical. 51 | @since v0.99.1 52 | */ 53 | @interface CCProgressTimer : CCNode 54 | { 55 | CCProgressTimerType type_; 56 | float percentage_; 57 | CCSprite *sprite_; 58 | 59 | int vertexDataCount_; 60 | ccV2F_C4B_T2F *vertexData_; 61 | } 62 | 63 | /** Change the percentage to change progress. */ 64 | @property (nonatomic, readwrite) CCProgressTimerType type; 65 | 66 | /** Percentages are from 0 to 100 */ 67 | @property (nonatomic, readwrite) float percentage; 68 | 69 | /** The image to show the progress percentage */ 70 | @property (nonatomic, readwrite, retain) CCSprite *sprite; 71 | 72 | 73 | /** Creates a progress timer with an image filename as the shape the timer goes through */ 74 | + (id) progressWithFile:(NSString*) filename; 75 | /** Initializes a progress timer with an image filename as the shape the timer goes through */ 76 | - (id) initWithFile:(NSString*) filename; 77 | 78 | /** Creates a progress timer with the texture as the shape the timer goes through */ 79 | + (id) progressWithTexture:(CCTexture2D*) texture; 80 | /** Creates a progress timer with the texture as the shape the timer goes through */ 81 | - (id) initWithTexture:(CCTexture2D*) texture; 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /libs/cocos2d/CCScene.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | 28 | #import "CCNode.h" 29 | 30 | /** CCScene is a subclass of CCNode that is used only as an abstract concept. 31 | 32 | CCScene an CCNode are almost identical with the difference that CCScene has it's 33 | anchor point (by default) at the center of the screen. 34 | 35 | For the moment CCScene has no other logic than that, but in future releases it might have 36 | additional logic. 37 | 38 | It is a good practice to use and CCScene as the parent of all your nodes. 39 | */ 40 | @interface CCScene : CCNode 41 | { 42 | } 43 | @end 44 | -------------------------------------------------------------------------------- /libs/cocos2d/CCScene.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | 28 | #import "CCScene.h" 29 | #import "Support/CGPointExtension.h" 30 | #import "CCDirector.h" 31 | 32 | 33 | @implementation CCScene 34 | -(id) init 35 | { 36 | if( (self=[super init]) ) { 37 | CGSize s = [[CCDirector sharedDirector] winSize]; 38 | self.isRelativeAnchorPoint = NO; 39 | anchorPoint_ = ccp(0.5f, 0.5f); 40 | [self setContentSize:s]; 41 | } 42 | 43 | return self; 44 | } 45 | @end 46 | -------------------------------------------------------------------------------- /libs/cocos2d/CCSpriteFrame.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2011 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #import 28 | #import "CCNode.h" 29 | #import "CCProtocols.h" 30 | 31 | /** A CCSpriteFrame has: 32 | - texture: A CCTexture2D that will be used by the CCSprite 33 | - rectangle: A rectangle of the texture 34 | 35 | 36 | You can modify the frame of a CCSprite by doing: 37 | 38 | CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:texture rect:rect offset:offset]; 39 | [sprite setDisplayFrame:frame]; 40 | */ 41 | @interface CCSpriteFrame : NSObject 42 | { 43 | CGRect rect_; 44 | CGRect rectInPixels_; 45 | BOOL rotated_; 46 | CGPoint offsetInPixels_; 47 | CGSize originalSizeInPixels_; 48 | CCTexture2D *texture_; 49 | } 50 | /** rect of the frame in points. If it is updated, then rectInPixels will be updated too. */ 51 | @property (nonatomic,readwrite) CGRect rect; 52 | 53 | /** rect of the frame in pixels. If it is updated, then rect (points) will be udpated too. */ 54 | @property (nonatomic,readwrite) CGRect rectInPixels; 55 | 56 | /** whether or not the rect of the frame is rotated ( x = x+width, y = y+height, width = height, height = width ) */ 57 | @property (nonatomic,readwrite) BOOL rotated; 58 | 59 | /** offset of the frame in pixels */ 60 | @property (nonatomic,readwrite) CGPoint offsetInPixels; 61 | 62 | /** original size of the trimmed image in pixels */ 63 | @property (nonatomic,readwrite) CGSize originalSizeInPixels; 64 | 65 | /** texture of the frame */ 66 | @property (nonatomic, retain, readwrite) CCTexture2D *texture; 67 | 68 | /** Create a CCSpriteFrame with a texture, rect in points. 69 | It is assumed that the frame was not trimmed. 70 | */ 71 | +(id) frameWithTexture:(CCTexture2D*)texture rect:(CGRect)rect; 72 | 73 | /** Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. 74 | The originalSize is the size in points of the frame before being trimmed. 75 | */ 76 | +(id) frameWithTexture:(CCTexture2D*)texture rectInPixels:(CGRect)rect rotated:(BOOL)rotated offset:(CGPoint)offset originalSize:(CGSize)originalSize; 77 | 78 | 79 | /** Initializes a CCSpriteFrame with a texture, rect in points; 80 | It is assumed that the frame was not trimmed. 81 | */ 82 | -(id) initWithTexture:(CCTexture2D*)texture rect:(CGRect)rect; 83 | 84 | /** Initializes a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. 85 | The originalSize is the size in points of the frame before being trimmed. 86 | */ 87 | -(id) initWithTexture:(CCTexture2D*)texture rectInPixels:(CGRect)rect rotated:(BOOL)rotated offset:(CGPoint)offset originalSize:(CGSize)originalSize; 88 | 89 | @end 90 | 91 | -------------------------------------------------------------------------------- /libs/cocos2d/CCTMXObjectGroup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Neophit 5 | * 6 | * Copyright (c) 2010 Ricardo Quesada 7 | * Copyright (c) 2011 Zynga Inc. 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | * 27 | * 28 | * TMX Tiled Map support: 29 | * http://www.mapeditor.org 30 | * 31 | */ 32 | 33 | #import "CCNode.h" 34 | 35 | 36 | @class CCTMXObjectGroup; 37 | 38 | 39 | /** CCTMXObjectGroup represents the TMX object group. 40 | @since v0.99.0 41 | */ 42 | @interface CCTMXObjectGroup : NSObject 43 | { 44 | NSString *groupName_; 45 | CGPoint positionOffset_; 46 | NSMutableArray *objects_; 47 | NSMutableDictionary *properties_; 48 | } 49 | 50 | /** name of the group */ 51 | @property (nonatomic,readwrite,retain) NSString *groupName; 52 | /** offset position of child objects */ 53 | @property (nonatomic,readwrite,assign) CGPoint positionOffset; 54 | /** array of the objects */ 55 | @property (nonatomic,readwrite,retain) NSMutableArray *objects; 56 | /** list of properties stored in a dictionary */ 57 | @property (nonatomic,readwrite,retain) NSMutableDictionary *properties; 58 | 59 | /** return the value for the specific property name */ 60 | -(id) propertyNamed:(NSString *)propertyName; 61 | 62 | /** return the dictionary for the specific object name. 63 | It will return the 1st object found on the array for the given name. 64 | */ 65 | -(NSMutableDictionary*) objectNamed:(NSString *)objectName; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /libs/cocos2d/CCTMXObjectGroup.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Neophit 5 | * 6 | * Copyright (c) 2010 Ricardo Quesada 7 | * Copyright (c) 2011 Zynga Inc. 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | * 27 | * 28 | * TMX Tiled Map support: 29 | * http://www.mapeditor.org 30 | * 31 | */ 32 | 33 | #import "CCTMXObjectGroup.h" 34 | #import "CCTMXXMLParser.h" 35 | #import "ccMacros.h" 36 | #import "Support/CGPointExtension.h" 37 | 38 | 39 | #pragma mark - 40 | #pragma mark TMXObjectGroup 41 | 42 | @implementation CCTMXObjectGroup 43 | 44 | @synthesize groupName = groupName_; 45 | @synthesize objects = objects_; 46 | @synthesize positionOffset = positionOffset_; 47 | @synthesize properties = properties_; 48 | 49 | -(id) init 50 | { 51 | if (( self=[super init] )) { 52 | self.groupName = nil; 53 | self.positionOffset = CGPointZero; 54 | self.objects = [NSMutableArray arrayWithCapacity:10]; 55 | self.properties = [NSMutableDictionary dictionaryWithCapacity:5]; 56 | } 57 | return self; 58 | } 59 | 60 | -(void) dealloc 61 | { 62 | CCLOGINFO( @"cocos2d: deallocing %@", self ); 63 | 64 | [groupName_ release]; 65 | [objects_ release]; 66 | [properties_ release]; 67 | [super dealloc]; 68 | } 69 | 70 | -(NSMutableDictionary*) objectNamed:(NSString *)objectName 71 | { 72 | for( id object in objects_ ) { 73 | if( [[object valueForKey:@"name"] isEqual:objectName] ) 74 | return object; 75 | } 76 | 77 | // object not found 78 | return nil; 79 | } 80 | 81 | -(id) propertyNamed:(NSString *)propertyName 82 | { 83 | return [properties_ valueForKey:propertyName]; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /libs/cocos2d/CCTileMapAtlas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | #import "CCTextureAtlas.h" 28 | #import "CCAtlasNode.h" 29 | #import "Support/TGAlib.h" 30 | 31 | /** CCTileMapAtlas is a subclass of CCAtlasNode. 32 | 33 | It knows how to render a map based of tiles. 34 | The tiles must be in a .PNG format while the map must be a .TGA file. 35 | 36 | For more information regarding the format, please see this post: 37 | http://www.cocos2d-iphone.org/archives/27 38 | 39 | All features from CCAtlasNode are valid in CCTileMapAtlas 40 | 41 | IMPORTANT: 42 | This class is deprecated. It is maintained for compatibility reasons only. 43 | You SHOULD not use this class. 44 | Instead, use the newer TMX file format: CCTMXTiledMap 45 | */ 46 | @interface CCTileMapAtlas : CCAtlasNode 47 | { 48 | 49 | /// info about the map file 50 | tImageTGA *tgaInfo; 51 | 52 | /// x,y to altas dicctionary 53 | NSMutableDictionary *posToAtlasIndex; 54 | 55 | /// numbers of tiles to render 56 | int itemsToRender; 57 | } 58 | 59 | /** TileMap info */ 60 | @property (nonatomic,readonly) tImageTGA *tgaInfo; 61 | 62 | /** creates a CCTileMap with a tile file (atlas) with a map file and the width and height of each tile in points. 63 | The tile file will be loaded using the TextureMgr. 64 | */ 65 | +(id) tileMapAtlasWithTileFile:(NSString*)tile mapFile:(NSString*)map tileWidth:(int)w tileHeight:(int)h; 66 | 67 | /** initializes a CCTileMap with a tile file (atlas) with a map file and the width and height of each tile in points. 68 | The file will be loaded using the TextureMgr. 69 | */ 70 | -(id) initWithTileFile:(NSString*)tile mapFile:(NSString*)map tileWidth:(int)w tileHeight:(int)h; 71 | 72 | /** returns a tile from position x,y. 73 | For the moment only channel R is used 74 | */ 75 | -(ccColor3B) tileAt: (ccGridSize) position; 76 | 77 | /** sets a tile at position x,y. 78 | For the moment only channel R is used 79 | */ 80 | -(void) setTile:(ccColor3B)tile at:(ccGridSize)position; 81 | /** dealloc the map from memory */ 82 | -(void) releaseMap; 83 | @end 84 | -------------------------------------------------------------------------------- /libs/cocos2d/CCTransitionPageTurn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import "CCTransition.h" 28 | 29 | /** CCTransitionPageTurn transition. 30 | * A transition which peels back the bottom right hand corner of a scene 31 | * to transition to the scene beneath it simulating a page turn 32 | * 33 | * This uses a 3DAction so it's strongly recommended that depth buffering 34 | * is turned on in CCDirector using: 35 | * 36 | * [[CCDirector sharedDirector] setDepthBufferFormat:kCCDepthBuffer16]; 37 | * 38 | * @since v0.8.2 39 | */ 40 | @interface CCTransitionPageTurn : CCTransitionScene 41 | { 42 | BOOL back_; 43 | } 44 | /** 45 | * creates a base transition with duration and incoming scene 46 | * if back is TRUE then the effect is reversed to appear as if the incoming 47 | * scene is being turned from left over the outgoing scene 48 | */ 49 | +(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s backwards:(BOOL) back; 50 | 51 | /** 52 | * creates a base transition with duration and incoming scene 53 | * if back is TRUE then the effect is reversed to appear as if the incoming 54 | * scene is being turned from left over the outgoing scene 55 | */ 56 | -(id) initWithDuration:(ccTime) t scene:(CCScene*)s backwards:(BOOL) back; 57 | 58 | -(CCActionInterval*) actionWithSize:(ccGridSize) vector; 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /libs/cocos2d/CCTransitionPageTurn.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import "CCTransitionPageTurn.h" 28 | #import "CCActionPageTurn3D.h" 29 | #import "CCDirector.h" 30 | 31 | @implementation CCTransitionPageTurn 32 | 33 | /** creates a base transition with duration and incoming scene */ 34 | +(id) transitionWithDuration:(ccTime) t scene:(CCScene*)s backwards:(BOOL) back 35 | { 36 | return [[[self alloc] initWithDuration:t scene:s backwards:back] autorelease]; 37 | } 38 | 39 | /** initializes a transition with duration and incoming scene */ 40 | -(id) initWithDuration:(ccTime) t scene:(CCScene*)s backwards:(BOOL) back 41 | { 42 | // XXX: needed before [super init] 43 | back_ = back; 44 | 45 | if( ( self = [super initWithDuration:t scene:s] ) ) 46 | { 47 | // do something 48 | } 49 | return self; 50 | } 51 | 52 | -(void) sceneOrder 53 | { 54 | inSceneOnTop_ = back_; 55 | } 56 | 57 | // 58 | -(void) onEnter 59 | { 60 | [super onEnter]; 61 | 62 | CGSize s = [[CCDirector sharedDirector] winSize]; 63 | int x, y; 64 | if( s.width > s.height) 65 | { 66 | x = 16; 67 | y = 12; 68 | } 69 | else 70 | { 71 | x = 12; 72 | y = 16; 73 | } 74 | 75 | id action = [self actionWithSize:ccg(x,y)]; 76 | 77 | if(! back_ ) 78 | { 79 | [outScene_ runAction: [CCSequence actions: 80 | action, 81 | [CCCallFunc actionWithTarget:self selector:@selector(finish)], 82 | [CCStopGrid action], 83 | nil] 84 | ]; 85 | } 86 | else 87 | { 88 | // to prevent initial flicker 89 | inScene_.visible = NO; 90 | [inScene_ runAction: [CCSequence actions: 91 | [CCShow action], 92 | action, 93 | [CCCallFunc actionWithTarget:self selector:@selector(finish)], 94 | [CCStopGrid action], 95 | nil] 96 | ]; 97 | } 98 | 99 | } 100 | 101 | -(CCActionInterval*) actionWithSize: (ccGridSize) v 102 | { 103 | if( back_ ) 104 | { 105 | // Get hold of the PageTurn3DAction 106 | return [CCReverseTime actionWithAction: 107 | [CCPageTurn3D actionWithSize:v duration:duration_]]; 108 | } 109 | else 110 | { 111 | // Get hold of the PageTurn3DAction 112 | return [CCPageTurn3D actionWithSize:v duration:duration_]; 113 | } 114 | } 115 | 116 | @end 117 | 118 | -------------------------------------------------------------------------------- /libs/cocos2d/CCTransitionRadial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Lam Pham 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #import "CCTransition.h" 27 | #import "CCProgressTimer.h" 28 | #import "CCActionProgressTimer.h" 29 | 30 | /** CCTransitionRadialCCW transition. 31 | A counter colock-wise radial transition to the next scene 32 | */ 33 | @interface CCTransitionRadialCCW : CCTransitionScene 34 | @end 35 | 36 | /** CCTransitionRadialCW transition. 37 | A counter colock-wise radial transition to the next scene 38 | */ 39 | @interface CCTransitionRadialCW : CCTransitionRadialCCW 40 | @end 41 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/CCGL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | // 27 | // Common layer for OpenGL stuff 28 | // 29 | 30 | #import 31 | 32 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 33 | #import 34 | #import 35 | #import 36 | #import "iOS/glu.h" 37 | #import "iOS/EAGLView.h" 38 | 39 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) 40 | #import 41 | #import 42 | #import // needed for NSOpenGLView 43 | #import "Mac/MacGLView.h" 44 | #endif 45 | 46 | 47 | // iOS 48 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 49 | #define CC_GLVIEW EAGLView 50 | #define ccglOrtho glOrthof 51 | #define ccglClearDepth glClearDepthf 52 | #define ccglGenerateMipmap glGenerateMipmapOES 53 | #define ccglGenFramebuffers glGenFramebuffersOES 54 | #define ccglBindFramebuffer glBindFramebufferOES 55 | #define ccglFramebufferTexture2D glFramebufferTexture2DOES 56 | #define ccglDeleteFramebuffers glDeleteFramebuffersOES 57 | #define ccglCheckFramebufferStatus glCheckFramebufferStatusOES 58 | #define ccglTranslate glTranslatef 59 | 60 | #define CC_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES 61 | #define CC_GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_OES 62 | #define CC_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_OES 63 | #define CC_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES 64 | 65 | // Mac 66 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) 67 | #define CC_GLVIEW MacGLView 68 | #define ccglOrtho glOrtho 69 | #define ccglClearDepth glClearDepth 70 | #define ccglGenerateMipmap glGenerateMipmap 71 | #define ccglGenFramebuffers glGenFramebuffers 72 | #define ccglBindFramebuffer glBindFramebuffer 73 | #define ccglFramebufferTexture2D glFramebufferTexture2D 74 | #define ccglDeleteFramebuffers glDeleteFramebuffers 75 | #define ccglCheckFramebufferStatus glCheckFramebufferStatus 76 | #define ccglTranslate glTranslated 77 | 78 | #define CC_GL_FRAMEBUFFER GL_FRAMEBUFFER 79 | #define CC_GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING 80 | #define CC_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0 81 | #define CC_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/CCNS.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | // 27 | // Common layer for NS (Next-Step) stuff 28 | // 29 | 30 | #import 31 | 32 | #import // for NSObject 33 | 34 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 35 | 36 | #define CCRectFromString(__r__) CGRectFromString(__r__) 37 | #define CCPointFromString(__p__) CGPointFromString(__p__) 38 | #define CCSizeFromString(__s__) CGSizeFromString(__s__) 39 | #define CCNSSizeToCGSize 40 | #define CCNSRectToCGRect 41 | #define CCNSPointToCGPoint 42 | #define CCTextAlignment UITextAlignment 43 | #define CCTextAlignmentCenter UITextAlignmentCenter 44 | #define CCTextAlignmentLeft UITextAlignmentLeft 45 | #define CCTextAlignmentRight UITextAlignmentRight 46 | #define CCLineBreakMode UILineBreakMode 47 | #define CCLineBreakModeWordWrap UILineBreakModeWordWrap 48 | #define CCLineBreakModeCharacterWrap UILineBreakModeCharacterWrap 49 | #define CCLineBreakModeClip UILineBreakModeClip 50 | #define CCLineBreakModeHeadTruncation UILineBreakModeHeadTruncation 51 | #define CCLineBreakModeTailTruncation UILineBreakModeTailTruncation 52 | #define CCLineBreakModeMiddleTruncation UILineBreakModeMiddleTruncation 53 | 54 | 55 | 56 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) 57 | 58 | #define CCRectFromString(__r__) NSRectToCGRect( NSRectFromString(__r__) ) 59 | #define CCPointFromString(__p__) NSPointToCGPoint( NSPointFromString(__p__) ) 60 | #define CCSizeFromString(__s__) NSSizeToCGSize( NSSizeFromString(__s__) ) 61 | #define CCNSSizeToCGSize NSSizeToCGSize 62 | #define CCNSRectToCGRect NSRectToCGRect 63 | #define CCNSPointToCGPoint NSPointToCGPoint 64 | #define CCTextAlignment NSTextAlignment 65 | #define CCTextAlignmentCenter NSCenterTextAlignment 66 | #define CCTextAlignmentLeft NSLeftTextAlignment 67 | #define CCTextAlignmentRight NSRightTextAlignment 68 | #define CCLineBreakMode NSLineBreakMode 69 | #define CCLineBreakModeWordWrap NSLineBreakByWordWrapping 70 | #define CCLineBreakModeClip -1 71 | #define CCLineBreakModeHeadTruncation -1 72 | #define CCLineBreakModeTailTruncation -1 73 | #define CCLineBreakModeMiddleTruncation -1 74 | 75 | 76 | #endif 77 | 78 | 79 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/Mac/CCDirectorMac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | 27 | // Only compile this code on Mac. These files should not be included on your iOS project. 28 | // But in case they are included, it won't be compiled. 29 | #import 30 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 31 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) 32 | 33 | #import 34 | #import "../../CCDirector.h" 35 | 36 | enum { 37 | /// If the window is resized, it won't be autoscaled 38 | kCCDirectorResize_NoScale, 39 | /// If the window is resized, it will be autoscaled (default behavior) 40 | kCCDirectorResize_AutoScale, 41 | }; 42 | 43 | @interface CCDirector (MacExtension) 44 | /** converts an NSEvent to GL coordinates */ 45 | -(CGPoint) convertEventToGL:(NSEvent*)event; 46 | @end 47 | 48 | /** Base class of Mac directors 49 | @since v0.99.5 50 | */ 51 | @interface CCDirectorMac : CCDirector 52 | { 53 | BOOL isFullScreen_; 54 | int resizeMode_; 55 | CGPoint winOffset_; 56 | CGSize originalWinSize_; 57 | 58 | NSWindow *fullScreenWindow_; 59 | 60 | // cache 61 | NSWindow *windowGLView_; 62 | NSView *superViewGLView_; 63 | NSRect originalWinRect_; // Original size and position 64 | } 65 | 66 | // whether or not the view is in fullscreen mode 67 | @property (nonatomic, readonly) BOOL isFullScreen; 68 | 69 | // resize mode: with or without scaling 70 | @property (nonatomic, readwrite) int resizeMode; 71 | 72 | @property (nonatomic, readwrite) CGSize originalWinSize; 73 | 74 | /** Sets the view in fullscreen or window mode */ 75 | - (void) setFullScreen:(BOOL)fullscreen; 76 | 77 | /** Converts window size coordiantes to logical coordinates. 78 | Useful only if resizeMode is kCCDirectorResize_Scale. 79 | If resizeMode is kCCDirectorResize_NoScale, then no conversion will be done. 80 | */ 81 | - (CGPoint) convertToLogicalCoordinates:(CGPoint)coordinates; 82 | @end 83 | 84 | 85 | /** DisplayLinkDirector is a Director that synchronizes timers with the refresh rate of the display. 86 | * 87 | * Features and Limitations: 88 | * - Only available on 3.1+ 89 | * - Scheduled timers & drawing are synchronizes with the refresh rate of the display 90 | * - Only supports animation intervals of 1/60 1/30 & 1/15 91 | * 92 | * It is the recommended Director if the SDK is 3.1 or newer 93 | * 94 | * @since v0.8.2 95 | */ 96 | @interface CCDirectorDisplayLink : CCDirectorMac 97 | { 98 | CVDisplayLinkRef displayLink; 99 | } 100 | @end 101 | 102 | #endif // __MAC_OS_X_VERSION_MAX_ALLOWED 103 | 104 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/Mac/MacGLView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | // Only compile this code on Mac. These files should not be included on your iOS project. 27 | // But in case they are included, it won't be compiled. 28 | #import 29 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 30 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) 31 | 32 | #import 33 | 34 | #import "../../ccConfig.h" 35 | 36 | //PROTOCOLS: 37 | 38 | @protocol MacEventDelegate 39 | // Mouse 40 | - (void)mouseDown:(NSEvent *)theEvent; 41 | - (void)mouseUp:(NSEvent *)theEvent; 42 | - (void)mouseMoved:(NSEvent *)theEvent; 43 | - (void)mouseDragged:(NSEvent *)theEvent; 44 | - (void)rightMouseDown:(NSEvent*)event; 45 | - (void)rightMouseDragged:(NSEvent*)event; 46 | - (void)rightMouseUp:(NSEvent*)event; 47 | - (void)otherMouseDown:(NSEvent*)event; 48 | - (void)otherMouseDragged:(NSEvent*)event; 49 | - (void)otherMouseUp:(NSEvent*)event; 50 | - (void)scrollWheel:(NSEvent *)theEvent; 51 | - (void)mouseEntered:(NSEvent *)theEvent; 52 | - (void)mouseExited:(NSEvent *)theEvent; 53 | 54 | 55 | // Keyboard 56 | - (void)keyDown:(NSEvent *)theEvent; 57 | - (void)keyUp:(NSEvent *)theEvent; 58 | - (void)flagsChanged:(NSEvent *)theEvent; 59 | 60 | // Touches 61 | - (void)touchesBeganWithEvent:(NSEvent *)event; 62 | - (void)touchesMovedWithEvent:(NSEvent *)event; 63 | - (void)touchesEndedWithEvent:(NSEvent *)event; 64 | - (void)touchesCancelledWithEvent:(NSEvent *)event; 65 | 66 | #if CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD 67 | - (void)queueEvent:(NSEvent*)event selector:(SEL)selector; 68 | #endif 69 | 70 | @end 71 | 72 | /** MacGLView 73 | 74 | Only available for Mac OS X 75 | */ 76 | @interface MacGLView : NSOpenGLView { 77 | id eventDelegate_; 78 | } 79 | 80 | @property (nonatomic, readwrite, assign) id eventDelegate; 81 | 82 | // initializes the MacGLView with a frame rect and an OpenGL context 83 | - (id) initWithFrame:(NSRect)frameRect shareContext:(NSOpenGLContext*)context; 84 | 85 | // private 86 | +(void) load_; 87 | @end 88 | 89 | #endif // __MAC_OS_X_VERSION_MAX_ALLOWED -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/Mac/MacWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | // Only compile this code on Mac. These files should not be included on your iOS project. 26 | // But in case they are included, it won't be compiled. 27 | #import 28 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 29 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) 30 | 31 | #import 32 | 33 | 34 | @interface MacWindow : NSWindow 35 | { 36 | } 37 | - (id) initWithFrame:(NSRect)frame fullscreen:(BOOL)fullscreen; 38 | 39 | @end 40 | 41 | 42 | #endif // __MAC_OS_X_VERSION_MAX_ALLOWED -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/Mac/MacWindow.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | // Only compile this code on Mac. These files should not be included on your iOS project. 26 | // But in case they are included, it won't be compiled. 27 | #import 28 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 29 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) 30 | 31 | #import "MacWindow.h" 32 | 33 | 34 | @implementation MacWindow 35 | 36 | - (id) initWithFrame:(NSRect)frame fullscreen:(BOOL)fullscreen 37 | { 38 | int styleMask = fullscreen ? NSBackingStoreBuffered : ( NSTitledWindowMask | NSClosableWindowMask ); 39 | self = [self initWithContentRect:frame 40 | styleMask:styleMask 41 | backing:NSBackingStoreBuffered 42 | defer:YES]; 43 | 44 | if (self != nil) 45 | { 46 | if(fullscreen) 47 | { 48 | [self setLevel:NSMainMenuWindowLevel+1]; 49 | [self setHidesOnDeactivate:YES]; 50 | [self setHasShadow:NO]; 51 | } 52 | 53 | [self setAcceptsMouseMovedEvents:NO]; 54 | [self setOpaque:YES]; 55 | } 56 | return self; 57 | } 58 | 59 | - (BOOL) canBecomeKeyWindow 60 | { 61 | return YES; 62 | } 63 | 64 | - (BOOL) canBecomeMainWindow 65 | { 66 | return YES; 67 | } 68 | @end 69 | 70 | #endif // __MAC_OS_X_VERSION_MAX_ALLOWED 71 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/iOS/CCTouchDelegateProtocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Valentin Milea 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | // Only compile this code on iOS. These files should NOT be included on your Mac project. 27 | // But in case they are included, it won't be compiled. 28 | #import 29 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 30 | 31 | #import 32 | 33 | /** 34 | CCTargetedTouchDelegate. 35 | 36 | Using this type of delegate results in two benefits: 37 | 1. You don't need to deal with NSSets, the dispatcher does the job of splitting 38 | them. You get exactly one UITouch per call. 39 | 2. You can *claim* a UITouch by returning YES in ccTouchBegan. Updates of claimed 40 | touches are sent only to the delegate(s) that claimed them. So if you get a move/ 41 | ended/cancelled update you're sure it's your touch. This frees you from doing a 42 | lot of checks when doing multi-touch. 43 | 44 | (The name TargetedTouchDelegate relates to updates "targeting" their specific 45 | handler, without bothering the other handlers.) 46 | @since v0.8 47 | */ 48 | @protocol CCTargetedTouchDelegate 49 | 50 | /** Return YES to claim the touch. 51 | @since v0.8 52 | */ 53 | - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event; 54 | @optional 55 | // touch updates: 56 | - (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event; 57 | - (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event; 58 | - (void)ccTouchCancelled:(UITouch *)touch withEvent:(UIEvent *)event; 59 | @end 60 | 61 | /** 62 | CCStandardTouchDelegate. 63 | 64 | This type of delegate is the same one used by CocoaTouch. You will receive all the events (Began,Moved,Ended,Cancelled). 65 | @since v0.8 66 | */ 67 | @protocol CCStandardTouchDelegate 68 | @optional 69 | - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; 70 | - (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; 71 | - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; 72 | - (void)ccTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; 73 | @end 74 | 75 | #endif // __IPHONE_OS_VERSION_MAX_ALLOWED 76 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/iOS/CCTouchHandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Valentin Milea 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | // Only compile this code on iOS. These files should NOT be included on your Mac project. 27 | // But in case they are included, it won't be compiled. 28 | #import 29 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 30 | 31 | /* 32 | * This file contains the delegates of the touches 33 | * There are 2 possible delegates: 34 | * - CCStandardTouchHandler: propagates all the events at once 35 | * - CCTargetedTouchHandler: propagates 1 event at the time 36 | */ 37 | 38 | #import "CCTouchDelegateProtocol.h" 39 | #import "CCTouchDispatcher.h" 40 | 41 | /** 42 | CCTouchHandler 43 | Object than contains the delegate and priority of the event handler. 44 | */ 45 | @interface CCTouchHandler : NSObject { 46 | id delegate; 47 | int priority; 48 | ccTouchSelectorFlag enabledSelectors_; 49 | } 50 | 51 | /** delegate */ 52 | @property(nonatomic, readwrite, retain) id delegate; 53 | /** priority */ 54 | @property(nonatomic, readwrite) int priority; // default 0 55 | /** enabled selectors */ 56 | @property(nonatomic,readwrite) ccTouchSelectorFlag enabledSelectors; 57 | 58 | /** allocates a TouchHandler with a delegate and a priority */ 59 | + (id)handlerWithDelegate:(id)aDelegate priority:(int)priority; 60 | /** initializes a TouchHandler with a delegate and a priority */ 61 | - (id)initWithDelegate:(id)aDelegate priority:(int)priority; 62 | @end 63 | 64 | /** CCStandardTouchHandler 65 | It forwardes each event to the delegate. 66 | */ 67 | @interface CCStandardTouchHandler : CCTouchHandler 68 | { 69 | } 70 | @end 71 | 72 | /** 73 | CCTargetedTouchHandler 74 | Object than contains the claimed touches and if it swallos touches. 75 | Used internally by TouchDispatcher 76 | */ 77 | @interface CCTargetedTouchHandler : CCTouchHandler { 78 | BOOL swallowsTouches; 79 | NSMutableSet *claimedTouches; 80 | } 81 | /** whether or not the touches are swallowed */ 82 | @property(nonatomic, readwrite) BOOL swallowsTouches; // default NO 83 | /** MutableSet that contains the claimed touches */ 84 | @property(nonatomic, readonly) NSMutableSet *claimedTouches; 85 | 86 | /** allocates a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not */ 87 | + (id)handlerWithDelegate:(id) aDelegate priority:(int)priority swallowsTouches:(BOOL)swallowsTouches; 88 | /** initializes a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not */ 89 | - (id)initWithDelegate:(id) aDelegate priority:(int)priority swallowsTouches:(BOOL)swallowsTouches; 90 | 91 | @end 92 | 93 | #endif // __IPHONE_OS_VERSION_MAX_ALLOWED 94 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/iOS/ES1Renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | * 26 | * File autogenerated with Xcode. Adapted for cocos2d needs. 27 | */ 28 | 29 | // Only compile this code on iOS. These files should NOT be included on your Mac project. 30 | // But in case they are included, it won't be compiled. 31 | #import 32 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 33 | 34 | 35 | #import "ESRenderer.h" 36 | 37 | #import 38 | #import 39 | 40 | @interface ES1Renderer : NSObject 41 | { 42 | // The pixel dimensions of the CAEAGLLayer 43 | GLint backingWidth_; 44 | GLint backingHeight_; 45 | 46 | unsigned int samplesToUse_; 47 | BOOL multiSampling_; 48 | 49 | unsigned int depthFormat_; 50 | unsigned int pixelFormat_; 51 | 52 | // The OpenGL ES names for the framebuffer and renderbuffer used to render to this view 53 | GLuint defaultFramebuffer_; 54 | GLuint colorRenderbuffer_; 55 | GLuint depthBuffer_; 56 | 57 | 58 | //buffers for MSAA 59 | GLuint msaaFramebuffer_; 60 | GLuint msaaColorbuffer_; 61 | 62 | EAGLContext *context_; 63 | } 64 | 65 | /** EAGLContext */ 66 | @property (nonatomic,readonly) EAGLContext* context; 67 | 68 | - (BOOL)resizeFromLayer:(CAEAGLLayer *)layer; 69 | 70 | @end 71 | 72 | #endif // __IPHONE_OS_VERSION_MAX_ALLOWED 73 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/iOS/ESRenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | * 26 | * File autogenerated with Xcode. Adapted for cocos2d needs. 27 | */ 28 | 29 | // Only compile this code on iOS. These files should NOT be included on your Mac project. 30 | // But in case they are included, it won't be compiled. 31 | #import 32 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 33 | 34 | #import 35 | 36 | #import 37 | #import 38 | 39 | @protocol ESRenderer 40 | 41 | - (id) initWithDepthFormat:(unsigned int)depthFormat withPixelFormat:(unsigned int)pixelFormat withSharegroup:(EAGLSharegroup*)sharegroup withMultiSampling:(BOOL) multiSampling withNumberOfSamples:(unsigned int) requestedSamples; 42 | 43 | - (BOOL) resizeFromLayer:(CAEAGLLayer *)layer; 44 | 45 | - (EAGLContext*) context; 46 | - (CGSize) backingSize; 47 | 48 | - (unsigned int) colorRenderBuffer; 49 | - (unsigned int) defaultFrameBuffer; 50 | - (unsigned int) msaaFrameBuffer; 51 | - (unsigned int) msaaColorBuffer; 52 | @end 53 | 54 | #endif // __IPHONE_OS_VERSION_MAX_ALLOWED 55 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/iOS/glu.c: -------------------------------------------------------------------------------- 1 | // 2 | // cocos2d (incomplete) GLU implementation 3 | // 4 | // gluLookAt and gluPerspective from: 5 | // http://jet.ro/creations (San Angeles Observation) 6 | // 7 | // 8 | 9 | // Only compile this code on iOS. These files should NOT be included on your Mac project. 10 | // But in case they are included, it won't be compiled. 11 | #import 12 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 13 | 14 | #import 15 | #import 16 | #import "../../Support/OpenGL_Internal.h" 17 | #include "glu.h" 18 | 19 | void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) 20 | { 21 | GLfloat xmin, xmax, ymin, ymax; 22 | 23 | ymax = zNear * (GLfloat)tanf(fovy * (float)M_PI / 360); 24 | ymin = -ymax; 25 | xmin = ymin * aspect; 26 | xmax = ymax * aspect; 27 | 28 | glFrustumf(xmin, xmax, 29 | ymin, ymax, 30 | zNear, zFar); 31 | } 32 | 33 | void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, 34 | GLfloat centerx, GLfloat centery, GLfloat centerz, 35 | GLfloat upx, GLfloat upy, GLfloat upz) 36 | { 37 | GLfloat m[16]; 38 | GLfloat x[3], y[3], z[3]; 39 | GLfloat mag; 40 | 41 | /* Make rotation matrix */ 42 | 43 | /* Z vector */ 44 | z[0] = eyex - centerx; 45 | z[1] = eyey - centery; 46 | z[2] = eyez - centerz; 47 | mag = (float)sqrtf(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]); 48 | if (mag) { 49 | z[0] /= mag; 50 | z[1] /= mag; 51 | z[2] /= mag; 52 | } 53 | 54 | /* Y vector */ 55 | y[0] = upx; 56 | y[1] = upy; 57 | y[2] = upz; 58 | 59 | /* X vector = Y cross Z */ 60 | x[0] = y[1] * z[2] - y[2] * z[1]; 61 | x[1] = -y[0] * z[2] + y[2] * z[0]; 62 | x[2] = y[0] * z[1] - y[1] * z[0]; 63 | 64 | /* Recompute Y = Z cross X */ 65 | y[0] = z[1] * x[2] - z[2] * x[1]; 66 | y[1] = -z[0] * x[2] + z[2] * x[0]; 67 | y[2] = z[0] * x[1] - z[1] * x[0]; 68 | 69 | /* cross product gives area of parallelogram, which is < 1.0 for 70 | * non-perpendicular unit-length vectors; so normalize x, y here 71 | */ 72 | 73 | mag = (float)sqrtf(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]); 74 | if (mag) { 75 | x[0] /= mag; 76 | x[1] /= mag; 77 | x[2] /= mag; 78 | } 79 | 80 | mag = (float)sqrtf(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]); 81 | if (mag) { 82 | y[0] /= mag; 83 | y[1] /= mag; 84 | y[2] /= mag; 85 | } 86 | 87 | #define M(row,col) m[col*4+row] 88 | M(0, 0) = x[0]; 89 | M(0, 1) = x[1]; 90 | M(0, 2) = x[2]; 91 | M(0, 3) = 0.0f; 92 | M(1, 0) = y[0]; 93 | M(1, 1) = y[1]; 94 | M(1, 2) = y[2]; 95 | M(1, 3) = 0.0f; 96 | M(2, 0) = z[0]; 97 | M(2, 1) = z[1]; 98 | M(2, 2) = z[2]; 99 | M(2, 3) = 0.0f; 100 | M(3, 0) = 0.0f; 101 | M(3, 1) = 0.0f; 102 | M(3, 2) = 0.0f; 103 | M(3, 3) = 1.0f; 104 | #undef M 105 | 106 | glMultMatrixf(m); 107 | 108 | 109 | /* Translate Eye to Origin */ 110 | glTranslatef(-eyex, -eyey, -eyez); 111 | } 112 | 113 | #endif // __IPHONE_OS_VERSION_MAX_ALLOWED 114 | -------------------------------------------------------------------------------- /libs/cocos2d/Platforms/iOS/glu.h: -------------------------------------------------------------------------------- 1 | // 2 | // cocos2d GLU implementation 3 | // 4 | // implementation of GLU functions 5 | // 6 | #ifndef __COCOS2D_GLU_H 7 | #define __COCOS2D_GLU_H 8 | 9 | // Only compile this code on iOS. These files should NOT be included on your Mac project. 10 | // But in case they are included, it won't be compiled. 11 | #import 12 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 13 | 14 | #import 15 | 16 | /** 17 | @file 18 | cocos2d OpenGL GLU implementation 19 | */ 20 | 21 | /** OpenGL gluLookAt implementation */ 22 | void gluLookAt(float eyeX, float eyeY, float eyeZ, float lookAtX, float lookAtY, float lookAtZ, float upX, float upY, float upZ); 23 | /** OpenGL gluPerspective implementation */ 24 | void gluPerspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar); 25 | 26 | #endif // __IPHONE_OS_VERSION_MAX_ALLOWED 27 | 28 | #endif /* __COCOS2D_GLU_H */ 29 | 30 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/CCArray.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | 26 | #import "ccCArray.h" 27 | 28 | 29 | /** A faster alternative of NSArray. 30 | CCArray uses internally a c-array. 31 | @since v0.99.4 32 | */ 33 | 34 | 35 | /** @def CCARRAY_FOREACH 36 | A convience macro to iterate over a CCArray using. It is faster than the "fast enumeration" interface. 37 | @since v0.99.4 38 | */ 39 | 40 | #define CCARRAY_FOREACH(__array__, __object__) \ 41 | if (__array__ && __array__->data->num > 0) \ 42 | for(id *__arr__ = __array__->data->arr, *end = __array__->data->arr + __array__->data->num-1; \ 43 | __arr__ <= end && ((__object__ = *__arr__) != nil || true); \ 44 | __arr__++) 45 | 46 | @interface CCArray : NSObject 47 | { 48 | @public ccArray *data; 49 | } 50 | 51 | + (id) array; 52 | + (id) arrayWithCapacity:(NSUInteger)capacity; 53 | + (id) arrayWithArray:(CCArray*)otherArray; 54 | + (id) arrayWithNSArray:(NSArray*)otherArray; 55 | 56 | 57 | - (id) initWithCapacity:(NSUInteger)capacity; 58 | - (id) initWithArray:(CCArray*)otherArray; 59 | - (id) initWithNSArray:(NSArray*)otherArray; 60 | 61 | 62 | // Querying an Array 63 | 64 | - (NSUInteger) count; 65 | - (NSUInteger) capacity; 66 | - (NSUInteger) indexOfObject:(id)object; 67 | - (id) objectAtIndex:(NSUInteger)index; 68 | - (BOOL) containsObject:(id)object; 69 | - (id) randomObject; 70 | - (id) lastObject; 71 | - (NSArray*) getNSArray; 72 | 73 | 74 | // Adding Objects 75 | 76 | - (void) addObject:(id)object; 77 | - (void) addObjectsFromArray:(CCArray*)otherArray; 78 | - (void) addObjectsFromNSArray:(NSArray*)otherArray; 79 | - (void) insertObject:(id)object atIndex:(NSUInteger)index; 80 | 81 | 82 | // Removing Objects 83 | 84 | - (void) removeLastObject; 85 | - (void) removeObject:(id)object; 86 | - (void) removeObjectAtIndex:(NSUInteger)index; 87 | - (void) removeObjectsInArray:(CCArray*)otherArray; 88 | - (void) removeAllObjects; 89 | - (void) fastRemoveObject:(id)object; 90 | - (void) fastRemoveObjectAtIndex:(NSUInteger)index; 91 | 92 | 93 | // Rearranging Content 94 | 95 | - (void) exchangeObject:(id)object1 withObject:(id)object2; 96 | - (void) exchangeObjectAtIndex:(NSUInteger)index1 withObjectAtIndex:(NSUInteger)index2; 97 | - (void) reverseObjects; 98 | - (void) reduceMemoryFootprint; 99 | 100 | // Sending Messages to Elements 101 | 102 | - (void) makeObjectsPerformSelector:(SEL)aSelector; 103 | - (void) makeObjectsPerformSelector:(SEL)aSelector withObject:(id)object; 104 | 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/CCFileUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | * 25 | */ 26 | 27 | 28 | #import 29 | 30 | 31 | /** Helper class to handle file operations */ 32 | @interface CCFileUtils : NSObject 33 | { 34 | } 35 | 36 | /** Returns the fullpath of an filename. 37 | 38 | If this method is when Retina Display is enabled, then the 39 | Retina Display suffix will be appended to the file (See ccConfig.h). 40 | 41 | If the Retina Display image doesn't exist, then it will return the "non-Retina Display" image 42 | 43 | */ 44 | +(NSString*) fullPathFromRelativePath:(NSString*) relPath; 45 | @end 46 | 47 | /** loads a file into memory. 48 | the caller should release the allocated buffer. 49 | 50 | @returns the size of the allocated buffer 51 | @since v0.99.5 52 | */ 53 | NSInteger ccLoadFileIntoMemory(const char *filename, unsigned char **out); 54 | 55 | 56 | /** removes the HD suffix from a path 57 | 58 | @returns NSString * without the HD suffix 59 | @since v0.99.5 60 | */ 61 | NSString *ccRemoveHDSuffixFromFile( NSString *path ); 62 | 63 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/CCProfiling.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Stuart Carnie 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import 28 | #import 29 | 30 | @class CCProfilingTimer; 31 | 32 | @interface CCProfiler : NSObject { 33 | NSMutableArray* activeTimers; 34 | } 35 | 36 | + (CCProfiler*)sharedProfiler; 37 | + (CCProfilingTimer*)timerWithName:(NSString*)timerName andInstance:(id)instance; 38 | + (void)releaseTimer:(CCProfilingTimer*)timer; 39 | - (void)displayTimers; 40 | 41 | @end 42 | 43 | 44 | @interface CCProfilingTimer : NSObject { 45 | NSString* name; 46 | struct timeval startTime; 47 | double averageTime; 48 | } 49 | 50 | @end 51 | 52 | extern void CCProfilingBeginTimingBlock(CCProfilingTimer* timer); 53 | extern void CCProfilingEndTimingBlock(CCProfilingTimer* timer); 54 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/CCProfiling.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2010 Stuart Carnie 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #import "../ccConfig.h" 27 | 28 | #if CC_ENABLE_PROFILERS 29 | 30 | #import "CCProfiling.h" 31 | 32 | @interface CCProfilingTimer() 33 | - (id)initWithName:(NSString*)timerName andInstance:(id)instance; 34 | @end 35 | 36 | @implementation CCProfiler 37 | 38 | static CCProfiler* g_sharedProfiler; 39 | 40 | + (CCProfiler*)sharedProfiler { 41 | if (!g_sharedProfiler) 42 | g_sharedProfiler = [[CCProfiler alloc] init]; 43 | 44 | return g_sharedProfiler; 45 | } 46 | 47 | + (CCProfilingTimer*)timerWithName:(NSString*)timerName andInstance:(id)instance { 48 | CCProfiler* p = [CCProfiler sharedProfiler]; 49 | CCProfilingTimer* t = [[CCProfilingTimer alloc] initWithName:timerName andInstance:instance]; 50 | [p->activeTimers addObject:t]; 51 | [t release]; 52 | return t; 53 | } 54 | 55 | + (void)releaseTimer:(CCProfilingTimer*)timer { 56 | CCProfiler* p = [CCProfiler sharedProfiler]; 57 | [p->activeTimers removeObject:timer]; 58 | } 59 | 60 | - (id)init { 61 | if (!(self = [super init])) return nil; 62 | 63 | activeTimers = [[NSMutableArray alloc] init]; 64 | 65 | return self; 66 | } 67 | 68 | - (void)dealloc { 69 | [activeTimers release]; 70 | [super dealloc]; 71 | } 72 | 73 | - (void)displayTimers { 74 | for (id timer in activeTimers) { 75 | printf("%s\n", [[timer description] cStringUsingEncoding:[NSString defaultCStringEncoding]]); 76 | } 77 | } 78 | 79 | @end 80 | 81 | @implementation CCProfilingTimer 82 | 83 | - (id)initWithName:(NSString*)timerName andInstance:(id)instance { 84 | if (!(self = [super init])) return nil; 85 | 86 | name = [[NSString stringWithFormat:@"%@ (0x%.8x)", timerName, instance] retain]; 87 | 88 | return self; 89 | } 90 | 91 | - (void)dealloc { 92 | [name release]; 93 | [super dealloc]; 94 | } 95 | 96 | - (NSString*)description { 97 | return [NSString stringWithFormat:@"%@ : avg time, %fms", name, averageTime]; 98 | } 99 | 100 | void CCProfilingBeginTimingBlock(CCProfilingTimer* timer) { 101 | gettimeofday(&timer->startTime, NULL); 102 | } 103 | 104 | typedef unsigned int uint32; 105 | void CCProfilingEndTimingBlock(CCProfilingTimer* timer) { 106 | struct timeval currentTime; 107 | gettimeofday(¤tTime, NULL); 108 | timersub(¤tTime, &timer->startTime, ¤tTime); 109 | double duration = currentTime.tv_sec * 1000.0 + currentTime.tv_usec / 1000.0; 110 | 111 | // return in milliseconds 112 | timer->averageTime = (timer->averageTime + duration) / 2.0f; 113 | } 114 | 115 | @end 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/TGAlib.h: -------------------------------------------------------------------------------- 1 | // 2 | // TGA lib for cocos2d-iphone 3 | // 4 | // sources from: http://www.lighthouse3d.com/opengl/terrain/index.php3?tgasource 5 | // 6 | 7 | //#ifndef TGA_LIB 8 | //#define TGA_LIB 9 | 10 | /** 11 | @file 12 | TGA image support 13 | */ 14 | 15 | enum { 16 | TGA_OK, 17 | TGA_ERROR_FILE_OPEN, 18 | TGA_ERROR_READING_FILE, 19 | TGA_ERROR_INDEXED_COLOR, 20 | TGA_ERROR_MEMORY, 21 | TGA_ERROR_COMPRESSED_FILE, 22 | }; 23 | 24 | /** TGA format */ 25 | typedef struct sImageTGA { 26 | int status; 27 | unsigned char type, pixelDepth; 28 | 29 | /** map width */ 30 | short int width; 31 | 32 | /** map height */ 33 | short int height; 34 | 35 | /** raw data */ 36 | unsigned char *imageData; 37 | int flipped; 38 | } tImageTGA; 39 | 40 | /// load the image header fields. We only keep those that matter! 41 | void tgaLoadHeader(FILE *file, tImageTGA *info); 42 | 43 | /// loads the image pixels. You shouldn't call this function directly 44 | void tgaLoadImageData(FILE *file, tImageTGA *info); 45 | 46 | /// this is the function to call when we want to load an image 47 | tImageTGA * tgaLoad(const char *filename); 48 | 49 | // /converts RGB to greyscale 50 | void tgaRGBtogreyscale(tImageTGA *info); 51 | 52 | /// releases the memory used for the image 53 | void tgaDestroy(tImageTGA *info); 54 | 55 | //#endif // TGA_LIB 56 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/TransformUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Valentin Milea 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #import 27 | 28 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED 29 | #import 30 | #import 31 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) 32 | #import 33 | #import 34 | #endif 35 | 36 | void CGAffineToGL(const CGAffineTransform *t, GLfloat *m); 37 | void GLToCGAffine(const GLfloat *m, CGAffineTransform *t); 38 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/TransformUtils.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2009 Valentin Milea 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #import "TransformUtils.h" 28 | 29 | void CGAffineToGL(const CGAffineTransform *t, GLfloat *m) 30 | { 31 | // | m[0] m[4] m[8] m[12] | | m11 m21 m31 m41 | | a c 0 tx | 32 | // | m[1] m[5] m[9] m[13] | | m12 m22 m32 m42 | | b d 0 ty | 33 | // | m[2] m[6] m[10] m[14] | <=> | m13 m23 m33 m43 | <=> | 0 0 1 0 | 34 | // | m[3] m[7] m[11] m[15] | | m14 m24 m34 m44 | | 0 0 0 1 | 35 | 36 | m[2] = m[3] = m[6] = m[7] = m[8] = m[9] = m[11] = m[14] = 0.0f; 37 | m[10] = m[15] = 1.0f; 38 | m[0] = t->a; m[4] = t->c; m[12] = t->tx; 39 | m[1] = t->b; m[5] = t->d; m[13] = t->ty; 40 | } 41 | 42 | void GLToCGAffine(const GLfloat *m, CGAffineTransform *t) 43 | { 44 | t->a = m[0]; t->c = m[4]; t->tx = m[12]; 45 | t->b = m[1]; t->d = m[5]; t->ty = m[13]; 46 | } 47 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/ZipUtils.h: -------------------------------------------------------------------------------- 1 | /* cocos2d for iPhone 2 | * 3 | * http://www.cocos2d-iphone.org 4 | * 5 | * 6 | * inflateMemory_ based on zlib example code 7 | * http://www.zlib.net 8 | * 9 | * Some ideas were taken from: 10 | * http://themanaworld.org/ 11 | * from the mapreader.cpp file 12 | * 13 | */ 14 | 15 | #ifndef __CC_ZIP_UTILS_H 16 | #define __CC_ZIP_UTILS_H 17 | 18 | #import 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* XXX: pragma pack ??? */ 25 | /** @struct CCZHeader 26 | */ 27 | struct CCZHeader { 28 | uint8_t sig[4]; // signature. Should be 'CCZ!' 4 bytes 29 | uint16_t compression_type; // should 0 30 | uint16_t version; // should be 2 (although version type==1 is also supported) 31 | uint32_t reserved; // Reserverd for users. 32 | uint32_t len; // size of the uncompressed file 33 | }; 34 | 35 | enum { 36 | CCZ_COMPRESSION_ZLIB, // zlib format. 37 | CCZ_COMPRESSION_BZIP2, // bzip2 format (not supported yet) 38 | CCZ_COMPRESSION_GZIP, // gzip format (not supported yet) 39 | CCZ_COMPRESSION_NONE, // plain (not supported yet) 40 | }; 41 | 42 | /** @file 43 | * Zip helper functions 44 | */ 45 | 46 | /** 47 | * Inflates either zlib or gzip deflated memory. The inflated memory is 48 | * expected to be freed by the caller. 49 | * 50 | * It will allocate 256k for the destination buffer. If it is not enought it will multiply the previous buffer size per 2, until there is enough memory. 51 | * @returns the length of the deflated buffer 52 | * 53 | @since v0.8.1 54 | */ 55 | int ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out); 56 | 57 | /** 58 | * Inflates either zlib or gzip deflated memory. The inflated memory is 59 | * expected to be freed by the caller. 60 | * 61 | * outLenghtHint is assumed to be the needed room to allocate the inflated buffer. 62 | * 63 | * @returns the length of the deflated buffer 64 | * 65 | @since v1.0.0 66 | */ 67 | int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLenghtHint ); 68 | 69 | 70 | /** inflates a GZip file into memory 71 | * 72 | * @returns the length of the deflated buffer 73 | * 74 | * @since v0.99.5 75 | */ 76 | int ccInflateGZipFile(const char *filename, unsigned char **out); 77 | 78 | /** inflates a CCZ file into memory 79 | * 80 | * @returns the length of the deflated buffer 81 | * 82 | * @since v0.99.5 83 | */ 84 | int ccInflateCCZFile(const char *filename, unsigned char **out); 85 | 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif // __CC_ZIP_UTILS_H 92 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/base64.c: -------------------------------------------------------------------------------- 1 | /* 2 | public domain BASE64 code 3 | 4 | modified for cocos2d-iphone: http://www.cocos2d-iphone.org 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #include "base64.h" 11 | 12 | unsigned char alphabet[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 13 | 14 | int _base64Decode( unsigned char *input, unsigned int input_len, unsigned char *output, unsigned int *output_len ); 15 | 16 | int _base64Decode( unsigned char *input, unsigned int input_len, unsigned char *output, unsigned int *output_len ) 17 | { 18 | static char inalphabet[256], decoder[256]; 19 | int i, bits, c, char_count, errors = 0; 20 | unsigned int input_idx = 0; 21 | unsigned int output_idx = 0; 22 | 23 | for (i = (sizeof alphabet) - 1; i >= 0 ; i--) { 24 | inalphabet[alphabet[i]] = 1; 25 | decoder[alphabet[i]] = i; 26 | } 27 | 28 | char_count = 0; 29 | bits = 0; 30 | for( input_idx=0; input_idx < input_len ; input_idx++ ) { 31 | c = input[ input_idx ]; 32 | if (c == '=') 33 | break; 34 | if (c > 255 || ! inalphabet[c]) 35 | continue; 36 | bits += decoder[c]; 37 | char_count++; 38 | if (char_count == 4) { 39 | output[ output_idx++ ] = (bits >> 16); 40 | output[ output_idx++ ] = ((bits >> 8) & 0xff); 41 | output[ output_idx++ ] = ( bits & 0xff); 42 | bits = 0; 43 | char_count = 0; 44 | } else { 45 | bits <<= 6; 46 | } 47 | } 48 | 49 | if( c == '=' ) { 50 | switch (char_count) { 51 | case 1: 52 | fprintf(stderr, "base64Decode: encoding incomplete: at least 2 bits missing"); 53 | errors++; 54 | break; 55 | case 2: 56 | output[ output_idx++ ] = ( bits >> 10 ); 57 | break; 58 | case 3: 59 | output[ output_idx++ ] = ( bits >> 16 ); 60 | output[ output_idx++ ] = (( bits >> 8 ) & 0xff); 61 | break; 62 | } 63 | } else if ( input_idx < input_len ) { 64 | if (char_count) { 65 | fprintf(stderr, "base64 encoding incomplete: at least %d bits truncated", 66 | ((4 - char_count) * 6)); 67 | errors++; 68 | } 69 | } 70 | 71 | *output_len = output_idx; 72 | return errors; 73 | } 74 | 75 | int base64Decode(unsigned char *in, unsigned int inLength, unsigned char **out) 76 | { 77 | unsigned int outLength = 0; 78 | 79 | //should be enough to store 6-bit buffers in 8-bit buffers 80 | *out = malloc( inLength * 3.0f / 4.0f + 1 ); 81 | if( *out ) { 82 | int ret = _base64Decode(in, inLength, *out, &outLength); 83 | 84 | if (ret > 0 ) 85 | { 86 | printf("Base64Utils: error decoding"); 87 | free(*out); 88 | *out = NULL; 89 | outLength = 0; 90 | } 91 | } 92 | return outLength; 93 | } 94 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | public domain BASE64 code 3 | 4 | modified for cocos2d-iphone: http://www.cocos2d-iphone.org 5 | */ 6 | 7 | #ifndef __CC_BASE64_DECODE_H 8 | #define __CC_BASE64_DECODE_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | /** @file 16 | base64 helper functions 17 | */ 18 | 19 | /** 20 | * Decodes a 64base encoded memory. The decoded memory is 21 | * expected to be freed by the caller. 22 | * 23 | * @returns the length of the out buffer 24 | * 25 | @since v0.8.1 26 | */ 27 | int base64Decode(unsigned char *in, unsigned int inLength, unsigned char **out); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // __CC_BASE64_DECODE_H 34 | -------------------------------------------------------------------------------- /libs/cocos2d/Support/ccUtils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | */ 5 | 6 | /* 7 | ccNextPOT function is licensed under the same license that is used in CCTexture2D.m. 8 | */ 9 | #include "ccUtils.h" 10 | 11 | unsigned long ccNextPOT(unsigned long x) 12 | { 13 | x = x - 1; 14 | x = x | (x >> 1); 15 | x = x | (x >> 2); 16 | x = x | (x >> 4); 17 | x = x | (x >> 8); 18 | x = x | (x >>16); 19 | return x + 1; 20 | } -------------------------------------------------------------------------------- /libs/cocos2d/Support/ccUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | */ 5 | 6 | #ifndef __CC_UTILS_H 7 | #define __CC_UTILS_H 8 | 9 | /** @file ccUtils.h 10 | Misc free functions 11 | */ 12 | 13 | /* 14 | ccNextPOT function is licensed under the same license that is used in CCTexture2D.m. 15 | */ 16 | 17 | /** returns the Next Power of Two value. 18 | 19 | Examples: 20 | - If "value" is 15, it will return 16. 21 | - If "value" is 16, it will return 16. 22 | - If "value" is 17, it will return 32. 23 | 24 | @since v0.99.5 25 | */ 26 | 27 | unsigned long ccNextPOT( unsigned long value ); 28 | 29 | #endif // ! __CC_UTILS_H 30 | -------------------------------------------------------------------------------- /libs/cocos2d/cocos2d.m: -------------------------------------------------------------------------------- 1 | /* 2 | * cocos2d for iPhone: http://www.cocos2d-iphone.org 3 | * 4 | * Copyright (c) 2008-2010 Ricardo Quesada 5 | * Copyright (c) 2011 Zynga Inc. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | 27 | #import 28 | #import "cocos2d.h" 29 | static NSString *version = @"cocos2d v1.0.1"; 30 | 31 | NSString *cocos2dVersion() 32 | { 33 | return version; 34 | } 35 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // iAdsTest 4 | // 5 | // Created by Jose Andrade on 2/1/11. 6 | // Copyright Jose Andrade 2011. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | NSAutoreleasePool *pool = [NSAutoreleasePool new]; 13 | int retVal = UIApplicationMain(argc, argv, nil, @"iAdsTestAppDelegate"); 14 | [pool release]; 15 | return retVal; 16 | } 17 | --------------------------------------------------------------------------------