diff options
| author | Starla Insigna <starla4444@gmail.com> | 2011-08-12 09:51:50 -0400 |
|---|---|---|
| committer | Starla Insigna <starla4444@gmail.com> | 2011-08-12 09:51:50 -0400 |
| commit | d19677f9f73d8fe7436982bdf8d40f69d69d1b43 (patch) | |
| tree | 74853f369ef51bc9f9f595ff31153ce1a718e651 | |
| parent | 07f40d804de35d1cead13217c448811e774e6e67 (diff) | |
| download | cartcollect-d19677f9f73d8fe7436982bdf8d40f69d69d1b43.tar.gz cartcollect-d19677f9f73d8fe7436982bdf8d40f69d69d1b43.tar.bz2 cartcollect-d19677f9f73d8fe7436982bdf8d40f69d69d1b43.zip | |
Added tutorial mode
GameLayer was also renamed to ClassicGameMode and its pause functionality and score/lives counters were moved out to GameMode. FallingObjectDelegate was created to allow for custom code to be run when items were caught/missed, something that is used extensively by tutorial mode. Important: Cart Collect's bundle identifier was changed in this revision from com.fourisland.Cart-Collect to com.apatheticink.Cart-Collect, so ensure that before attempting to compile/run this build, you clear your build directory and remove the old version of Cart Collect from your device. Closes #193
| -rwxr-xr-x | Cart Collect.xcodeproj/project.pbxproj | 40 | ||||
| -rw-r--r-- | Classes/Cart.h | 2 | ||||
| -rw-r--r-- | Classes/Cart.m | 10 | ||||
| -rwxr-xr-x | Classes/Cart_CollectAppDelegate.m | 4 | ||||
| -rwxr-xr-x | Classes/ClassicGameMode.h | 20 | ||||
| -rwxr-xr-x | Classes/ClassicGameMode.m | 166 | ||||
| -rwxr-xr-x | Classes/FallingObject.h | 3 | ||||
| -rwxr-xr-x | Classes/FallingObject.m | 25 | ||||
| -rw-r--r-- | Classes/FallingObjectDelegate.h | 20 | ||||
| -rwxr-xr-x | Classes/GameLayer.h | 31 | ||||
| -rwxr-xr-x | Classes/GameLayer.m | 284 | ||||
| -rw-r--r-- | Classes/GameMode.h | 19 | ||||
| -rw-r--r-- | Classes/GameMode.m | 112 | ||||
| -rwxr-xr-x | Classes/MainMenuLayer.m | 12 | ||||
| -rw-r--r-- | Classes/TutorialBubble.m | 13 | ||||
| -rw-r--r-- | Classes/TutorialMode.h | 26 | ||||
| -rw-r--r-- | Classes/TutorialMode.m | 349 | ||||
| -rwxr-xr-x | Resources/Info.plist | 4 | ||||
| -rw-r--r-- | Resources/skiptutorial.png | bin | 0 -> 2871 bytes | |||
| -rw-r--r-- | Resources/skiptutorial2.png | bin | 0 -> 3193 bytes |
20 files changed, 792 insertions, 348 deletions
| diff --git a/Cart Collect.xcodeproj/project.pbxproj b/Cart Collect.xcodeproj/project.pbxproj index a7baa89..ebc6afe 100755 --- a/Cart Collect.xcodeproj/project.pbxproj +++ b/Cart Collect.xcodeproj/project.pbxproj | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F83955213D739B10059AEE8 /* MainMenuLayer.m */; }; | 43 | 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F83955213D739B10059AEE8 /* MainMenuLayer.m */; }; |
| 44 | 3F8395B813D744420059AEE8 /* cartdata.sqlite3 in Resources */ = {isa = PBXBuildFile; fileRef = 3F8395B713D744420059AEE8 /* cartdata.sqlite3 */; }; | 44 | 3F8395B813D744420059AEE8 /* cartdata.sqlite3 in Resources */ = {isa = PBXBuildFile; fileRef = 3F8395B713D744420059AEE8 /* cartdata.sqlite3 */; }; |
| 45 | 3F8395D113D746200059AEE8 /* libsqlite3.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F8395D013D746200059AEE8 /* libsqlite3.0.dylib */; }; | 45 | 3F8395D113D746200059AEE8 /* libsqlite3.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F8395D013D746200059AEE8 /* libsqlite3.0.dylib */; }; |
| 46 | 3FE79CD413D4DE37001A6B93 /* GameLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FE79CD313D4DE37001A6B93 /* GameLayer.m */; }; | 46 | 3FE79CD413D4DE37001A6B93 /* ClassicGameMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 3FE79CD313D4DE37001A6B93 /* ClassicGameMode.m */; }; |
| 47 | 504DFC4810AF1557006D82FE /* CLScoreServerPost.h in Headers */ = {isa = PBXBuildFile; fileRef = 504DFC4210AF1557006D82FE /* CLScoreServerPost.h */; }; | 47 | 504DFC4810AF1557006D82FE /* CLScoreServerPost.h in Headers */ = {isa = PBXBuildFile; fileRef = 504DFC4210AF1557006D82FE /* CLScoreServerPost.h */; }; |
| 48 | 504DFC4910AF1557006D82FE /* CLScoreServerPost.m in Sources */ = {isa = PBXBuildFile; fileRef = 504DFC4310AF1557006D82FE /* CLScoreServerPost.m */; }; | 48 | 504DFC4910AF1557006D82FE /* CLScoreServerPost.m in Sources */ = {isa = PBXBuildFile; fileRef = 504DFC4310AF1557006D82FE /* CLScoreServerPost.m */; }; |
| 49 | 504DFC4A10AF1557006D82FE /* CLScoreServerRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 504DFC4410AF1557006D82FE /* CLScoreServerRequest.h */; }; | 49 | 504DFC4A10AF1557006D82FE /* CLScoreServerRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 504DFC4410AF1557006D82FE /* CLScoreServerRequest.h */; }; |
| @@ -91,6 +91,9 @@ | |||
| 91 | 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C29041113EAEC8A0032DA0F /* framestuff.png */; }; | 91 | 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C29041113EAEC8A0032DA0F /* framestuff.png */; }; |
| 92 | 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C5179C513DF3839006F1F38 /* Morning1.png */; }; | 92 | 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C5179C513DF3839006F1F38 /* Morning1.png */; }; |
| 93 | 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */; }; | 93 | 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */; }; |
| 94 | 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CC89DDE13F31413003704F7 /* TutorialMode.m */; }; | ||
| 95 | 6CF29FF013F5580400C83428 /* skiptutorial.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CF29FEE13F5580400C83428 /* skiptutorial.png */; }; | ||
| 96 | 6CF29FF113F5580400C83428 /* skiptutorial2.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CF29FEF13F5580400C83428 /* skiptutorial2.png */; }; | ||
| 94 | DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; }; | 97 | DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; }; |
| 95 | DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; }; | 98 | DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; }; |
| 96 | DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; }; | 99 | DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; }; |
| @@ -338,8 +341,8 @@ | |||
| 338 | 3F83955213D739B10059AEE8 /* MainMenuLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainMenuLayer.m; sourceTree = "<group>"; }; | 341 | 3F83955213D739B10059AEE8 /* MainMenuLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainMenuLayer.m; sourceTree = "<group>"; }; |
| 339 | 3F8395B713D744420059AEE8 /* cartdata.sqlite3 */ = {isa = PBXFileReference; lastKnownFileType = file; path = cartdata.sqlite3; sourceTree = "<group>"; }; | 342 | 3F8395B713D744420059AEE8 /* cartdata.sqlite3 */ = {isa = PBXFileReference; lastKnownFileType = file; path = cartdata.sqlite3; sourceTree = "<group>"; }; |
| 340 | 3F8395D013D746200059AEE8 /* libsqlite3.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.0.dylib; path = usr/lib/libsqlite3.0.dylib; sourceTree = SDKROOT; }; | 343 | 3F8395D013D746200059AEE8 /* libsqlite3.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.0.dylib; path = usr/lib/libsqlite3.0.dylib; sourceTree = SDKROOT; }; |
| 341 | 3FE79CD213D4DE37001A6B93 /* GameLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameLayer.h; sourceTree = "<group>"; }; | 344 | 3FE79CD213D4DE37001A6B93 /* ClassicGameMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassicGameMode.h; sourceTree = "<group>"; }; |
| 342 | 3FE79CD313D4DE37001A6B93 /* GameLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameLayer.m; sourceTree = "<group>"; }; | 345 | 3FE79CD313D4DE37001A6B93 /* ClassicGameMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClassicGameMode.m; sourceTree = "<group>"; }; |
| 343 | 504DFC4210AF1557006D82FE /* CLScoreServerPost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLScoreServerPost.h; sourceTree = "<group>"; }; | 346 | 504DFC4210AF1557006D82FE /* CLScoreServerPost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLScoreServerPost.h; sourceTree = "<group>"; }; |
| 344 | 504DFC4310AF1557006D82FE /* CLScoreServerPost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLScoreServerPost.m; sourceTree = "<group>"; }; | 347 | 504DFC4310AF1557006D82FE /* CLScoreServerPost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CLScoreServerPost.m; sourceTree = "<group>"; }; |
| 345 | 504DFC4410AF1557006D82FE /* CLScoreServerRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLScoreServerRequest.h; sourceTree = "<group>"; }; | 348 | 504DFC4410AF1557006D82FE /* CLScoreServerRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CLScoreServerRequest.h; sourceTree = "<group>"; }; |
| @@ -387,6 +390,11 @@ | |||
| 387 | 6C29041113EAEC8A0032DA0F /* framestuff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = framestuff.png; sourceTree = "<group>"; }; | 390 | 6C29041113EAEC8A0032DA0F /* framestuff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = framestuff.png; sourceTree = "<group>"; }; |
| 388 | 6C5179C513DF3839006F1F38 /* Morning1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Morning1.png; sourceTree = "<group>"; }; | 391 | 6C5179C513DF3839006F1F38 /* Morning1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Morning1.png; sourceTree = "<group>"; }; |
| 389 | 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = "<group>"; }; | 392 | 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = "<group>"; }; |
| 393 | 6CC89DDD13F31413003704F7 /* TutorialMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TutorialMode.h; sourceTree = "<group>"; }; | ||
| 394 | 6CC89DDE13F31413003704F7 /* TutorialMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TutorialMode.m; sourceTree = "<group>"; }; | ||
| 395 | 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectDelegate.h; sourceTree = "<group>"; }; | ||
| 396 | 6CF29FEE13F5580400C83428 /* skiptutorial.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = skiptutorial.png; sourceTree = "<group>"; }; | ||
| 397 | 6CF29FEF13F5580400C83428 /* skiptutorial2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = skiptutorial2.png; sourceTree = "<group>"; }; | ||
| 390 | DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; | 398 | DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; |
| 391 | DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; | 399 | DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; |
| 392 | DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; | 400 | DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; |
| @@ -736,6 +744,8 @@ | |||
| 736 | 3F7D0EC713D8E6B000B6CE14 /* Buttons */ = { | 744 | 3F7D0EC713D8E6B000B6CE14 /* Buttons */ = { |
| 737 | isa = PBXGroup; | 745 | isa = PBXGroup; |
| 738 | children = ( | 746 | children = ( |
| 747 | 6CF29FEE13F5580400C83428 /* skiptutorial.png */, | ||
| 748 | 6CF29FEF13F5580400C83428 /* skiptutorial2.png */, | ||
| 739 | 3F7D0F4813D8F17C00B6CE14 /* highscores.png */, | 749 | 3F7D0F4813D8F17C00B6CE14 /* highscores.png */, |
| 740 | 3F7D0F4913D8F17C00B6CE14 /* highscores2.png */, | 750 | 3F7D0F4913D8F17C00B6CE14 /* highscores2.png */, |
| 741 | 3F7D0F4A13D8F17C00B6CE14 /* newgame.png */, | 751 | 3F7D0F4A13D8F17C00B6CE14 /* newgame.png */, |
| @@ -836,8 +846,10 @@ | |||
| 836 | children = ( | 846 | children = ( |
| 837 | 6C0C141213F20E98003A31B2 /* GameMode.h */, | 847 | 6C0C141213F20E98003A31B2 /* GameMode.h */, |
| 838 | 6C0C141313F20E98003A31B2 /* GameMode.m */, | 848 | 6C0C141313F20E98003A31B2 /* GameMode.m */, |
| 839 | 3FE79CD213D4DE37001A6B93 /* GameLayer.h */, | 849 | 3FE79CD213D4DE37001A6B93 /* ClassicGameMode.h */, |
| 840 | 3FE79CD313D4DE37001A6B93 /* GameLayer.m */, | 850 | 3FE79CD313D4DE37001A6B93 /* ClassicGameMode.m */, |
| 851 | 6CC89DDD13F31413003704F7 /* TutorialMode.h */, | ||
| 852 | 6CC89DDE13F31413003704F7 /* TutorialMode.m */, | ||
| 841 | ); | 853 | ); |
| 842 | name = "Game Modes"; | 854 | name = "Game Modes"; |
| 843 | sourceTree = "<group>"; | 855 | sourceTree = "<group>"; |
| @@ -859,6 +871,7 @@ | |||
| 859 | 6C0C140D13F1C3EC003A31B2 /* ValuableObject.m */, | 871 | 6C0C140D13F1C3EC003A31B2 /* ValuableObject.m */, |
| 860 | 6C0C140F13F2099B003A31B2 /* Cart.h */, | 872 | 6C0C140F13F2099B003A31B2 /* Cart.h */, |
| 861 | 6C0C141013F2099B003A31B2 /* Cart.m */, | 873 | 6C0C141013F2099B003A31B2 /* Cart.m */, |
| 874 | 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */, | ||
| 862 | ); | 875 | ); |
| 863 | name = Items; | 876 | name = Items; |
| 864 | sourceTree = "<group>"; | 877 | sourceTree = "<group>"; |
| @@ -1325,6 +1338,8 @@ | |||
| 1325 | 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */, | 1338 | 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */, |
| 1326 | 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */, | 1339 | 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */, |
| 1327 | 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */, | 1340 | 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */, |
| 1341 | 6CF29FF013F5580400C83428 /* skiptutorial.png in Resources */, | ||
| 1342 | 6CF29FF113F5580400C83428 /* skiptutorial2.png in Resources */, | ||
| 1328 | ); | 1343 | ); |
| 1329 | runOnlyForDeploymentPostprocessing = 0; | 1344 | runOnlyForDeploymentPostprocessing = 0; |
| 1330 | }; | 1345 | }; |
| @@ -1338,7 +1353,7 @@ | |||
| 1338 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, | 1353 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, |
| 1339 | 507022A4107672FA00393637 /* Cart_CollectAppDelegate.m in Sources */, | 1354 | 507022A4107672FA00393637 /* Cart_CollectAppDelegate.m in Sources */, |
| 1340 | E0F81038120A173C005866B8 /* RootViewController.m in Sources */, | 1355 | E0F81038120A173C005866B8 /* RootViewController.m in Sources */, |
| 1341 | 3FE79CD413D4DE37001A6B93 /* GameLayer.m in Sources */, | 1356 | 3FE79CD413D4DE37001A6B93 /* ClassicGameMode.m in Sources */, |
| 1342 | 3F6C7C4F13D5E1B600C038FE /* FallingObject.m in Sources */, | 1357 | 3F6C7C4F13D5E1B600C038FE /* FallingObject.m in Sources */, |
| 1343 | 3F6C7C6D13D5E51800C038FE /* Cherry.m in Sources */, | 1358 | 3F6C7C6D13D5E51800C038FE /* Cherry.m in Sources */, |
| 1344 | 3F6C7C7013D5E54E00C038FE /* Bottle.m in Sources */, | 1359 | 3F6C7C7013D5E54E00C038FE /* Bottle.m in Sources */, |
| @@ -1352,6 +1367,7 @@ | |||
| 1352 | 6C0C140E13F1C3EC003A31B2 /* ValuableObject.m in Sources */, | 1367 | 6C0C140E13F1C3EC003A31B2 /* ValuableObject.m in Sources */, |
| 1353 | 6C0C141113F2099B003A31B2 /* Cart.m in Sources */, | 1368 | 6C0C141113F2099B003A31B2 /* Cart.m in Sources */, |
| 1354 | 6C0C141413F20E98003A31B2 /* GameMode.m in Sources */, | 1369 | 6C0C141413F20E98003A31B2 /* GameMode.m in Sources */, |
| 1370 | 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */, | ||
| 1355 | ); | 1371 | ); |
| 1356 | runOnlyForDeploymentPostprocessing = 0; | 1372 | runOnlyForDeploymentPostprocessing = 0; |
| 1357 | }; | 1373 | }; |
| @@ -1487,8 +1503,8 @@ | |||
| 1487 | "-ObjC", | 1503 | "-ObjC", |
| 1488 | ); | 1504 | ); |
| 1489 | PRODUCT_NAME = "Cart Collect"; | 1505 | PRODUCT_NAME = "Cart Collect"; |
| 1490 | PROVISIONING_PROFILE = "D4BA5E2C-C75B-4F36-A5F6-AF4A3C6072A5"; | 1506 | PROVISIONING_PROFILE = "42DE7CBA-2166-4560-9EE8-5D227F4278B1"; |
| 1491 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = "D4BA5E2C-C75B-4F36-A5F6-AF4A3C6072A5"; | 1507 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = "42DE7CBA-2166-4560-9EE8-5D227F4278B1"; |
| 1492 | TARGETED_DEVICE_FAMILY = 1; | 1508 | TARGETED_DEVICE_FAMILY = 1; |
| 1493 | WARNING_CFLAGS = "-Wall"; | 1509 | WARNING_CFLAGS = "-Wall"; |
| 1494 | }; | 1510 | }; |
| @@ -1513,8 +1529,8 @@ | |||
| 1513 | "-ObjC", | 1529 | "-ObjC", |
| 1514 | ); | 1530 | ); |
| 1515 | PRODUCT_NAME = "Cart Collect"; | 1531 | PRODUCT_NAME = "Cart Collect"; |
| 1516 | PROVISIONING_PROFILE = "D4BA5E2C-C75B-4F36-A5F6-AF4A3C6072A5"; | 1532 | PROVISIONING_PROFILE = "42DE7CBA-2166-4560-9EE8-5D227F4278B1"; |
| 1517 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = "D4BA5E2C-C75B-4F36-A5F6-AF4A3C6072A5"; | 1533 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = "42DE7CBA-2166-4560-9EE8-5D227F4278B1"; |
| 1518 | TARGETED_DEVICE_FAMILY = 1; | 1534 | TARGETED_DEVICE_FAMILY = 1; |
| 1519 | WARNING_CFLAGS = "-Wall"; | 1535 | WARNING_CFLAGS = "-Wall"; |
| 1520 | }; | 1536 | }; |
| @@ -1597,8 +1613,8 @@ | |||
| 1597 | "-ObjC", | 1613 | "-ObjC", |
| 1598 | ); | 1614 | ); |
| 1599 | PRODUCT_NAME = "Cart Collect"; | 1615 | PRODUCT_NAME = "Cart Collect"; |
| 1600 | PROVISIONING_PROFILE = "D4BA5E2C-C75B-4F36-A5F6-AF4A3C6072A5"; | 1616 | PROVISIONING_PROFILE = "42DE7CBA-2166-4560-9EE8-5D227F4278B1"; |
| 1601 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = "D4BA5E2C-C75B-4F36-A5F6-AF4A3C6072A5"; | 1617 | "PROVISIONING_PROFILE[sdk=iphoneos*]" = "42DE7CBA-2166-4560-9EE8-5D227F4278B1"; |
| 1602 | TARGETED_DEVICE_FAMILY = 1; | 1618 | TARGETED_DEVICE_FAMILY = 1; |
| 1603 | WARNING_CFLAGS = "-Wall"; | 1619 | WARNING_CFLAGS = "-Wall"; |
| 1604 | }; | 1620 | }; |
| diff --git a/Classes/Cart.h b/Classes/Cart.h index d708d73..0ef1abf 100644 --- a/Classes/Cart.h +++ b/Classes/Cart.h | |||
| @@ -12,9 +12,11 @@ | |||
| 12 | @interface Cart : NSObject { | 12 | @interface Cart : NSObject { |
| 13 | CCSprite* sprite; | 13 | CCSprite* sprite; |
| 14 | float accelX; | 14 | float accelX; |
| 15 | BOOL immobile; | ||
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | @property (readonly) CCSprite* sprite; | 18 | @property (readonly) CCSprite* sprite; |
| 19 | @property (assign) BOOL immobile; | ||
| 18 | - (id)initWithSprite:(CCSprite*)sprite; | 20 | - (id)initWithSprite:(CCSprite*)sprite; |
| 19 | - (void)tick; | 21 | - (void)tick; |
| 20 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration; | 22 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration; |
| diff --git a/Classes/Cart.m b/Classes/Cart.m index 3046be3..45c370c 100644 --- a/Classes/Cart.m +++ b/Classes/Cart.m | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | @implementation Cart | 11 | @implementation Cart |
| 12 | 12 | ||
| 13 | @synthesize sprite; | 13 | @synthesize sprite, immobile; |
| 14 | 14 | ||
| 15 | - (id)initWithSprite:(CCSprite*)m_sprite | 15 | - (id)initWithSprite:(CCSprite*)m_sprite |
| 16 | { | 16 | { |
| @@ -19,6 +19,7 @@ | |||
| 19 | if (nil != self) | 19 | if (nil != self) |
| 20 | { | 20 | { |
| 21 | sprite = m_sprite; | 21 | sprite = m_sprite; |
| 22 | immobile = NO; | ||
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | return self; | 25 | return self; |
| @@ -26,8 +27,11 @@ | |||
| 26 | 27 | ||
| 27 | - (void)tick | 28 | - (void)tick |
| 28 | { | 29 | { |
| 29 | // Move the cart based on acceleration gathered from accelerometer | 30 | if (!immobile) |
| 30 | sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y); | 31 | { |
| 32 | // Move the cart based on acceleration gathered from accelerometer | ||
| 33 | sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y); | ||
| 34 | } | ||
| 31 | } | 35 | } |
| 32 | 36 | ||
| 33 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration | 37 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration |
| diff --git a/Classes/Cart_CollectAppDelegate.m b/Classes/Cart_CollectAppDelegate.m index 7547601..158f660 100755 --- a/Classes/Cart_CollectAppDelegate.m +++ b/Classes/Cart_CollectAppDelegate.m | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #import "Cart_CollectAppDelegate.h" | 11 | #import "Cart_CollectAppDelegate.h" |
| 12 | #import "GameConfig.h" | 12 | #import "GameConfig.h" |
| 13 | #import "GameLayer.h" | 13 | #import "GameMode.h" |
| 14 | #import "RootViewController.h" | 14 | #import "RootViewController.h" |
| 15 | #import "MainMenuLayer.h" | 15 | #import "MainMenuLayer.h" |
| 16 | 16 | ||
| @@ -141,7 +141,7 @@ | |||
| 141 | 141 | ||
| 142 | if ([[CCDirector sharedDirector] runningScene].tag == GAME_SCENE) | 142 | if ([[CCDirector sharedDirector] runningScene].tag == GAME_SCENE) |
| 143 | { | 143 | { |
| 144 | [((GameLayer*)[[[CCDirector sharedDirector] runningScene] getChildByTag:GAME_LAYER]) pause]; | 144 | [((GameMode*)[[[CCDirector sharedDirector] runningScene] getChildByTag:GAME_LAYER]) pause]; |
| 145 | } | 145 | } |
| 146 | } | 146 | } |
| 147 | 147 | ||
| diff --git a/Classes/ClassicGameMode.h b/Classes/ClassicGameMode.h new file mode 100755 index 0000000..bbce029 --- /dev/null +++ b/Classes/ClassicGameMode.h | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | // | ||
| 2 | // GameLayer.h | ||
| 3 | // Cart Collect | ||
| 4 | // | ||
| 5 | // Created by iD Student Account on 7/18/11. | ||
| 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import <Foundation/Foundation.h> | ||
| 10 | #import "cocos2d.h" | ||
| 11 | #import "GameMode.h" | ||
| 12 | |||
| 13 | @interface ClassicGameMode : GameMode { | ||
| 14 | float addSpeed; | ||
| 15 | } | ||
| 16 | |||
| 17 | - (id)init; | ||
| 18 | - (void)randomlyAddObject:(ccTime)dt; | ||
| 19 | |||
| 20 | @end | ||
| diff --git a/Classes/ClassicGameMode.m b/Classes/ClassicGameMode.m new file mode 100755 index 0000000..eb766a1 --- /dev/null +++ b/Classes/ClassicGameMode.m | |||
| @@ -0,0 +1,166 @@ | |||
| 1 | // | ||
| 2 | // GameLayer.m | ||
| 3 | // Cart Collect | ||
| 4 | // | ||
| 5 | // Created by iD Student Account on 7/18/11. | ||
| 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import "ClassicGameMode.h" | ||
| 10 | #import "FallingObject.h" | ||
| 11 | #import "Cherry.h" | ||
| 12 | #import "Bottle.h" | ||
| 13 | #import "OneUp.h" | ||
| 14 | #import "Rock.h" | ||
| 15 | #import "GameOverLayer.h" | ||
| 16 | #import "SimpleAudioEngine.h" | ||
| 17 | |||
| 18 | @implementation ClassicGameMode | ||
| 19 | |||
| 20 | - (void)tick:(ccTime)dt | ||
| 21 | { | ||
| 22 | int lastScore = score; | ||
| 23 | |||
| 24 | [super tick:dt]; | ||
| 25 | |||
| 26 | if (lives == 0) | ||
| 27 | { | ||
| 28 | [self unscheduleAllSelectors]; | ||
| 29 | |||
| 30 | [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverLayer sceneWithScore:score]]]; | ||
| 31 | } else if (score > lastScore) | ||
| 32 | { | ||
| 33 | if ((lastScore < 6500) && (score >= 6500)) | ||
| 34 | { | ||
| 35 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 36 | [self schedule:@selector(randomlyAddObject:) interval:0.6f]; | ||
| 37 | addSpeed = 0.6f; | ||
| 38 | } else if ((lastScore < 4500) && (score >= 4500)) | ||
| 39 | { | ||
| 40 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 41 | [self schedule:@selector(randomlyAddObject:) interval:0.7f]; | ||
| 42 | addSpeed = 0.7f; | ||
| 43 | } else if ((lastScore < 2500) && (score >= 2500)) | ||
| 44 | { | ||
| 45 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 46 | [self schedule:@selector(randomlyAddObject:) interval:0.8f]; | ||
| 47 | addSpeed = 0.8f; | ||
| 48 | } else if ((lastScore < 1500) && (score >= 1500)) | ||
| 49 | { | ||
| 50 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 51 | [self schedule:@selector(randomlyAddObject:) interval:0.9f]; | ||
| 52 | addSpeed = 0.9f; | ||
| 53 | } else if ((lastScore < 500) && (score >= 500)) | ||
| 54 | { | ||
| 55 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 56 | [self schedule:@selector(randomlyAddObject:) interval:1.0f]; | ||
| 57 | addSpeed = 1.0f; | ||
| 58 | } else if ((lastScore < 150) && (score >= 150)) | ||
| 59 | { | ||
| 60 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 61 | [self schedule:@selector(randomlyAddObject:) interval:2.0f]; | ||
| 62 | addSpeed = 2.0f; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | - (void)randomlyAddObject:(ccTime)dt | ||
| 68 | { | ||
| 69 | FallingObject* object; | ||
| 70 | int oneuppercent = 98 - (lives == 1 ? 1 : 0); | ||
| 71 | |||
| 72 | if (score < 1000) | ||
| 73 | { | ||
| 74 | int randomval = arc4random()%100; | ||
| 75 | |||
| 76 | if (randomval < 65) | ||
| 77 | { | ||
| 78 | object = [[Cherry alloc] init]; | ||
| 79 | } else if (randomval < oneuppercent) | ||
| 80 | { | ||
| 81 | object = [[Bottle alloc] init]; | ||
| 82 | } else { | ||
| 83 | object = [[OneUp alloc] init]; | ||
| 84 | } | ||
| 85 | } else { | ||
| 86 | int randomval = arc4random()%100; | ||
| 87 | |||
| 88 | if (randomval < 40) | ||
| 89 | { | ||
| 90 | object = [[Cherry alloc] init]; | ||
| 91 | } else if (randomval < 70) | ||
| 92 | { | ||
| 93 | object = [[Rock alloc] init]; | ||
| 94 | } else if (randomval < oneuppercent) | ||
| 95 | { | ||
| 96 | object = [[Bottle alloc] init]; | ||
| 97 | } else { | ||
| 98 | object = [[OneUp alloc] init]; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | int objectX = arc4random()%448+16; | ||
| 103 | object.sprite.position = ccp(objectX, 360); | ||
| 104 | object.sprite.scale = 1; | ||
| 105 | [self addChild:object.sprite]; | ||
| 106 | |||
| 107 | [objects addObject:object]; | ||
| 108 | [object release]; | ||
| 109 | |||
| 110 | if (score >= 2000) | ||
| 111 | { | ||
| 112 | if (arc4random() % 100 > 80) | ||
| 113 | { | ||
| 114 | object = [[Rock alloc] init]; | ||
| 115 | |||
| 116 | objectX = arc4random()%448+16; | ||
| 117 | object.sprite.position = ccp(objectX, 360); | ||
| 118 | object.sprite.scale = 1; | ||
| 119 | [self addChild:object.sprite]; | ||
| 120 | |||
| 121 | [objects addObject:object]; | ||
| 122 | [object release]; | ||
| 123 | } | ||
| 124 | } | ||
| 125 | |||
| 126 | if (score >= 4000) | ||
| 127 | { | ||
| 128 | if (arc4random() % 100 > 80) | ||
| 129 | { | ||
| 130 | object = [[Rock alloc] init]; | ||
| 131 | |||
| 132 | objectX = arc4random()%448+16; | ||
| 133 | object.sprite.position = ccp(objectX, 360); | ||
| 134 | object.sprite.scale = 1; | ||
| 135 | [self addChild:object.sprite]; | ||
| 136 | |||
| 137 | [objects addObject:object]; | ||
| 138 | [object release]; | ||
| 139 | } | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | - (id)init | ||
| 144 | { | ||
| 145 | self = [super init]; | ||
| 146 | |||
| 147 | if (nil != self) | ||
| 148 | { | ||
| 149 | CCSprite* backgroundImage = [CCSprite spriteWithFile:@"SeaBeach.png"]; | ||
| 150 | backgroundImage.position = ccp(240, 160); | ||
| 151 | [self addChild:backgroundImage z:-1]; | ||
| 152 | |||
| 153 | addSpeed = 2.5f; | ||
| 154 | } | ||
| 155 | |||
| 156 | return self; | ||
| 157 | } | ||
| 158 | |||
| 159 | - (void)onEnterTransitionDidFinish | ||
| 160 | { | ||
| 161 | [super onEnterTransitionDidFinish]; | ||
| 162 | |||
| 163 | [self schedule:@selector(randomlyAddObject:) interval:addSpeed]; | ||
| 164 | } | ||
| 165 | |||
| 166 | @end | ||
| diff --git a/Classes/FallingObject.h b/Classes/FallingObject.h index 0bda787..3e28903 100755 --- a/Classes/FallingObject.h +++ b/Classes/FallingObject.h | |||
| @@ -8,14 +8,17 @@ | |||
| 8 | 8 | ||
| 9 | #import <Foundation/Foundation.h> | 9 | #import <Foundation/Foundation.h> |
| 10 | #import "cocos2d.h" | 10 | #import "cocos2d.h" |
| 11 | #import "FallingObjectDelegate.h" | ||
| 11 | 12 | ||
| 12 | @interface FallingObject : NSObject { | 13 | @interface FallingObject : NSObject { |
| 13 | CCSprite* sprite; | 14 | CCSprite* sprite; |
| 14 | int weight; | 15 | int weight; |
| 16 | id<FallingObjectDelegate> delegate; | ||
| 15 | } | 17 | } |
| 16 | 18 | ||
| 17 | @property (readonly) CCSprite* sprite; | 19 | @property (readonly) CCSprite* sprite; |
| 18 | @property (readonly) int weight; | 20 | @property (readonly) int weight; |
| 21 | @property (nonatomic,retain) id<FallingObjectDelegate> delegate; | ||
| 19 | - (id)init; | 22 | - (id)init; |
| 20 | - (BOOL)tick; | 23 | - (BOOL)tick; |
| 21 | - (void)collideWithCart; | 24 | - (void)collideWithCart; |
| diff --git a/Classes/FallingObject.m b/Classes/FallingObject.m index 515948e..85ea902 100755 --- a/Classes/FallingObject.m +++ b/Classes/FallingObject.m | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | @implementation FallingObject | 12 | @implementation FallingObject |
| 13 | 13 | ||
| 14 | @synthesize sprite, weight; | 14 | @synthesize sprite, weight, delegate; |
| 15 | 15 | ||
| 16 | - (id)init | 16 | - (id)init |
| 17 | { | 17 | { |
| @@ -46,6 +46,16 @@ | |||
| 46 | { | 46 | { |
| 47 | [self collideWithCart]; | 47 | [self collideWithCart]; |
| 48 | 48 | ||
| 49 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(didCatchItem:)])) | ||
| 50 | { | ||
| 51 | [delegate didCatchItem:self]; | ||
| 52 | } | ||
| 53 | |||
| 54 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(didDestroyItem:)])) | ||
| 55 | { | ||
| 56 | [delegate didDestroyItem:self]; | ||
| 57 | } | ||
| 58 | |||
| 49 | return YES; | 59 | return YES; |
| 50 | } | 60 | } |
| 51 | } | 61 | } |
| @@ -57,6 +67,16 @@ | |||
| 57 | { | 67 | { |
| 58 | [self collideWithFloor]; | 68 | [self collideWithFloor]; |
| 59 | 69 | ||
| 70 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(didMissItem:)])) | ||
| 71 | { | ||
| 72 | [delegate didMissItem:self]; | ||
| 73 | } | ||
| 74 | |||
| 75 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(didDestroyItem:)])) | ||
| 76 | { | ||
| 77 | [delegate didDestroyItem:self]; | ||
| 78 | } | ||
| 79 | |||
| 60 | return YES; | 80 | return YES; |
| 61 | } | 81 | } |
| 62 | 82 | ||
| @@ -75,7 +95,8 @@ | |||
| 75 | 95 | ||
| 76 | - (void)dealloc | 96 | - (void)dealloc |
| 77 | { | 97 | { |
| 78 | [sprite release]; | 98 | [sprite.parent removeChild:sprite cleanup:YES]; |
| 99 | [delegate release]; | ||
| 79 | [super dealloc]; | 100 | [super dealloc]; |
| 80 | } | 101 | } |
| 81 | 102 | ||
| diff --git a/Classes/FallingObjectDelegate.h b/Classes/FallingObjectDelegate.h new file mode 100644 index 0000000..b5c03fb --- /dev/null +++ b/Classes/FallingObjectDelegate.h | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | // | ||
| 2 | // FallingObjectDelegate.h | ||
| 3 | // Cart Collect | ||
| 4 | // | ||
| 5 | // Created by Starla Insigna on 8/10/11. | ||
| 6 | // Copyright 2011 Four Island. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import <Foundation/Foundation.h> | ||
| 10 | |||
| 11 | @class FallingObject; | ||
| 12 | |||
| 13 | @protocol FallingObjectDelegate <NSObject> | ||
| 14 | |||
| 15 | @optional | ||
| 16 | - (void)didCatchItem:(FallingObject*)item; | ||
| 17 | - (void)didMissItem:(FallingObject*)item; | ||
| 18 | - (void)didDestroyItem:(FallingObject*)item; | ||
| 19 | |||
| 20 | @end | ||
| diff --git a/Classes/GameLayer.h b/Classes/GameLayer.h deleted file mode 100755 index 128cbf2..0000000 --- a/Classes/GameLayer.h +++ /dev/null | |||
| @@ -1,31 +0,0 @@ | |||
| 1 | // | ||
| 2 | // GameLayer.h | ||
| 3 | // Cart Collect | ||
| 4 | // | ||
| 5 | // Created by iD Student Account on 7/18/11. | ||
| 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import <Foundation/Foundation.h> | ||
| 10 | #import "cocos2d.h" | ||
| 11 | #import "TutorialBubble.h" | ||
| 12 | #import "GameMode.h" | ||
| 13 | |||
| 14 | @interface GameLayer : GameMode { | ||
| 15 | CCLabelBMFont* scoreLabel; | ||
| 16 | CCLabelBMFont* livesLabel; | ||
| 17 | float addSpeed; | ||
| 18 | TutorialBubble* currentTutorial; | ||
| 19 | |||
| 20 | CCLayerColor* shadedLayer; | ||
| 21 | CCLayer* pauseLayer; | ||
| 22 | } | ||
| 23 | |||
| 24 | @property (nonatomic,retain) TutorialBubble* currentTutorial; | ||
| 25 | - (id)init; | ||
| 26 | - (void)pause; | ||
| 27 | - (void)unpause; | ||
| 28 | - (void)mainmenu; | ||
| 29 | - (void)endTutorial; | ||
| 30 | |||
| 31 | @end | ||
| diff --git a/Classes/GameLayer.m b/Classes/GameLayer.m deleted file mode 100755 index 95bc83b..0000000 --- a/Classes/GameLayer.m +++ /dev/null | |||
| @@ -1,284 +0,0 @@ | |||
| 1 | // | ||
| 2 | // GameLayer.m | ||
| 3 | // Cart Collect | ||
| 4 | // | ||
| 5 | // Created by iD Student Account on 7/18/11. | ||
| 6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import "GameLayer.h" | ||
| 10 | #import "FallingObject.h" | ||
| 11 | #import "Cherry.h" | ||
| 12 | #import "Bottle.h" | ||
| 13 | #import "OneUp.h" | ||
| 14 | #import "Rock.h" | ||
| 15 | #import "GameOverLayer.h" | ||
| 16 | #import "SimpleAudioEngine.h" | ||
| 17 | #import "MainMenuLayer.h" | ||
| 18 | |||
| 19 | @implementation GameLayer | ||
| 20 | |||
| 21 | @synthesize currentTutorial; | ||
| 22 | |||
| 23 | - (void)tick:(ccTime)dt | ||
| 24 | { | ||
| 25 | int lastScore = score; | ||
| 26 | |||
| 27 | [super tick:dt]; | ||
| 28 | |||
| 29 | if (lives == 0) | ||
| 30 | { | ||
| 31 | [self unscheduleAllSelectors]; | ||
| 32 | |||
| 33 | [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverLayer sceneWithScore:score]]]; | ||
| 34 | } else if (score > lastScore) | ||
| 35 | { | ||
| 36 | if ((lastScore < 6500) && (score >= 6500)) | ||
| 37 | { | ||
| 38 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 39 | [self schedule:@selector(randomlyAddObject:) interval:0.6f]; | ||
| 40 | addSpeed = 0.6f; | ||
| 41 | } else if ((lastScore < 4500) && (score >= 4500)) | ||
| 42 | { | ||
| 43 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 44 | [self schedule:@selector(randomlyAddObject:) interval:0.7f]; | ||
| 45 | addSpeed = 0.7f; | ||
| 46 | } else if ((lastScore < 2500) && (score >= 2500)) | ||
| 47 | { | ||
| 48 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 49 | [self schedule:@selector(randomlyAddObject:) interval:0.8f]; | ||
| 50 | addSpeed = 0.8f; | ||
| 51 | } else if ((lastScore < 1500) && (score >= 1500)) | ||
| 52 | { | ||
| 53 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 54 | [self schedule:@selector(randomlyAddObject:) interval:0.9f]; | ||
| 55 | addSpeed = 0.9f; | ||
| 56 | } else if ((lastScore < 500) && (score >= 500)) | ||
| 57 | { | ||
| 58 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 59 | [self schedule:@selector(randomlyAddObject:) interval:1.0f]; | ||
| 60 | addSpeed = 1.0f; | ||
| 61 | } else if ((lastScore < 150) && (score >= 150)) | ||
| 62 | { | ||
| 63 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 64 | [self schedule:@selector(randomlyAddObject:) interval:2.0f]; | ||
| 65 | addSpeed = 2.0f; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | - (void)randomlyAddObject:(ccTime)dt | ||
| 71 | { | ||
| 72 | FallingObject* object; | ||
| 73 | int oneuppercent = 98 - (lives == 1 ? 1 : 0); | ||
| 74 | |||
| 75 | if (score < 1000) | ||
| 76 | { | ||
| 77 | int randomval = arc4random()%100; | ||
| 78 | |||
| 79 | if (randomval < 65) | ||
| 80 | { | ||
| 81 | object = [[Cherry alloc] init]; | ||
| 82 | } else if (randomval < oneuppercent) | ||
| 83 | { | ||
| 84 | object = [[Bottle alloc] init]; | ||
| 85 | } else { | ||
| 86 | object = [[OneUp alloc] init]; | ||
| 87 | } | ||
| 88 | } else { | ||
| 89 | int randomval = arc4random()%100; | ||
| 90 | |||
| 91 | if (randomval < 40) | ||
| 92 | { | ||
| 93 | object = [[Cherry alloc] init]; | ||
| 94 | } else if (randomval < 70) | ||
| 95 | { | ||
| 96 | object = [[Rock alloc] init]; | ||
| 97 | } else if (randomval < oneuppercent) | ||
| 98 | { | ||
| 99 | object = [[Bottle alloc] init]; | ||
| 100 | } else { | ||
| 101 | object = [[OneUp alloc] init]; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | int objectX = arc4random()%448+16; | ||
| 106 | object.sprite.position = ccp(objectX, 360); | ||
| 107 | object.sprite.scale = 1; | ||
| 108 | [self addChild:object.sprite]; | ||
| 109 | |||
| 110 | [objects addObject:object]; | ||
| 111 | [object release]; | ||
| 112 | |||
| 113 | if (score >= 2000) | ||
| 114 | { | ||
| 115 | if (arc4random() % 100 > 80) | ||
| 116 | { | ||
| 117 | object = [[Rock alloc] init]; | ||
| 118 | |||
| 119 | objectX = arc4random()%448+16; | ||
| 120 | object.sprite.position = ccp(objectX, 360); | ||
| 121 | object.sprite.scale = 1; | ||
| 122 | [self addChild:object.sprite]; | ||
| 123 | |||
| 124 | [objects addObject:object]; | ||
| 125 | [object release]; | ||
| 126 | } | ||
| 127 | } | ||
| 128 | |||
| 129 | if (score >= 4000) | ||
| 130 | { | ||
| 131 | if (arc4random() % 100 > 80) | ||
| 132 | { | ||
| 133 | object = [[Rock alloc] init]; | ||
| 134 | |||
| 135 | objectX = arc4random()%448+16; | ||
| 136 | object.sprite.position = ccp(objectX, 360); | ||
| 137 | object.sprite.scale = 1; | ||
| 138 | [self addChild:object.sprite]; | ||
| 139 | |||
| 140 | [objects addObject:object]; | ||
| 141 | [object release]; | ||
| 142 | } | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 146 | - (id)init | ||
| 147 | { | ||
| 148 | self = [super init]; | ||
| 149 | |||
| 150 | int winWidth = [CCDirector sharedDirector].winSize.width; | ||
| 151 | //int winHeight = [CCDirector sharedDirector].winSize.height; | ||
| 152 | int cartScale = 2; | ||
| 153 | |||
| 154 | if (self != nil) | ||
| 155 | { | ||
| 156 | CCSprite* backgroundImage = [CCSprite spriteWithFile:@"SeaBeach.png"]; | ||
| 157 | backgroundImage.position = ccp(240, 160); | ||
| 158 | [self addChild:backgroundImage z:0]; | ||
| 159 | |||
| 160 | cart = [[Cart alloc] initWithSprite:[CCSprite spriteWithFile:@"cart.png"]]; | ||
| 161 | cart.sprite.position = ccp(winWidth/2, 22); | ||
| 162 | cart.sprite.scale = cartScale; | ||
| 163 | [self addChild:cart.sprite]; | ||
| 164 | |||
| 165 | scoreLabel = [CCLabelBMFont labelWithString:@"Score: 0" fntFile:@"helvetica2.fnt"]; | ||
| 166 | scoreLabel.position = ccp(50, 300); | ||
| 167 | [self addChild:scoreLabel]; | ||
| 168 | |||
| 169 | livesLabel = [CCLabelBMFont labelWithString:@"Lives: 3" fntFile:@"helvetica2.fnt"]; | ||
| 170 | livesLabel.position = ccp(50, 280); | ||
| 171 | [self addChild:livesLabel]; | ||
| 172 | |||
| 173 | score = 0; | ||
| 174 | lives = 3; | ||
| 175 | |||
| 176 | CCMenuItemImage* pauseButton = [CCMenuItemImage itemFromNormalImage:@"pause2.png" selectedImage:@"pause.png" target:self selector:@selector(pause)]; | ||
| 177 | CCMenu* pauseMenu = [CCMenu menuWithItems:pauseButton, nil]; | ||
| 178 | [pauseMenu setPosition:ccp(480-8-16, 320-8-16)]; | ||
| 179 | [self addChild:pauseMenu]; | ||
| 180 | |||
| 181 | addSpeed = 2.5f; | ||
| 182 | } | ||
| 183 | |||
| 184 | return self; | ||
| 185 | } | ||
| 186 | |||
| 187 | - (void)onEnter | ||
| 188 | { | ||
| 189 | [super onEnter]; | ||
| 190 | |||
| 191 | [self schedule:@selector(randomlyAddObject:) interval:addSpeed]; | ||
| 192 | } | ||
| 193 | |||
| 194 | - (void)setScore:(int)m_score | ||
| 195 | { | ||
| 196 | score = m_score; | ||
| 197 | |||
| 198 | [scoreLabel setString:[NSString stringWithFormat:@"Score: %d", score]]; | ||
| 199 | } | ||
| 200 | |||
| 201 | - (void)setLives:(int)m_lives | ||
| 202 | { | ||
| 203 | lives = m_lives; | ||
| 204 | |||
| 205 | [livesLabel setString:[NSString stringWithFormat:@"Lives: %d", lives]]; | ||
| 206 | } | ||
| 207 | |||
| 208 | - (void)pause | ||
| 209 | { | ||
| 210 | if (self.currentTutorial != nil) | ||
| 211 | { | ||
| 212 | [self.currentTutorial removeFromSuperview]; | ||
| 213 | } | ||
| 214 | |||
| 215 | [self pauseSchedulerAndActions]; | ||
| 216 | |||
| 217 | shadedLayer = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)]; | ||
| 218 | [[[CCDirector sharedDirector] runningScene] addChild:shadedLayer]; | ||
| 219 | |||
| 220 | pauseLayer = [CCLayer node]; | ||
| 221 | CCLabelBMFont* scoreLabel2 = [CCLabelBMFont labelWithString:@"PAUSE" fntFile:@"helvetica.fnt"]; | ||
| 222 | scoreLabel2.position = ccp(240,90); | ||
| 223 | [pauseLayer addChild:scoreLabel2]; | ||
| 224 | |||
| 225 | CCMenuItemImage* pauseButton = [CCMenuItemImage itemFromNormalImage:@"pause2.png" selectedImage:@"pause.png" target:self selector:@selector(unpause)]; | ||
| 226 | CCMenu* pauseMenu = [CCMenu menuWithItems:pauseButton, nil]; | ||
| 227 | [pauseMenu setPosition:ccp(480-8-16, 320-8-16)]; | ||
| 228 | [pauseLayer addChild:pauseMenu]; | ||
| 229 | |||
| 230 | CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(mainmenu)]; | ||
| 231 | CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil]; | ||
| 232 | myMenu.position = ccp(240, 60); | ||
| 233 | [pauseLayer addChild:myMenu]; | ||
| 234 | |||
| 235 | [[[CCDirector sharedDirector] runningScene] addChild:pauseLayer]; | ||
| 236 | } | ||
| 237 | |||
| 238 | - (void)unpause | ||
| 239 | { | ||
| 240 | [[[CCDirector sharedDirector] runningScene] removeChild:shadedLayer cleanup:YES]; | ||
| 241 | [[[CCDirector sharedDirector] runningScene] removeChild:pauseLayer cleanup:YES]; | ||
| 242 | |||
| 243 | shadedLayer = nil; | ||
| 244 | pauseLayer = nil; | ||
| 245 | |||
| 246 | if (self.currentTutorial != nil) | ||
| 247 | { | ||
| 248 | [[[CCDirector sharedDirector] openGLView] addSubview:self.currentTutorial]; | ||
| 249 | } else { | ||
| 250 | [self resumeSchedulerAndActions]; | ||
| 251 | } | ||
| 252 | } | ||
| 253 | |||
| 254 | - (void)mainmenu | ||
| 255 | { | ||
| 256 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; | ||
| 257 | } | ||
| 258 | |||
| 259 | - (void)setCurrentTutorial:(TutorialBubble *)m_currentTutorial | ||
| 260 | { | ||
| 261 | @synchronized(self) | ||
| 262 | { | ||
| 263 | if (currentTutorial != m_currentTutorial) | ||
| 264 | { | ||
| 265 | [currentTutorial release]; | ||
| 266 | currentTutorial = [m_currentTutorial retain]; | ||
| 267 | } | ||
| 268 | } | ||
| 269 | |||
| 270 | if (currentTutorial != nil) | ||
| 271 | { | ||
| 272 | [currentTutorial setTarget:self action:@selector(endTutorial)]; | ||
| 273 | [[[CCDirector sharedDirector] openGLView] addSubview:currentTutorial]; | ||
| 274 | [self pauseSchedulerAndActions]; | ||
| 275 | } | ||
| 276 | } | ||
| 277 | |||
| 278 | - (void)endTutorial | ||
| 279 | { | ||
| 280 | self.currentTutorial = nil; | ||
| 281 | [self resumeSchedulerAndActions]; | ||
| 282 | } | ||
| 283 | |||
| 284 | @end | ||
| diff --git a/Classes/GameMode.h b/Classes/GameMode.h index bd47c90..370550c 100644 --- a/Classes/GameMode.h +++ b/Classes/GameMode.h | |||
| @@ -17,11 +17,26 @@ | |||
| 17 | int score; | 17 | int score; |
| 18 | int lives; | 18 | int lives; |
| 19 | Cart* cart; | 19 | Cart* cart; |
| 20 | |||
| 21 | CCLayerColor* shadedLayer; | ||
| 22 | CCLayer* pauseLayer; | ||
| 23 | |||
| 24 | CCLabelBMFont* scoreLabel; | ||
| 25 | CCLabelBMFont* livesLabel; | ||
| 26 | |||
| 27 | void (^delayedAction)(void); | ||
| 20 | } | 28 | } |
| 21 | 29 | ||
| 22 | @property (readonly) Cart* cart; | 30 | @property (readonly) Cart* cart; |
| 23 | @property (assign) int score; | 31 | @property (nonatomic,assign) int score; |
| 24 | @property (assign) int lives; | 32 | @property (nonatomic,assign) int lives; |
| 33 | + (CCScene*)scene; | ||
| 25 | - (void)tick:(ccTime)dt; | 34 | - (void)tick:(ccTime)dt; |
| 35 | - (BOOL)canPause; | ||
| 36 | - (void)pause; | ||
| 37 | - (void)unpause; | ||
| 38 | - (void)mainmenu; | ||
| 39 | - (void)scheduleDelayedAction:(void(^)(void))delayedAction delay:(float)delay; | ||
| 40 | - (void)runDelayedAction; | ||
| 26 | 41 | ||
| 27 | @end | 42 | @end |
| diff --git a/Classes/GameMode.m b/Classes/GameMode.m index 6fa31e5..7afbf20 100644 --- a/Classes/GameMode.m +++ b/Classes/GameMode.m | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #import "GameMode.h" | 9 | #import "GameMode.h" |
| 10 | #import "FallingObject.h" | 10 | #import "FallingObject.h" |
| 11 | #import "MainMenuLayer.h" | ||
| 11 | 12 | ||
| 12 | @implementation GameMode | 13 | @implementation GameMode |
| 13 | 14 | ||
| @@ -16,7 +17,7 @@ | |||
| 16 | + (CCScene*)scene | 17 | + (CCScene*)scene |
| 17 | { | 18 | { |
| 18 | CCScene* scene = [CCScene node]; | 19 | CCScene* scene = [CCScene node]; |
| 19 | 20 | ||
| 20 | GameMode* layer = [self node]; | 21 | GameMode* layer = [self node]; |
| 21 | layer.tag = GAME_LAYER; | 22 | layer.tag = GAME_LAYER; |
| 22 | [scene addChild:layer]; | 23 | [scene addChild:layer]; |
| @@ -35,6 +36,30 @@ | |||
| 35 | isAccelerometerEnabled_ = YES; | 36 | isAccelerometerEnabled_ = YES; |
| 36 | 37 | ||
| 37 | objects = [[NSMutableSet alloc] init]; | 38 | objects = [[NSMutableSet alloc] init]; |
| 39 | |||
| 40 | cart = [[Cart alloc] initWithSprite:[CCSprite spriteWithFile:@"cart.png"]]; | ||
| 41 | cart.sprite.position = ccp(240, 22); | ||
| 42 | cart.sprite.scale = 2; | ||
| 43 | [self addChild:cart.sprite]; | ||
| 44 | |||
| 45 | scoreLabel = [CCLabelBMFont labelWithString:@"Score: 0" fntFile:@"helvetica2.fnt"]; | ||
| 46 | scoreLabel.position = ccp(50, 300); | ||
| 47 | [self addChild:scoreLabel]; | ||
| 48 | |||
| 49 | livesLabel = [CCLabelBMFont labelWithString:@"Lives: 3" fntFile:@"helvetica2.fnt"]; | ||
| 50 | livesLabel.position = ccp(50, 280); | ||
| 51 | [self addChild:livesLabel]; | ||
| 52 | |||
| 53 | score = 0; | ||
| 54 | lives = 3; | ||
| 55 | |||
| 56 | if ([self canPause]) | ||
| 57 | { | ||
| 58 | CCMenuItemImage* pauseButton = [CCMenuItemImage itemFromNormalImage:@"pause2.png" selectedImage:@"pause.png" target:self selector:@selector(pause)]; | ||
| 59 | CCMenu* pauseMenu = [CCMenu menuWithItems:pauseButton, nil]; | ||
| 60 | [pauseMenu setPosition:ccp(480-8-16, 320-8-16)]; | ||
| 61 | [self addChild:pauseMenu]; | ||
| 62 | } | ||
| 38 | } | 63 | } |
| 39 | 64 | ||
| 40 | return self; | 65 | return self; |
| @@ -45,9 +70,9 @@ | |||
| 45 | [cart accelerometer:accelerometer didAccelerate:acceleration]; | 70 | [cart accelerometer:accelerometer didAccelerate:acceleration]; |
| 46 | } | 71 | } |
| 47 | 72 | ||
| 48 | - (void)onEnter | 73 | - (void)onEnterTransitionDidFinish |
| 49 | { | 74 | { |
| 50 | [super onEnter]; | 75 | [super onEnterTransitionDidFinish]; |
| 51 | 76 | ||
| 52 | [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 60)]; | 77 | [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 60)]; |
| 53 | [self schedule:@selector(tick:) interval:1.0f/60.0f]; | 78 | [self schedule:@selector(tick:) interval:1.0f/60.0f]; |
| @@ -61,13 +86,90 @@ | |||
| 61 | { | 86 | { |
| 62 | if ([object tick]) | 87 | if ([object tick]) |
| 63 | { | 88 | { |
| 64 | [object retain]; | ||
| 65 | [self removeChild:object.sprite cleanup:YES]; | ||
| 66 | [objects removeObject:object]; | 89 | [objects removeObject:object]; |
| 67 | } | 90 | } |
| 68 | } | 91 | } |
| 69 | } | 92 | } |
| 70 | 93 | ||
| 94 | - (BOOL)canPause | ||
| 95 | { | ||
| 96 | return YES; | ||
| 97 | } | ||
| 98 | |||
| 99 | - (void)pause | ||
| 100 | { | ||
| 101 | if ([self canPause]) | ||
| 102 | { | ||
| 103 | [self pauseSchedulerAndActions]; | ||
| 104 | |||
| 105 | shadedLayer = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)]; | ||
| 106 | [[[CCDirector sharedDirector] runningScene] addChild:shadedLayer]; | ||
| 107 | |||
| 108 | pauseLayer = [CCLayer node]; | ||
| 109 | CCLabelBMFont* scoreLabel2 = [CCLabelBMFont labelWithString:@"PAUSE" fntFile:@"helvetica.fnt"]; | ||
| 110 | scoreLabel2.position = ccp(240,90); | ||
| 111 | [pauseLayer addChild:scoreLabel2]; | ||
| 112 | |||
| 113 | CCMenuItemImage* pauseButton = [CCMenuItemImage itemFromNormalImage:@"pause2.png" selectedImage:@"pause.png" target:self selector:@selector(unpause)]; | ||
| 114 | CCMenu* pauseMenu = [CCMenu menuWithItems:pauseButton, nil]; | ||
| 115 | [pauseMenu setPosition:ccp(480-8-16, 320-8-16)]; | ||
| 116 | [pauseLayer addChild:pauseMenu]; | ||
| 117 | |||
| 118 | CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(mainmenu)]; | ||
| 119 | CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil]; | ||
| 120 | myMenu.position = ccp(240, 60); | ||
| 121 | [pauseLayer addChild:myMenu]; | ||
| 122 | |||
| 123 | [[[CCDirector sharedDirector] runningScene] addChild:pauseLayer]; | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | - (void)unpause | ||
| 128 | { | ||
| 129 | [[[CCDirector sharedDirector] runningScene] removeChild:shadedLayer cleanup:YES]; | ||
| 130 | [[[CCDirector sharedDirector] runningScene] removeChild:pauseLayer cleanup:YES]; | ||
| 131 | |||
| 132 | shadedLayer = nil; | ||
| 133 | pauseLayer = nil; | ||
| 134 | |||
| 135 | [self resumeSchedulerAndActions]; | ||
| 136 | } | ||
| 137 | |||
| 138 | - (void)mainmenu | ||
| 139 | { | ||
| 140 | [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]]; | ||
| 141 | } | ||
| 142 | |||
| 143 | - (void)setScore:(int)m_score | ||
| 144 | { | ||
| 145 | score = m_score; | ||
| 146 | |||
| 147 | [scoreLabel setString:[NSString stringWithFormat:@"Score: %d", score]]; | ||
| 148 | } | ||
| 149 | |||
| 150 | - (void)setLives:(int)m_lives | ||
| 151 | { | ||
| 152 | lives = m_lives; | ||
| 153 | |||
| 154 | [livesLabel setString:[NSString stringWithFormat:@"Lives: %d", lives]]; | ||
| 155 | } | ||
| 156 | |||
| 157 | - (void)scheduleDelayedAction:(void(^)(void))m_delayedAction delay:(float)delay | ||
| 158 | { | ||
| 159 | delayedAction = Block_copy([m_delayedAction retain]); | ||
| 160 | |||
| 161 | [self schedule:@selector(runDelayedAction) interval:delay]; | ||
| 162 | } | ||
| 163 | |||
| 164 | - (void)runDelayedAction | ||
| 165 | { | ||
| 166 | [self unschedule:@selector(runDelayedAction)]; | ||
| 167 | |||
| 168 | delayedAction(); | ||
| 169 | [delayedAction release]; | ||
| 170 | delayedAction = nil; | ||
| 171 | } | ||
| 172 | |||
| 71 | - (void)dealloc | 173 | - (void)dealloc |
| 72 | { | 174 | { |
| 73 | [objects release]; | 175 | [objects release]; |
| diff --git a/Classes/MainMenuLayer.m b/Classes/MainMenuLayer.m index 11cffd7..50c595f 100755 --- a/Classes/MainMenuLayer.m +++ b/Classes/MainMenuLayer.m | |||
| @@ -8,7 +8,8 @@ | |||
| 8 | 8 | ||
| 9 | #import "MainMenuLayer.h" | 9 | #import "MainMenuLayer.h" |
| 10 | #import "HighscoreListController.h" | 10 | #import "HighscoreListController.h" |
| 11 | #import "GameLayer.h" | 11 | #import "ClassicGameMode.h" |
| 12 | #import "TutorialMode.h" | ||
| 12 | #import "Cart_CollectAppDelegate.h" | 13 | #import "Cart_CollectAppDelegate.h" |
| 13 | 14 | ||
| 14 | @implementation MainMenuLayer | 15 | @implementation MainMenuLayer |
| @@ -57,7 +58,14 @@ | |||
| 57 | 58 | ||
| 58 | - (void)newgame | 59 | - (void)newgame |
| 59 | { | 60 | { |
| 60 | [[CCDirector sharedDirector] replaceScene:[GameLayer scene]]; | 61 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
| 62 | |||
| 63 | if ([defaults boolForKey:@"hasDoneTutorial"]) | ||
| 64 | { | ||
| 65 | [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; | ||
| 66 | } else { | ||
| 67 | [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]]; | ||
| 68 | } | ||
| 61 | } | 69 | } |
| 62 | 70 | ||
| 63 | - (void)highscores | 71 | - (void)highscores |
| diff --git a/Classes/TutorialBubble.m b/Classes/TutorialBubble.m index b85aa31..74f667f 100644 --- a/Classes/TutorialBubble.m +++ b/Classes/TutorialBubble.m | |||
| @@ -134,6 +134,17 @@ | |||
| 134 | boxLoc = CGPointMake(CGRectGetMaxX(spriteBounds), CGRectGetMaxY(spriteBounds) - self.frame.size.height); | 134 | boxLoc = CGPointMake(CGRectGetMaxX(spriteBounds), CGRectGetMaxY(spriteBounds) - self.frame.size.height); |
| 135 | arrowLoc = CGPointMake(0, button.frame.size.height - spriteBounds.size.height/2 + 4); | 135 | arrowLoc = CGPointMake(0, button.frame.size.height - spriteBounds.size.height/2 + 4); |
| 136 | } | 136 | } |
| 137 | } else { | ||
| 138 | arrowRotation = 180; | ||
| 139 | |||
| 140 | if (CGRectGetMidX(spriteBounds) < button.frame.size.width) | ||
| 141 | { | ||
| 142 | boxLoc = CGPointMake(0, CGRectGetMaxY(spriteBounds)-4); | ||
| 143 | arrowLoc = CGPointMake(spriteBounds.origin.x+4, 0); | ||
| 144 | } else { | ||
| 145 | boxLoc = CGPointMake(CGRectGetMaxX(spriteBounds) - self.frame.size.width, CGRectGetMaxY(spriteBounds)-4); | ||
| 146 | arrowLoc = CGPointMake(button.frame.size.width - spriteBounds.size.width/2 + 4, 0); | ||
| 147 | } | ||
| 137 | } | 148 | } |
| 138 | 149 | ||
| 139 | CGImageRef framestuff = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"framestuff" ofType:@"png"]] CGImage]; | 150 | CGImageRef framestuff = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"framestuff" ofType:@"png"]] CGImage]; |
| @@ -153,8 +164,6 @@ | |||
| 153 | 164 | ||
| 154 | - (void)buttonPressed:(id)sender | 165 | - (void)buttonPressed:(id)sender |
| 155 | { | 166 | { |
| 156 | [self removeFromSuperview]; | ||
| 157 | |||
| 158 | if (target != nil) | 167 | if (target != nil) |
| 159 | { | 168 | { |
| 160 | [target performSelector:action]; | 169 | [target performSelector:action]; |
| diff --git a/Classes/TutorialMode.h b/Classes/TutorialMode.h new file mode 100644 index 0000000..17b0c7f --- /dev/null +++ b/Classes/TutorialMode.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | // | ||
| 2 | // TutorialMode.h | ||
| 3 | // Cart Collect | ||
| 4 | // | ||
| 5 | // Created by Starla Insigna on 8/10/11. | ||
| 6 | // Copyright 2011 Four Island. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import "GameMode.h" | ||
| 10 | #import "TutorialBubble.h" | ||
| 11 | #import "FallingObjectDelegate.h" | ||
| 12 | |||
| 13 | @interface TutorialMode : GameMode <FallingObjectDelegate> { | ||
| 14 | TutorialBubble* currentTutorial; | ||
| 15 | BOOL showedDeathBubble; | ||
| 16 | int randomItemsDropped; | ||
| 17 | } | ||
| 18 | |||
| 19 | @property (nonatomic,retain) TutorialBubble* currentTutorial; | ||
| 20 | - (void)endTutorial; | ||
| 21 | - (FallingObject*)dropSpecificItem:(FallingObject*)item; | ||
| 22 | - (FallingObject*)dropRandomItem; | ||
| 23 | - (void)randomlyAddObject:(ccTime)dt; | ||
| 24 | - (void)skipTutorial; | ||
| 25 | |||
| 26 | @end | ||
| diff --git a/Classes/TutorialMode.m b/Classes/TutorialMode.m new file mode 100644 index 0000000..37e8bd0 --- /dev/null +++ b/Classes/TutorialMode.m | |||
| @@ -0,0 +1,349 @@ | |||
| 1 | // | ||
| 2 | // TutorialMode.m | ||
| 3 | // Cart Collect | ||
| 4 | // | ||
| 5 | // Created by Starla Insigna on 8/10/11. | ||
| 6 | // Copyright 2011 Four Island. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import "TutorialMode.h" | ||
| 10 | #import "FallingObject.h" | ||
| 11 | #import "Cherry.h" | ||
| 12 | #import "Bottle.h" | ||
| 13 | #import "OneUp.h" | ||
| 14 | #import "Rock.h" | ||
| 15 | #import "ClassicGameMode.h" | ||
| 16 | |||
| 17 | // Item tags: | ||
| 18 | // 2000 - first dropped item | ||
| 19 | // 2001 - item that is dropped after you catch first dropped item to demonstrate what happens when you miss | ||
| 20 | // 2002 - items that are dropped after you miss first dropped item to demonstrate what happens when you catch | ||
| 21 | // 2003 - 1-Up | ||
| 22 | // 2009 - rock | ||
| 23 | |||
| 24 | @implementation TutorialMode | ||
| 25 | |||
| 26 | @synthesize currentTutorial; | ||
| 27 | |||
| 28 | - (id)init | ||
| 29 | { | ||
| 30 | self = [super init]; | ||
| 31 | |||
| 32 | if (nil != self) | ||
| 33 | { | ||
| 34 | CCSprite* backgroundImage = [CCSprite spriteWithFile:@"SeaBeach.png"]; | ||
| 35 | backgroundImage.position = ccp(240, 160); | ||
| 36 | [self addChild:backgroundImage z:-1]; | ||
| 37 | |||
| 38 | CCMenuItemImage* menuItem1 = [CCMenuItemImage itemFromNormalImage:@"skiptutorial.png" selectedImage:@"skiptutorial2.png" target:self selector:@selector(skipTutorial)]; | ||
| 39 | CCMenu* theMenu = [CCMenu menuWithItems:menuItem1, nil]; | ||
| 40 | theMenu.position = ccp(480-16-16-62, 320-8-16); | ||
| 41 | [self addChild:theMenu]; | ||
| 42 | |||
| 43 | showedDeathBubble = NO; | ||
| 44 | randomItemsDropped = 0; | ||
| 45 | } | ||
| 46 | |||
| 47 | return self; | ||
| 48 | } | ||
| 49 | |||
| 50 | - (void)onEnterTransitionDidFinish | ||
| 51 | { | ||
| 52 | [super onEnterTransitionDidFinish]; | ||
| 53 | |||
| 54 | [self scheduleDelayedAction:^{ | ||
| 55 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"Welcome to Cart Collect. This is a tutorial designed to help you get started playing the game. Below this bubble is a cart. Tilt your device to move it." name:@"cart" spriteReference:cart.sprite]; | ||
| 56 | self.currentTutorial = bubble; | ||
| 57 | [bubble release]; | ||
| 58 | } delay:2.0f]; | ||
| 59 | } | ||
| 60 | |||
| 61 | - (void)tick:(ccTime)dt | ||
| 62 | { | ||
| 63 | [super tick:dt]; | ||
| 64 | |||
| 65 | FallingObject* object = [objects anyObject]; | ||
| 66 | if ((object.sprite.tag == 2000) && (object.sprite.position.y == 360-object.weight*14)) | ||
| 67 | { | ||
| 68 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"This is an item. Try to catch it with your cart." name:@"item" spriteReference:object.sprite]; | ||
| 69 | self.currentTutorial = bubble; | ||
| 70 | [bubble release]; | ||
| 71 | } else if ((object.sprite.tag == 2003) && (object.sprite.position.y == 360-object.weight*8)) | ||
| 72 | { | ||
| 73 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"This is a 1-Up. Catch it to gain an extra life. There's no penalty for not catching it, though." name:@"oneup" spriteReference:object.sprite]; | ||
| 74 | self.currentTutorial = bubble; | ||
| 75 | [bubble release]; | ||
| 76 | } else if ((object.sprite.tag == 2009) && (object.sprite.position.y == 360-object.weight*14)) | ||
| 77 | { | ||
| 78 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"This is a rock. It would be better for your health if you did not catch this item." name:@"rock" spriteReference:object.sprite]; | ||
| 79 | self.currentTutorial = bubble; | ||
| 80 | [bubble release]; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | - (void)didCatchItem:(FallingObject *)item | ||
| 85 | { | ||
| 86 | if (item.sprite.tag == 2000) | ||
| 87 | { | ||
| 88 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"Congratulations! If you look at your score, you'll see it increased. Catching items is good. Now, let's see what happens when you don't catch an item." name:@"caught-first"]; | ||
| 89 | self.currentTutorial = bubble; | ||
| 90 | [bubble release]; | ||
| 91 | } else if (item.sprite.tag == 2002) | ||
| 92 | { | ||
| 93 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"There you go! If you look at your score, you'll see it increased. Catching items is good." name:@"caught-second"]; | ||
| 94 | self.currentTutorial = bubble; | ||
| 95 | [bubble release]; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 | - (void)didMissItem:(FallingObject *)item | ||
| 100 | { | ||
| 101 | if (item.sprite.tag == 2000) | ||
| 102 | { | ||
| 103 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"Whoops, you missed it! Look at your lives counter--you lost one! If you lose all of your lives, you lose the game. Try catching the item again." name:@"missed-first"]; | ||
| 104 | self.currentTutorial = bubble; | ||
| 105 | [bubble release]; | ||
| 106 | } else if (item.sprite.tag == 2001) | ||
| 107 | { | ||
| 108 | [cart setImmobile:NO]; | ||
| 109 | |||
| 110 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"You lost a life! You only have three lives, so try not to miss any items! However..." name:@"missed-second"]; | ||
| 111 | self.currentTutorial = bubble; | ||
| 112 | [bubble release]; | ||
| 113 | } else if (item.sprite.tag == 2002) | ||
| 114 | { | ||
| 115 | [self scheduleDelayedAction:^{ | ||
| 116 | FallingObject* object = [self dropRandomItem]; | ||
| 117 | object.sprite.tag = 2002; | ||
| 118 | [object release]; | ||
| 119 | } delay:1.0f]; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | - (void)didDestroyItem:(FallingObject *)item | ||
| 124 | { | ||
| 125 | if (item.sprite.tag == 2003) | ||
| 126 | { | ||
| 127 | [self schedule:@selector(randomlyAddObject:) interval:2.5f]; | ||
| 128 | } else if (item.sprite.tag == 2009) | ||
| 129 | { | ||
| 130 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"As you play, Cart Collect gets progressively more intense. Watch what happens when rocks are added to the mix and the speed is turned up." name:@"intense"]; | ||
| 131 | self.currentTutorial = bubble; | ||
| 132 | [bubble release]; | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
| 136 | - (void)setCurrentTutorial:(TutorialBubble *)m_currentTutorial | ||
| 137 | { | ||
| 138 | @synchronized(self) | ||
| 139 | { | ||
| 140 | if (currentTutorial != m_currentTutorial) | ||
| 141 | { | ||
| 142 | [currentTutorial removeFromSuperview]; | ||
| 143 | [currentTutorial release]; | ||
| 144 | currentTutorial = [m_currentTutorial retain]; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | if (currentTutorial != nil) | ||
| 149 | { | ||
| 150 | [currentTutorial setTarget:self action:@selector(endTutorial)]; | ||
| 151 | [[[CCDirector sharedDirector] openGLView] addSubview:currentTutorial]; | ||
| 152 | [self pauseSchedulerAndActions]; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | - (void)endTutorial | ||
| 157 | { | ||
| 158 | [self resumeSchedulerAndActions]; | ||
| 159 | |||
| 160 | if ([currentTutorial.name isEqual:@"cart"]) | ||
| 161 | { | ||
| 162 | [self scheduleDelayedAction:^{ | ||
| 163 | FallingObject* object = [self dropRandomItem]; | ||
| 164 | object.sprite.tag = 2000; | ||
| 165 | [object release]; | ||
| 166 | } delay:3.0f]; | ||
| 167 | } else if ([currentTutorial.name isEqual:@"caught-first"]) | ||
| 168 | { | ||
| 169 | [cart setImmobile:YES]; | ||
| 170 | |||
| 171 | [self scheduleDelayedAction:^{ | ||
| 172 | FallingObject* object = [self dropRandomItem]; | ||
| 173 | |||
| 174 | if (cart.sprite.position.x > 240) | ||
| 175 | { | ||
| 176 | object.sprite.position = ccp(20, 360); | ||
| 177 | } else { | ||
| 178 | object.sprite.position = ccp(460, 360); | ||
| 179 | } | ||
| 180 | |||
| 181 | object.sprite.tag = 2001; | ||
| 182 | |||
| 183 | [object release]; | ||
| 184 | } delay:1.0f]; | ||
| 185 | } else if ([currentTutorial.name isEqual:@"missed-first"]) | ||
| 186 | { | ||
| 187 | [self scheduleDelayedAction:^{ | ||
| 188 | FallingObject* object = [self dropRandomItem]; | ||
| 189 | object.sprite.tag = 2002; | ||
| 190 | [object release]; | ||
| 191 | } delay:1.0f]; | ||
| 192 | } else if (([currentTutorial.name isEqual:@"caught-second"]) || ([currentTutorial.name isEqual:@"missed-second"])) | ||
| 193 | { | ||
| 194 | [self scheduleDelayedAction:^{ | ||
| 195 | FallingObject* object = [self dropSpecificItem:[[OneUp alloc] init]]; | ||
| 196 | object.sprite.tag = 2003; | ||
| 197 | [object release]; | ||
| 198 | } delay:2.0f]; | ||
| 199 | } else if ([currentTutorial.name isEqual:@"intense"]) | ||
| 200 | { | ||
| 201 | [self schedule:@selector(randomlyAddObject:) interval:1.0f]; | ||
| 202 | } else if ([currentTutorial.name isEqual:@"end"]) | ||
| 203 | { | ||
| 204 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | ||
| 205 | [defaults setBool:YES forKey:@"hasDoneTutorial"]; | ||
| 206 | |||
| 207 | [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:3.0f scene:[ClassicGameMode scene] withColor:ccc3(0,0,0)]]; | ||
| 208 | } | ||
| 209 | |||
| 210 | self.currentTutorial = nil; | ||
| 211 | } | ||
| 212 | |||
| 213 | - (void)pause | ||
| 214 | { | ||
| 215 | if (self.currentTutorial != nil) | ||
| 216 | { | ||
| 217 | [self.currentTutorial removeFromSuperview]; | ||
| 218 | } | ||
| 219 | |||
| 220 | [super pause]; | ||
| 221 | } | ||
| 222 | |||
| 223 | - (void)unpause | ||
| 224 | { | ||
| 225 | [super unpause]; | ||
| 226 | |||
| 227 | if (self.currentTutorial != nil) | ||
| 228 | { | ||
| 229 | [self pauseSchedulerAndActions]; | ||
| 230 | [[[CCDirector sharedDirector] openGLView] addSubview:self.currentTutorial]; | ||
| 231 | } | ||
| 232 | } | ||
| 233 | |||
| 234 | - (FallingObject*)dropSpecificItem:(FallingObject*)object | ||
| 235 | { | ||
| 236 | int objectX = arc4random()%448+16; | ||
| 237 | object.sprite.position = ccp(objectX, 360); | ||
| 238 | object.sprite.scale = 1; | ||
| 239 | [self addChild:object.sprite]; | ||
| 240 | |||
| 241 | object.delegate = self; | ||
| 242 | |||
| 243 | [objects addObject:object]; | ||
| 244 | |||
| 245 | return object; | ||
| 246 | } | ||
| 247 | |||
| 248 | - (FallingObject*)dropRandomItem | ||
| 249 | { | ||
| 250 | FallingObject* object; | ||
| 251 | int randomval = arc4random()%100; | ||
| 252 | |||
| 253 | if (randomval < 65) | ||
| 254 | { | ||
| 255 | object = [[Cherry alloc] init]; | ||
| 256 | } else { | ||
| 257 | object = [[Bottle alloc] init]; | ||
| 258 | } | ||
| 259 | |||
| 260 | return [self dropSpecificItem:object]; | ||
| 261 | } | ||
| 262 | |||
| 263 | - (void)setLives:(int)m_lives | ||
| 264 | { | ||
| 265 | [super setLives:m_lives]; | ||
| 266 | |||
| 267 | if ((lives < 1) && (!showedDeathBubble)) | ||
| 268 | { | ||
| 269 | showedDeathBubble = YES; | ||
| 270 | |||
| 271 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"You lost all your lives! Normally, you'd be taken to a game over screen where you could submit your score to the highscore list, but we're a bit more forgiving in tutorial mode." name:@"gameover"]; | ||
| 272 | self.currentTutorial = bubble; | ||
| 273 | [bubble release]; | ||
| 274 | } | ||
| 275 | } | ||
| 276 | |||
| 277 | - (void)randomlyAddObject:(ccTime)dt | ||
| 278 | { | ||
| 279 | FallingObject* object; | ||
| 280 | |||
| 281 | if (randomItemsDropped < 5) | ||
| 282 | { | ||
| 283 | int randomval = arc4random()%100; | ||
| 284 | |||
| 285 | if (randomval < 65) | ||
| 286 | { | ||
| 287 | object = [[Cherry alloc] init]; | ||
| 288 | } else if (randomval < 98) | ||
| 289 | { | ||
| 290 | object = [[Bottle alloc] init]; | ||
| 291 | } else { | ||
| 292 | object = [[OneUp alloc] init]; | ||
| 293 | } | ||
| 294 | } else if (randomItemsDropped == 5) | ||
| 295 | { | ||
| 296 | object = [[Rock alloc] init]; | ||
| 297 | object.sprite.tag = 2009; | ||
| 298 | |||
| 299 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 300 | } else if (randomItemsDropped < 15) { | ||
| 301 | int randomval = arc4random()%100; | ||
| 302 | |||
| 303 | if (randomval < 40) | ||
| 304 | { | ||
| 305 | object = [[Cherry alloc] init]; | ||
| 306 | } else if (randomval < 70) | ||
| 307 | { | ||
| 308 | object = [[Rock alloc] init]; | ||
| 309 | } else if (randomval < 98) | ||
| 310 | { | ||
| 311 | object = [[Bottle alloc] init]; | ||
| 312 | } else { | ||
| 313 | object = [[OneUp alloc] init]; | ||
| 314 | } | ||
| 315 | } else if (randomItemsDropped == 15) | ||
| 316 | { | ||
| 317 | [self scheduleDelayedAction:^{ | ||
| 318 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"That's pretty much it! You've completed the tutorial, so now it's time to play an actual game of Cart Collect!" name:@"end"]; | ||
| 319 | self.currentTutorial = bubble; | ||
| 320 | [bubble release]; | ||
| 321 | } delay:2.0f]; | ||
| 322 | |||
| 323 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 324 | |||
| 325 | return; | ||
| 326 | } else { | ||
| 327 | NSLog(@"randomItemsDropped in TutorialMode is greater than 15--this should never happen."); | ||
| 328 | |||
| 329 | return; | ||
| 330 | } | ||
| 331 | |||
| 332 | [self dropSpecificItem:object]; | ||
| 333 | [object release]; | ||
| 334 | |||
| 335 | randomItemsDropped++; | ||
| 336 | } | ||
| 337 | |||
| 338 | - (void)skipTutorial | ||
| 339 | { | ||
| 340 | [self unscheduleAllSelectors]; | ||
| 341 | self.currentTutorial = nil; | ||
| 342 | |||
| 343 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | ||
| 344 | [defaults setBool:YES forKey:@"hasDoneTutorial"]; | ||
| 345 | |||
| 346 | [[CCDirector sharedDirector] replaceScene:[CCTransitionFlipY transitionWithDuration:1.0f scene:[ClassicGameMode scene]]]; | ||
| 347 | } | ||
| 348 | |||
| 349 | @end | ||
| diff --git a/Resources/Info.plist b/Resources/Info.plist index 9b64e3d..ed33cda 100755 --- a/Resources/Info.plist +++ b/Resources/Info.plist | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | <string>Icon-72.png</string> | 19 | <string>Icon-72.png</string> |
| 20 | </array> | 20 | </array> |
| 21 | <key>CFBundleIdentifier</key> | 21 | <key>CFBundleIdentifier</key> |
| 22 | <string>com.fourisland.${PRODUCT_NAME:rfc1034identifier}</string> | 22 | <string>com.apatheticink.${PRODUCT_NAME:rfc1034identifier}</string> |
| 23 | <key>CFBundleInfoDictionaryVersion</key> | 23 | <key>CFBundleInfoDictionaryVersion</key> |
| 24 | <string>6.0</string> | 24 | <string>6.0</string> |
| 25 | <key>CFBundleName</key> | 25 | <key>CFBundleName</key> |
| @@ -32,8 +32,6 @@ | |||
| 32 | <string>????</string> | 32 | <string>????</string> |
| 33 | <key>CFBundleURLTypes</key> | 33 | <key>CFBundleURLTypes</key> |
| 34 | <array/> | 34 | <array/> |
| 35 | <key>CFBundleVersion</key> | ||
| 36 | <string>1.0</string> | ||
| 37 | <key>LSRequiresIPhoneOS</key> | 35 | <key>LSRequiresIPhoneOS</key> |
| 38 | <true/> | 36 | <true/> |
| 39 | <key>UIPrerenderedIcon</key> | 37 | <key>UIPrerenderedIcon</key> |
| diff --git a/Resources/skiptutorial.png b/Resources/skiptutorial.png new file mode 100644 index 0000000..5c95cc9 --- /dev/null +++ b/Resources/skiptutorial.png | |||
| Binary files differ | |||
| diff --git a/Resources/skiptutorial2.png b/Resources/skiptutorial2.png new file mode 100644 index 0000000..95bbbbd --- /dev/null +++ b/Resources/skiptutorial2.png | |||
| Binary files differ | |||
