diff options
| -rwxr-xr-x | Cartographic.xcodeproj/project.pbxproj | 61 | ||||
| -rw-r--r-- | Classes/Cart.h | 5 | ||||
| -rw-r--r-- | Classes/Cart.m | 23 | ||||
| -rw-r--r-- | Classes/CartDelegate.h | 19 | ||||
| -rwxr-xr-x | Classes/Cart_CollectAppDelegate.m | 4 | ||||
| -rwxr-xr-x | Classes/ClassicGameMode.m | 14 | ||||
| -rw-r--r-- | Classes/GameMode.h | 2 | ||||
| -rw-r--r-- | Classes/GameMode.m | 6 | ||||
| -rw-r--r-- | Classes/GameModeSelectionLayer.m | 15 | ||||
| -rwxr-xr-x | Classes/GameOverScene.h | 5 | ||||
| -rwxr-xr-x | Classes/GameOverScene.m | 9 | ||||
| -rw-r--r-- | Classes/JumpGameMode.h | 32 | ||||
| -rw-r--r-- | Classes/JumpGameMode.m | 437 | ||||
| -rw-r--r-- | Resources/jump.png | bin | 0 -> 2071 bytes | |||
| -rw-r--r-- | Resources/jump2.png | bin | 0 -> 2079 bytes | |||
| -rw-r--r-- | Resources/ledge.png | bin | 0 -> 1012 bytes | |||
| -rw-r--r-- | Resources/venice.png | bin | 0 -> 1329 bytes | |||
| -rw-r--r-- | Resources/water.png | bin | 0 -> 981 bytes | |||
| -rwxr-xr-x | libs/cocos2d/CCNotifications.h | 141 | ||||
| -rwxr-xr-x | libs/cocos2d/CCNotifications.m | 494 | ||||
| -rw-r--r-- | libs/cocos2d/notificationDesign.h | 39 | ||||
| -rw-r--r-- | libs/cocos2d/notificationDesign.m | 82 |
22 files changed, 1372 insertions, 16 deletions
| diff --git a/Cartographic.xcodeproj/project.pbxproj b/Cartographic.xcodeproj/project.pbxproj index e7f02e3..5f63bf1 100755 --- a/Cartographic.xcodeproj/project.pbxproj +++ b/Cartographic.xcodeproj/project.pbxproj | |||
| @@ -111,15 +111,23 @@ | |||
| 111 | 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C29041113EAEC8A0032DA0F /* framestuff.png */; }; | 111 | 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C29041113EAEC8A0032DA0F /* framestuff.png */; }; |
| 112 | 6C39CFE013FC2708002B21AF /* tutorial.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFDF13FC2708002B21AF /* tutorial.png */; }; | 112 | 6C39CFE013FC2708002B21AF /* tutorial.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFDF13FC2708002B21AF /* tutorial.png */; }; |
| 113 | 6C39CFE213FC2713002B21AF /* tutorial2.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFE113FC2713002B21AF /* tutorial2.png */; }; | 113 | 6C39CFE213FC2713002B21AF /* tutorial2.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFE113FC2713002B21AF /* tutorial2.png */; }; |
| 114 | 6C39CFE513FC4635002B21AF /* JumpGameMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C39CFE413FC4635002B21AF /* JumpGameMode.m */; }; | ||
| 115 | 6C39CFE713FC46CD002B21AF /* water.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFE613FC46CD002B21AF /* water.png */; }; | ||
| 116 | 6C39CFE913FC8AC4002B21AF /* jump2.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFE813FC8AC4002B21AF /* jump2.png */; }; | ||
| 117 | 6C39CFEB13FC8ACA002B21AF /* jump.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFEA13FC8ACA002B21AF /* jump.png */; }; | ||
| 114 | 6C39CFF313FD4F8B002B21AF /* GameModeSelection.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C39CFF213FD4F89002B21AF /* GameModeSelection.m */; }; | 118 | 6C39CFF313FD4F8B002B21AF /* GameModeSelection.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C39CFF213FD4F89002B21AF /* GameModeSelection.m */; }; |
| 115 | 6C39CFF513FD5526002B21AF /* paintdaubs.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFF413FD5526002B21AF /* paintdaubs.png */; }; | 119 | 6C39CFF513FD5526002B21AF /* paintdaubs.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39CFF413FD5526002B21AF /* paintdaubs.png */; }; |
| 116 | 6C39CFF813FD7638002B21AF /* GameModeSelectionLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C39CFF713FD7637002B21AF /* GameModeSelectionLayer.m */; }; | 120 | 6C39CFF813FD7638002B21AF /* GameModeSelectionLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C39CFF713FD7637002B21AF /* GameModeSelectionLayer.m */; }; |
| 117 | 6C39D00813FD9037002B21AF /* florence.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39D00713FD9037002B21AF /* florence.png */; }; | 121 | 6C39D00813FD9037002B21AF /* florence.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39D00713FD9037002B21AF /* florence.png */; }; |
| 118 | 6C39D01213FD9945002B21AF /* paris.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39D01113FD9945002B21AF /* paris.png */; }; | 122 | 6C39D01213FD9945002B21AF /* paris.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C39D01113FD9945002B21AF /* paris.png */; }; |
| 123 | 6C44FFFD1413D03300A9E1D7 /* libTestFlight.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C88B69314119B5A0049E402 /* libTestFlight.a */; }; | ||
| 119 | 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C5179C513DF3839006F1F38 /* Morning1.png */; }; | 124 | 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C5179C513DF3839006F1F38 /* Morning1.png */; }; |
| 120 | 6C88B69414119B5A0049E402 /* libTestFlight.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C88B69314119B5A0049E402 /* libTestFlight.a */; }; | 125 | 6C85834014055A44009EF100 /* CCNotifications.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C85833F14055A44009EF100 /* CCNotifications.m */; }; |
| 126 | 6C85834414055B2E009EF100 /* notificationDesign.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C85834314055B2E009EF100 /* notificationDesign.m */; }; | ||
| 127 | 6C85834614056E57009EF100 /* venice.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C85834514056E57009EF100 /* venice.png */; }; | ||
| 121 | 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */; }; | 128 | 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */; }; |
| 122 | 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CC89DDE13F31413003704F7 /* TutorialMode.m */; }; | 129 | 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CC89DDE13F31413003704F7 /* TutorialMode.m */; }; |
| 130 | 6CDBE80C14092DB00072F287 /* ledge.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CDBE80B14092DB00072F287 /* ledge.png */; }; | ||
| 123 | DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; }; | 131 | DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; }; |
| 124 | DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; }; | 132 | DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; }; |
| 125 | DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; }; | 133 | DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; }; |
| @@ -434,6 +442,11 @@ | |||
| 434 | 6C29041113EAEC8A0032DA0F /* framestuff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = framestuff.png; sourceTree = "<group>"; }; | 442 | 6C29041113EAEC8A0032DA0F /* framestuff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = framestuff.png; sourceTree = "<group>"; }; |
| 435 | 6C39CFDF13FC2708002B21AF /* tutorial.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tutorial.png; sourceTree = "<group>"; }; | 443 | 6C39CFDF13FC2708002B21AF /* tutorial.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tutorial.png; sourceTree = "<group>"; }; |
| 436 | 6C39CFE113FC2713002B21AF /* tutorial2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tutorial2.png; sourceTree = "<group>"; }; | 444 | 6C39CFE113FC2713002B21AF /* tutorial2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tutorial2.png; sourceTree = "<group>"; }; |
| 445 | 6C39CFE313FC4635002B21AF /* JumpGameMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JumpGameMode.h; sourceTree = "<group>"; }; | ||
| 446 | 6C39CFE413FC4635002B21AF /* JumpGameMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JumpGameMode.m; sourceTree = "<group>"; }; | ||
| 447 | 6C39CFE613FC46CD002B21AF /* water.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = water.png; sourceTree = "<group>"; }; | ||
| 448 | 6C39CFE813FC8AC4002B21AF /* jump2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = jump2.png; sourceTree = "<group>"; }; | ||
| 449 | 6C39CFEA13FC8ACA002B21AF /* jump.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = jump.png; sourceTree = "<group>"; }; | ||
| 437 | 6C39CFF113FD4F87002B21AF /* GameModeSelection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameModeSelection.h; sourceTree = "<group>"; }; | 450 | 6C39CFF113FD4F87002B21AF /* GameModeSelection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameModeSelection.h; sourceTree = "<group>"; }; |
| 438 | 6C39CFF213FD4F89002B21AF /* GameModeSelection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameModeSelection.m; sourceTree = "<group>"; }; | 451 | 6C39CFF213FD4F89002B21AF /* GameModeSelection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameModeSelection.m; sourceTree = "<group>"; }; |
| 439 | 6C39CFF413FD5526002B21AF /* paintdaubs.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = paintdaubs.png; sourceTree = "<group>"; }; | 452 | 6C39CFF413FD5526002B21AF /* paintdaubs.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = paintdaubs.png; sourceTree = "<group>"; }; |
| @@ -442,12 +455,19 @@ | |||
| 442 | 6C39D00713FD9037002B21AF /* florence.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = florence.png; sourceTree = "<group>"; }; | 455 | 6C39D00713FD9037002B21AF /* florence.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = florence.png; sourceTree = "<group>"; }; |
| 443 | 6C39D01113FD9945002B21AF /* paris.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = paris.png; sourceTree = "<group>"; }; | 456 | 6C39D01113FD9945002B21AF /* paris.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = paris.png; sourceTree = "<group>"; }; |
| 444 | 6C5179C513DF3839006F1F38 /* Morning1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Morning1.png; sourceTree = "<group>"; }; | 457 | 6C5179C513DF3839006F1F38 /* Morning1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Morning1.png; sourceTree = "<group>"; }; |
| 458 | 6C85833E14055A44009EF100 /* CCNotifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNotifications.h; sourceTree = "<group>"; }; | ||
| 459 | 6C85833F14055A44009EF100 /* CCNotifications.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCNotifications.m; sourceTree = "<group>"; }; | ||
| 460 | 6C85834214055B2D009EF100 /* notificationDesign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = notificationDesign.h; sourceTree = "<group>"; }; | ||
| 461 | 6C85834314055B2E009EF100 /* notificationDesign.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = notificationDesign.m; sourceTree = "<group>"; }; | ||
| 462 | 6C85834514056E57009EF100 /* venice.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = venice.png; sourceTree = "<group>"; }; | ||
| 445 | 6C88B69314119B5A0049E402 /* libTestFlight.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libTestFlight.a; sourceTree = "<group>"; }; | 463 | 6C88B69314119B5A0049E402 /* libTestFlight.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libTestFlight.a; sourceTree = "<group>"; }; |
| 446 | 6CB532581403BA4F00780A5E /* GameModeSelectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameModeSelectionDelegate.h; sourceTree = "<group>"; }; | 464 | 6CB532581403BA4F00780A5E /* GameModeSelectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameModeSelectionDelegate.h; sourceTree = "<group>"; }; |
| 447 | 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = "<group>"; }; | 465 | 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Entitlements.plist; sourceTree = "<group>"; }; |
| 448 | 6CC89DDD13F31413003704F7 /* TutorialMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TutorialMode.h; sourceTree = "<group>"; }; | 466 | 6CC89DDD13F31413003704F7 /* TutorialMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TutorialMode.h; sourceTree = "<group>"; }; |
| 449 | 6CC89DDE13F31413003704F7 /* TutorialMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TutorialMode.m; sourceTree = "<group>"; }; | 467 | 6CC89DDE13F31413003704F7 /* TutorialMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TutorialMode.m; sourceTree = "<group>"; }; |
| 450 | 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectDelegate.h; sourceTree = "<group>"; }; | 468 | 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectDelegate.h; sourceTree = "<group>"; }; |
| 469 | 6CDBE80B14092DB00072F287 /* ledge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ledge.png; sourceTree = "<group>"; }; | ||
| 470 | 6CDBE80E140936CF0072F287 /* CartDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CartDelegate.h; sourceTree = "<group>"; }; | ||
| 451 | DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; | 471 | DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; |
| 452 | DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; | 472 | DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; |
| 453 | DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; | 473 | DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; |
| @@ -654,7 +674,7 @@ | |||
| 654 | 506EDBA5102F4C9F00A389B3 /* AVFoundation.framework in Frameworks */, | 674 | 506EDBA5102F4C9F00A389B3 /* AVFoundation.framework in Frameworks */, |
| 655 | 506EE1A91030508200A389B3 /* libcocos2d libraries.a in Frameworks */, | 675 | 506EE1A91030508200A389B3 /* libcocos2d libraries.a in Frameworks */, |
| 656 | 3F8395D113D746200059AEE8 /* libsqlite3.0.dylib in Frameworks */, | 676 | 3F8395D113D746200059AEE8 /* libsqlite3.0.dylib in Frameworks */, |
| 657 | 6C88B69414119B5A0049E402 /* libTestFlight.a in Frameworks */, | 677 | 6C44FFFD1413D03300A9E1D7 /* libTestFlight.a in Frameworks */, |
| 658 | ); | 678 | ); |
| 659 | runOnlyForDeploymentPostprocessing = 0; | 679 | runOnlyForDeploymentPostprocessing = 0; |
| 660 | }; | 680 | }; |
| @@ -765,6 +785,8 @@ | |||
| 765 | 3F6C7F4D13D647B600C038FE /* Sprites */ = { | 785 | 3F6C7F4D13D647B600C038FE /* Sprites */ = { |
| 766 | isa = PBXGroup; | 786 | isa = PBXGroup; |
| 767 | children = ( | 787 | children = ( |
| 788 | 6CDBE80B14092DB00072F287 /* ledge.png */, | ||
| 789 | 6C39CFE613FC46CD002B21AF /* water.png */, | ||
| 768 | 6C29041113EAEC8A0032DA0F /* framestuff.png */, | 790 | 6C29041113EAEC8A0032DA0F /* framestuff.png */, |
| 769 | 3F6C7EE013D636BE00C038FE /* rock.png */, | 791 | 3F6C7EE013D636BE00C038FE /* rock.png */, |
| 770 | 3F63FA3E13D4EE53003B3D14 /* oneup.png */, | 792 | 3F63FA3E13D4EE53003B3D14 /* oneup.png */, |
| @@ -803,6 +825,8 @@ | |||
| 803 | children = ( | 825 | children = ( |
| 804 | 6C19F1641401917900F9CCD3 /* feedback2.png */, | 826 | 6C19F1641401917900F9CCD3 /* feedback2.png */, |
| 805 | 6C19F1621401917500F9CCD3 /* feedback.png */, | 827 | 6C19F1621401917500F9CCD3 /* feedback.png */, |
| 828 | 6C39CFEA13FC8ACA002B21AF /* jump.png */, | ||
| 829 | 6C39CFE813FC8AC4002B21AF /* jump2.png */, | ||
| 806 | 6C39CFE113FC2713002B21AF /* tutorial2.png */, | 830 | 6C39CFE113FC2713002B21AF /* tutorial2.png */, |
| 807 | 6C39CFDF13FC2708002B21AF /* tutorial.png */, | 831 | 6C39CFDF13FC2708002B21AF /* tutorial.png */, |
| 808 | 3F7D0F4813D8F17C00B6CE14 /* highscores.png */, | 832 | 3F7D0F4813D8F17C00B6CE14 /* highscores.png */, |
| @@ -911,6 +935,8 @@ | |||
| 911 | 3FE79CD313D4DE37001A6B93 /* ClassicGameMode.m */, | 935 | 3FE79CD313D4DE37001A6B93 /* ClassicGameMode.m */, |
| 912 | 6CC89DDD13F31413003704F7 /* TutorialMode.h */, | 936 | 6CC89DDD13F31413003704F7 /* TutorialMode.h */, |
| 913 | 6CC89DDE13F31413003704F7 /* TutorialMode.m */, | 937 | 6CC89DDE13F31413003704F7 /* TutorialMode.m */, |
| 938 | 6C39CFE313FC4635002B21AF /* JumpGameMode.h */, | ||
| 939 | 6C39CFE413FC4635002B21AF /* JumpGameMode.m */, | ||
| 914 | ); | 940 | ); |
| 915 | name = "Game Modes"; | 941 | name = "Game Modes"; |
| 916 | sourceTree = "<group>"; | 942 | sourceTree = "<group>"; |
| @@ -918,6 +944,7 @@ | |||
| 918 | 6C39D00513FD901A002B21AF /* Icons */ = { | 944 | 6C39D00513FD901A002B21AF /* Icons */ = { |
| 919 | isa = PBXGroup; | 945 | isa = PBXGroup; |
| 920 | children = ( | 946 | children = ( |
| 947 | 6C85834514056E57009EF100 /* venice.png */, | ||
| 921 | 6C39D01113FD9945002B21AF /* paris.png */, | 948 | 6C39D01113FD9945002B21AF /* paris.png */, |
| 922 | 6C39D00713FD9037002B21AF /* florence.png */, | 949 | 6C39D00713FD9037002B21AF /* florence.png */, |
| 923 | ); | 950 | ); |
| @@ -942,6 +969,7 @@ | |||
| 942 | 6C0C140F13F2099B003A31B2 /* Cart.h */, | 969 | 6C0C140F13F2099B003A31B2 /* Cart.h */, |
| 943 | 6C0C141013F2099B003A31B2 /* Cart.m */, | 970 | 6C0C141013F2099B003A31B2 /* Cart.m */, |
| 944 | 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */, | 971 | 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */, |
| 972 | 6CDBE80E140936CF0072F287 /* CartDelegate.h */, | ||
| 945 | ); | 973 | ); |
| 946 | name = Items; | 974 | name = Items; |
| 947 | sourceTree = "<group>"; | 975 | sourceTree = "<group>"; |
| @@ -969,6 +997,8 @@ | |||
| 969 | E02BBB19126CC2F5006E46A2 /* cocos2d */ = { | 997 | E02BBB19126CC2F5006E46A2 /* cocos2d */ = { |
| 970 | isa = PBXGroup; | 998 | isa = PBXGroup; |
| 971 | children = ( | 999 | children = ( |
| 1000 | 6C85833E14055A44009EF100 /* CCNotifications.h */, | ||
| 1001 | 6C85833F14055A44009EF100 /* CCNotifications.m */, | ||
| 972 | E02BBB1A126CC2F5006E46A2 /* CCAction.h */, | 1002 | E02BBB1A126CC2F5006E46A2 /* CCAction.h */, |
| 973 | E02BBB1B126CC2F5006E46A2 /* CCAction.m */, | 1003 | E02BBB1B126CC2F5006E46A2 /* CCAction.m */, |
| 974 | E02BBB1C126CC2F5006E46A2 /* CCActionCamera.h */, | 1004 | E02BBB1C126CC2F5006E46A2 /* CCActionCamera.h */, |
| @@ -1089,6 +1119,8 @@ | |||
| 1089 | E02BBB93126CC2F6006E46A2 /* cocos2d.m */, | 1119 | E02BBB93126CC2F6006E46A2 /* cocos2d.m */, |
| 1090 | E02BBB94126CC2F6006E46A2 /* Platforms */, | 1120 | E02BBB94126CC2F6006E46A2 /* Platforms */, |
| 1091 | E02BBBAD126CC2F6006E46A2 /* Support */, | 1121 | E02BBBAD126CC2F6006E46A2 /* Support */, |
| 1122 | 6C85834214055B2D009EF100 /* notificationDesign.h */, | ||
| 1123 | 6C85834314055B2E009EF100 /* notificationDesign.m */, | ||
| 1092 | ); | 1124 | ); |
| 1093 | name = cocos2d; | 1125 | name = cocos2d; |
| 1094 | path = libs/cocos2d; | 1126 | path = libs/cocos2d; |
| @@ -1368,7 +1400,7 @@ | |||
| 1368 | 29B97313FDCFA39411CA2CEA /* Project object */ = { | 1400 | 29B97313FDCFA39411CA2CEA /* Project object */ = { |
| 1369 | isa = PBXProject; | 1401 | isa = PBXProject; |
| 1370 | attributes = { | 1402 | attributes = { |
| 1371 | LastUpgradeCheck = 0410; | 1403 | LastUpgradeCheck = 0420; |
| 1372 | }; | 1404 | }; |
| 1373 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Cartographic" */; | 1405 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Cartographic" */; |
| 1374 | compatibilityVersion = "Xcode 3.2"; | 1406 | compatibilityVersion = "Xcode 3.2"; |
| @@ -1437,6 +1469,11 @@ | |||
| 1437 | 6C39D01213FD9945002B21AF /* paris.png in Resources */, | 1469 | 6C39D01213FD9945002B21AF /* paris.png in Resources */, |
| 1438 | 6C19F1631401917500F9CCD3 /* feedback.png in Resources */, | 1470 | 6C19F1631401917500F9CCD3 /* feedback.png in Resources */, |
| 1439 | 6C19F1651401917900F9CCD3 /* feedback2.png in Resources */, | 1471 | 6C19F1651401917900F9CCD3 /* feedback2.png in Resources */, |
| 1472 | 6C39CFE713FC46CD002B21AF /* water.png in Resources */, | ||
| 1473 | 6C39CFE913FC8AC4002B21AF /* jump2.png in Resources */, | ||
| 1474 | 6C39CFEB13FC8ACA002B21AF /* jump.png in Resources */, | ||
| 1475 | 6C85834614056E57009EF100 /* venice.png in Resources */, | ||
| 1476 | 6CDBE80C14092DB00072F287 /* ledge.png in Resources */, | ||
| 1440 | ); | 1477 | ); |
| 1441 | runOnlyForDeploymentPostprocessing = 0; | 1478 | runOnlyForDeploymentPostprocessing = 0; |
| 1442 | }; | 1479 | }; |
| @@ -1487,6 +1524,9 @@ | |||
| 1487 | 6C18C3D214033DC50005AA4C /* CocosOverlayScrollView.m in Sources */, | 1524 | 6C18C3D214033DC50005AA4C /* CocosOverlayScrollView.m in Sources */, |
| 1488 | 6C18C3D314033DC60005AA4C /* NMPanelMenu.m in Sources */, | 1525 | 6C18C3D314033DC60005AA4C /* NMPanelMenu.m in Sources */, |
| 1489 | 6C18C3D414033DC60005AA4C /* TouchDelegatingView.m in Sources */, | 1526 | 6C18C3D414033DC60005AA4C /* TouchDelegatingView.m in Sources */, |
| 1527 | 6C39CFE513FC4635002B21AF /* JumpGameMode.m in Sources */, | ||
| 1528 | 6C85834014055A44009EF100 /* CCNotifications.m in Sources */, | ||
| 1529 | 6C85834414055B2E009EF100 /* notificationDesign.m in Sources */, | ||
| 1490 | ); | 1530 | ); |
| 1491 | runOnlyForDeploymentPostprocessing = 0; | 1531 | runOnlyForDeploymentPostprocessing = 0; |
| 1492 | }; | 1532 | }; |
| @@ -1621,6 +1661,7 @@ | |||
| 1621 | GCC_PRECOMPILE_PREFIX_HEADER = YES; | 1661 | GCC_PRECOMPILE_PREFIX_HEADER = YES; |
| 1622 | GCC_PREFIX_HEADER = Cart_Collect_Prefix.pch; | 1662 | GCC_PREFIX_HEADER = Cart_Collect_Prefix.pch; |
| 1623 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; | 1663 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; |
| 1664 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
| 1624 | HEADER_SEARCH_PATHS = libs; | 1665 | HEADER_SEARCH_PATHS = libs; |
| 1625 | INFOPLIST_FILE = Resources/Info.plist; | 1666 | INFOPLIST_FILE = Resources/Info.plist; |
| 1626 | INFOPLIST_PREFIX_HEADER = Versioning.h; | 1667 | INFOPLIST_PREFIX_HEADER = Versioning.h; |
| @@ -1652,6 +1693,7 @@ | |||
| 1652 | GCC_PRECOMPILE_PREFIX_HEADER = YES; | 1693 | GCC_PRECOMPILE_PREFIX_HEADER = YES; |
| 1653 | GCC_PREFIX_HEADER = Cart_Collect_Prefix.pch; | 1694 | GCC_PREFIX_HEADER = Cart_Collect_Prefix.pch; |
| 1654 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; | 1695 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; |
| 1696 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
| 1655 | HEADER_SEARCH_PATHS = libs; | 1697 | HEADER_SEARCH_PATHS = libs; |
| 1656 | INFOPLIST_FILE = Resources/Info.plist; | 1698 | INFOPLIST_FILE = Resources/Info.plist; |
| 1657 | INFOPLIST_PREFIX_HEADER = Versioning.h; | 1699 | INFOPLIST_PREFIX_HEADER = Versioning.h; |
| @@ -1679,6 +1721,7 @@ | |||
| 1679 | GCC_DYNAMIC_NO_PIC = NO; | 1721 | GCC_DYNAMIC_NO_PIC = NO; |
| 1680 | GCC_OPTIMIZATION_LEVEL = 0; | 1722 | GCC_OPTIMIZATION_LEVEL = 0; |
| 1681 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; | 1723 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; |
| 1724 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
| 1682 | HEADER_SEARCH_PATHS = ( | 1725 | HEADER_SEARCH_PATHS = ( |
| 1683 | libs/Chipmunk/include/chipmunk, | 1726 | libs/Chipmunk/include/chipmunk, |
| 1684 | libs, | 1727 | libs, |
| @@ -1697,6 +1740,7 @@ | |||
| 1697 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | 1740 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; |
| 1698 | GCC_PREPROCESSOR_DEFINITIONS = ""; | 1741 | GCC_PREPROCESSOR_DEFINITIONS = ""; |
| 1699 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; | 1742 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; |
| 1743 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
| 1700 | HEADER_SEARCH_PATHS = ( | 1744 | HEADER_SEARCH_PATHS = ( |
| 1701 | libs/Chipmunk/include/chipmunk, | 1745 | libs/Chipmunk/include/chipmunk, |
| 1702 | libs, | 1746 | libs, |
| @@ -1722,7 +1766,7 @@ | |||
| 1722 | "GCC_THUMB_SUPPORT[arch=armv6]" = NO; | 1766 | "GCC_THUMB_SUPPORT[arch=armv6]" = NO; |
| 1723 | "GCC_THUMB_SUPPORT[arch=armv7]" = YES; | 1767 | "GCC_THUMB_SUPPORT[arch=armv7]" = YES; |
| 1724 | GCC_UNROLL_LOOPS = YES; | 1768 | GCC_UNROLL_LOOPS = YES; |
| 1725 | GCC_VERSION = com.apple.compilers.llvmgcc42; | 1769 | GCC_VERSION = ""; |
| 1726 | GCC_WARN_ABOUT_RETURN_TYPE = YES; | 1770 | GCC_WARN_ABOUT_RETURN_TYPE = YES; |
| 1727 | GCC_WARN_UNUSED_VARIABLE = YES; | 1771 | GCC_WARN_UNUSED_VARIABLE = YES; |
| 1728 | IPHONEOS_DEPLOYMENT_TARGET = 3.0; | 1772 | IPHONEOS_DEPLOYMENT_TARGET = 3.0; |
| @@ -1749,6 +1793,7 @@ | |||
| 1749 | NDEBUG, | 1793 | NDEBUG, |
| 1750 | ); | 1794 | ); |
| 1751 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; | 1795 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; |
| 1796 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
| 1752 | HEADER_SEARCH_PATHS = libs; | 1797 | HEADER_SEARCH_PATHS = libs; |
| 1753 | INFOPLIST_FILE = Resources/Info.plist; | 1798 | INFOPLIST_FILE = Resources/Info.plist; |
| 1754 | INFOPLIST_PREFIX_HEADER = Versioning.h; | 1799 | INFOPLIST_PREFIX_HEADER = Versioning.h; |
| @@ -1776,6 +1821,7 @@ | |||
| 1776 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | 1821 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; |
| 1777 | GCC_PREPROCESSOR_DEFINITIONS = ""; | 1822 | GCC_PREPROCESSOR_DEFINITIONS = ""; |
| 1778 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; | 1823 | GCC_TREAT_WARNINGS_AS_ERRORS = NO; |
| 1824 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
| 1779 | HEADER_SEARCH_PATHS = ( | 1825 | HEADER_SEARCH_PATHS = ( |
| 1780 | libs/Chipmunk/include/chipmunk, | 1826 | libs/Chipmunk/include/chipmunk, |
| 1781 | libs, | 1827 | libs, |
| @@ -1789,6 +1835,7 @@ | |||
| 1789 | 6C19F16F1401944500F9CCD3 /* Ad-Hoc */ = { | 1835 | 6C19F16F1401944500F9CCD3 /* Ad-Hoc */ = { |
| 1790 | isa = XCBuildConfiguration; | 1836 | isa = XCBuildConfiguration; |
| 1791 | buildSettings = { | 1837 | buildSettings = { |
| 1838 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
| 1792 | PRODUCT_NAME = "$(TARGET_NAME)"; | 1839 | PRODUCT_NAME = "$(TARGET_NAME)"; |
| 1793 | }; | 1840 | }; |
| 1794 | name = "Ad-Hoc"; | 1841 | name = "Ad-Hoc"; |
| @@ -1796,6 +1843,7 @@ | |||
| 1796 | 6C263DDD13F6F4A000116746 /* Debug */ = { | 1843 | 6C263DDD13F6F4A000116746 /* Debug */ = { |
| 1797 | isa = XCBuildConfiguration; | 1844 | isa = XCBuildConfiguration; |
| 1798 | buildSettings = { | 1845 | buildSettings = { |
| 1846 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
| 1799 | PRODUCT_NAME = "$(TARGET_NAME)"; | 1847 | PRODUCT_NAME = "$(TARGET_NAME)"; |
| 1800 | }; | 1848 | }; |
| 1801 | name = Debug; | 1849 | name = Debug; |
| @@ -1803,6 +1851,7 @@ | |||
| 1803 | 6C263DDE13F6F4A000116746 /* Release */ = { | 1851 | 6C263DDE13F6F4A000116746 /* Release */ = { |
| 1804 | isa = XCBuildConfiguration; | 1852 | isa = XCBuildConfiguration; |
| 1805 | buildSettings = { | 1853 | buildSettings = { |
| 1854 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; | ||
| 1806 | PRODUCT_NAME = "$(TARGET_NAME)"; | 1855 | PRODUCT_NAME = "$(TARGET_NAME)"; |
| 1807 | }; | 1856 | }; |
| 1808 | name = Release; | 1857 | name = Release; |
| @@ -1822,7 +1871,7 @@ | |||
| 1822 | ); | 1871 | ); |
| 1823 | "GCC_THUMB_SUPPORT[arch=armv6]" = NO; | 1872 | "GCC_THUMB_SUPPORT[arch=armv6]" = NO; |
| 1824 | "GCC_THUMB_SUPPORT[arch=armv7]" = YES; | 1873 | "GCC_THUMB_SUPPORT[arch=armv7]" = YES; |
| 1825 | GCC_VERSION = com.apple.compilers.llvmgcc42; | 1874 | GCC_VERSION = ""; |
| 1826 | GCC_WARN_ABOUT_RETURN_TYPE = YES; | 1875 | GCC_WARN_ABOUT_RETURN_TYPE = YES; |
| 1827 | GCC_WARN_UNUSED_VARIABLE = YES; | 1876 | GCC_WARN_UNUSED_VARIABLE = YES; |
| 1828 | IPHONEOS_DEPLOYMENT_TARGET = 3.0; | 1877 | IPHONEOS_DEPLOYMENT_TARGET = 3.0; |
| @@ -1847,7 +1896,7 @@ | |||
| 1847 | "GCC_THUMB_SUPPORT[arch=armv6]" = NO; | 1896 | "GCC_THUMB_SUPPORT[arch=armv6]" = NO; |
| 1848 | "GCC_THUMB_SUPPORT[arch=armv7]" = YES; | 1897 | "GCC_THUMB_SUPPORT[arch=armv7]" = YES; |
| 1849 | GCC_UNROLL_LOOPS = YES; | 1898 | GCC_UNROLL_LOOPS = YES; |
| 1850 | GCC_VERSION = com.apple.compilers.llvmgcc42; | 1899 | GCC_VERSION = ""; |
| 1851 | GCC_WARN_ABOUT_RETURN_TYPE = YES; | 1900 | GCC_WARN_ABOUT_RETURN_TYPE = YES; |
| 1852 | GCC_WARN_UNUSED_VARIABLE = YES; | 1901 | GCC_WARN_UNUSED_VARIABLE = YES; |
| 1853 | IPHONEOS_DEPLOYMENT_TARGET = 3.0; | 1902 | IPHONEOS_DEPLOYMENT_TARGET = 3.0; |
| diff --git a/Classes/Cart.h b/Classes/Cart.h index 0ef1abf..302e5ec 100644 --- a/Classes/Cart.h +++ b/Classes/Cart.h | |||
| @@ -8,15 +8,20 @@ | |||
| 8 | 8 | ||
| 9 | #import <Foundation/Foundation.h> | 9 | #import <Foundation/Foundation.h> |
| 10 | #import "cocos2d.h" | 10 | #import "cocos2d.h" |
| 11 | #import "CartDelegate.h" | ||
| 11 | 12 | ||
| 12 | @interface Cart : NSObject { | 13 | @interface Cart : NSObject { |
| 13 | CCSprite* sprite; | 14 | CCSprite* sprite; |
| 14 | float accelX; | 15 | float accelX; |
| 15 | BOOL immobile; | 16 | BOOL immobile; |
| 17 | id<CartDelegate> delegate; | ||
| 18 | BOOL falling; | ||
| 16 | } | 19 | } |
| 17 | 20 | ||
| 18 | @property (readonly) CCSprite* sprite; | 21 | @property (readonly) CCSprite* sprite; |
| 19 | @property (assign) BOOL immobile; | 22 | @property (assign) BOOL immobile; |
| 23 | @property (nonatomic,retain) id<CartDelegate> delegate; | ||
| 24 | @property (assign) BOOL falling; | ||
| 20 | - (id)initWithSprite:(CCSprite*)sprite; | 25 | - (id)initWithSprite:(CCSprite*)sprite; |
| 21 | - (void)tick; | 26 | - (void)tick; |
| 22 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration; | 27 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration; |
| diff --git a/Classes/Cart.m b/Classes/Cart.m index 45c370c..cfe7ee7 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, immobile; | 13 | @synthesize sprite, immobile, delegate, falling; |
| 14 | 14 | ||
| 15 | - (id)initWithSprite:(CCSprite*)m_sprite | 15 | - (id)initWithSprite:(CCSprite*)m_sprite |
| 16 | { | 16 | { |
| @@ -20,6 +20,7 @@ | |||
| 20 | { | 20 | { |
| 21 | sprite = m_sprite; | 21 | sprite = m_sprite; |
| 22 | immobile = NO; | 22 | immobile = NO; |
| 23 | falling = NO; | ||
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | return self; | 26 | return self; |
| @@ -30,7 +31,27 @@ | |||
| 30 | if (!immobile) | 31 | if (!immobile) |
| 31 | { | 32 | { |
| 32 | // Move the cart based on acceleration gathered from accelerometer | 33 | // Move the cart based on acceleration gathered from accelerometer |
| 34 | CGPoint prevLoc = sprite.position; | ||
| 33 | sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y); | 35 | sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y); |
| 36 | |||
| 37 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartIsObstructed:)])) | ||
| 38 | { | ||
| 39 | if ([delegate cartIsObstructed:self]) | ||
| 40 | { | ||
| 41 | sprite.position = prevLoc; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | if (falling) | ||
| 46 | { | ||
| 47 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartShouldFall:)])) | ||
| 48 | { | ||
| 49 | int bottom = [delegate cartShouldFall:self]; | ||
| 50 | sprite.position = ccp(sprite.position.x, MAX(bottom, sprite.position.y-6)); | ||
| 51 | } else { | ||
| 52 | NSLog(@"Falling is set on a cart without a compatible game mode."); | ||
| 53 | } | ||
| 54 | } | ||
| 34 | } | 55 | } |
| 35 | } | 56 | } |
| 36 | 57 | ||
| diff --git a/Classes/CartDelegate.h b/Classes/CartDelegate.h new file mode 100644 index 0000000..8c37019 --- /dev/null +++ b/Classes/CartDelegate.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | // | ||
| 2 | // CartDelegate.h | ||
| 3 | // Cartographic | ||
| 4 | // | ||
| 5 | // Created by Starla Insigna on 8/27/11. | ||
| 6 | // Copyright 2011 Four Island. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import <Foundation/Foundation.h> | ||
| 10 | |||
| 11 | @class Cart; | ||
| 12 | |||
| 13 | @protocol CartDelegate <NSObject> | ||
| 14 | |||
| 15 | @optional | ||
| 16 | - (int)cartShouldFall:(Cart*)cart; | ||
| 17 | - (BOOL)cartIsObstructed:(Cart*)cart; | ||
| 18 | |||
| 19 | @end | ||
| diff --git a/Classes/Cart_CollectAppDelegate.m b/Classes/Cart_CollectAppDelegate.m index ba9d60b..1a6759c 100755 --- a/Classes/Cart_CollectAppDelegate.m +++ b/Classes/Cart_CollectAppDelegate.m | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | #import "RootViewController.h" | 14 | #import "RootViewController.h" |
| 15 | #import "MainMenuLayer.h" | 15 | #import "MainMenuLayer.h" |
| 16 | #import "TestFlight.h" | 16 | #import "TestFlight.h" |
| 17 | #import "CCNotifications.h" | ||
| 18 | #import "notificationDesign.h" | ||
| 17 | 19 | ||
| 18 | @implementation Cart_CollectAppDelegate | 20 | @implementation Cart_CollectAppDelegate |
| 19 | 21 | ||
| @@ -64,6 +66,8 @@ | |||
| 64 | 66 | ||
| 65 | 67 | ||
| 66 | CCDirector *director = [CCDirector sharedDirector]; | 68 | CCDirector *director = [CCDirector sharedDirector]; |
| 69 | CCNotifications* notifications = [CCNotifications sharedManager]; | ||
| 70 | [director setNotificationNode:notifications]; | ||
| 67 | 71 | ||
| 68 | // Init the View Controller | 72 | // Init the View Controller |
| 69 | viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; | 73 | viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; |
| diff --git a/Classes/ClassicGameMode.m b/Classes/ClassicGameMode.m index 88c52ce..b8fe636 100755 --- a/Classes/ClassicGameMode.m +++ b/Classes/ClassicGameMode.m | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #import "Rock.h" | 14 | #import "Rock.h" |
| 15 | #import "GameOverScene.h" | 15 | #import "GameOverScene.h" |
| 16 | #import "SimpleAudioEngine.h" | 16 | #import "SimpleAudioEngine.h" |
| 17 | #import "CCNotifications.h" | ||
| 17 | 18 | ||
| 18 | @implementation ClassicGameMode | 19 | @implementation ClassicGameMode |
| 19 | 20 | ||
| @@ -27,7 +28,7 @@ | |||
| 27 | { | 28 | { |
| 28 | [self unscheduleAllSelectors]; | 29 | [self unscheduleAllSelectors]; |
| 29 | 30 | ||
| 30 | [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverScene sceneWithScore:score]]]; | 31 | [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverScene sceneWithScore:score gameMode:@"Collect"]]]; |
| 31 | } else if (score > lastScore) | 32 | } else if (score > lastScore) |
| 32 | { | 33 | { |
| 33 | if ((lastScore < 6500) && (score >= 6500)) | 34 | if ((lastScore < 6500) && (score >= 6500)) |
| @@ -35,6 +36,17 @@ | |||
| 35 | [self unschedule:@selector(randomlyAddObject:)]; | 36 | [self unschedule:@selector(randomlyAddObject:)]; |
| 36 | [self schedule:@selector(randomlyAddObject:) interval:0.6f]; | 37 | [self schedule:@selector(randomlyAddObject:) interval:0.6f]; |
| 37 | addSpeed = 0.6f; | 38 | addSpeed = 0.6f; |
| 39 | } else if ((lastScore < 5000) && (score >= 5000)) | ||
| 40 | { | ||
| 41 | NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | ||
| 42 | |||
| 43 | if (![defaults boolForKey:@"unlockedJumpMode"]) | ||
| 44 | { | ||
| 45 | [[CCNotifications sharedManager] addWithTitle:@"Jump" message:@"You've unlocked a new game mode!" image:@"venice.png"]; | ||
| 46 | |||
| 47 | [defaults setBool:YES forKey:@"unlockedJumpMode"]; | ||
| 48 | [defaults synchronize]; | ||
| 49 | } | ||
| 38 | } else if ((lastScore < 4500) && (score >= 4500)) | 50 | } else if ((lastScore < 4500) && (score >= 4500)) |
| 39 | { | 51 | { |
| 40 | [self unschedule:@selector(randomlyAddObject:)]; | 52 | [self unschedule:@selector(randomlyAddObject:)]; |
| diff --git a/Classes/GameMode.h b/Classes/GameMode.h index 53ed9fc..0659a57 100644 --- a/Classes/GameMode.h +++ b/Classes/GameMode.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #define GAME_SCENE 436 | 12 | #define GAME_SCENE 436 |
| 13 | #define GAME_LAYER 437 | 13 | #define GAME_LAYER 437 |
| 14 | 14 | ||
| 15 | @interface GameMode : CCLayer <UIAlertViewDelegate> { | 15 | @interface GameMode : CCLayer <UIAlertViewDelegate, CartDelegate> { |
| 16 | NSMutableSet* objects; | 16 | NSMutableSet* objects; |
| 17 | int score; | 17 | int score; |
| 18 | int lives; | 18 | int lives; |
| diff --git a/Classes/GameMode.m b/Classes/GameMode.m index 8f695d1..f0eb02f 100644 --- a/Classes/GameMode.m +++ b/Classes/GameMode.m | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | cart = [[Cart alloc] initWithSprite:[CCSprite spriteWithFile:@"cart.png"]]; | 40 | cart = [[Cart alloc] initWithSprite:[CCSprite spriteWithFile:@"cart.png"]]; |
| 41 | cart.sprite.position = ccp(240, 22); | 41 | cart.sprite.position = ccp(240, 22); |
| 42 | cart.sprite.scale = 2; | 42 | cart.sprite.scale = 2; |
| 43 | cart.delegate = self; | ||
| 43 | [self addChild:cart.sprite]; | 44 | [self addChild:cart.sprite]; |
| 44 | 45 | ||
| 45 | scoreLabel = [CCLabelBMFont labelWithString:@"Score: 0" fntFile:@"helvetica2.fnt"]; | 46 | scoreLabel = [CCLabelBMFont labelWithString:@"Score: 0" fntFile:@"helvetica2.fnt"]; |
| @@ -84,13 +85,16 @@ | |||
| 84 | { | 85 | { |
| 85 | [cart tick]; | 86 | [cart tick]; |
| 86 | 87 | ||
| 88 | NSMutableSet* discardedObjects = [NSMutableSet set]; | ||
| 87 | for (FallingObject* object in objects) | 89 | for (FallingObject* object in objects) |
| 88 | { | 90 | { |
| 89 | if ([object tick]) | 91 | if ([object tick]) |
| 90 | { | 92 | { |
| 91 | [objects removeObject:object]; | 93 | [discardedObjects addObject:object]; |
| 92 | } | 94 | } |
| 93 | } | 95 | } |
| 96 | |||
| 97 | [objects minusSet:discardedObjects]; | ||
| 94 | } | 98 | } |
| 95 | 99 | ||
| 96 | - (BOOL)canPause | 100 | - (BOOL)canPause |
| diff --git a/Classes/GameModeSelectionLayer.m b/Classes/GameModeSelectionLayer.m index db08146..3fbf417 100644 --- a/Classes/GameModeSelectionLayer.m +++ b/Classes/GameModeSelectionLayer.m | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #import "TutorialMode.h" | 14 | #import "TutorialMode.h" |
| 15 | #import "ClassicGameMode.h" | 15 | #import "ClassicGameMode.h" |
| 16 | #import "NMPanelMenu.h" | 16 | #import "NMPanelMenu.h" |
| 17 | #import "JumpGameMode.h" | ||
| 17 | 18 | ||
| 18 | @implementation GameModeSelectionLayer | 19 | @implementation GameModeSelectionLayer |
| 19 | 20 | ||
| @@ -56,6 +57,17 @@ | |||
| 56 | 57 | ||
| 57 | [gameModes addObject:collectSelection]; | 58 | [gameModes addObject:collectSelection]; |
| 58 | 59 | ||
| 60 | GameModeSelection* jumpSelection; | ||
| 61 | |||
| 62 | if ([defaults boolForKey:@"unlockedJumpMode"]) | ||
| 63 | { | ||
| 64 | jumpSelection = [GameModeSelection selectionWithName:@"Jump" location:@"Venice" filename:@"venice" unlocked:YES]; | ||
| 65 | } else { | ||
| 66 | jumpSelection = [GameModeSelection selectionWithName:@"Jump" location:@"Venice" filename:@"venice" unlockCondition:@"Get 5000 points in Collect!"]; | ||
| 67 | } | ||
| 68 | |||
| 69 | [gameModes addObject:jumpSelection]; | ||
| 70 | |||
| 59 | CCMenu* menu = [CCMenu menuWithItems:nil]; | 71 | CCMenu* menu = [CCMenu menuWithItems:nil]; |
| 60 | float onePanelWide = 128; | 72 | float onePanelWide = 128; |
| 61 | float padding = 15; | 73 | float padding = 15; |
| @@ -126,6 +138,9 @@ | |||
| 126 | } else if ([gameMode.name isEqual:@"Collect"]) | 138 | } else if ([gameMode.name isEqual:@"Collect"]) |
| 127 | { | 139 | { |
| 128 | [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; | 140 | [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; |
| 141 | } else if ([gameMode.name isEqual:@"Jump"]) | ||
| 142 | { | ||
| 143 | [[CCDirector sharedDirector] replaceScene:[JumpGameMode scene]]; | ||
| 129 | } | 144 | } |
| 130 | } | 145 | } |
| 131 | 146 | ||
| diff --git a/Classes/GameOverScene.h b/Classes/GameOverScene.h index ef63aa7..a91286e 100755 --- a/Classes/GameOverScene.h +++ b/Classes/GameOverScene.h | |||
| @@ -18,10 +18,11 @@ | |||
| 18 | UIActivityIndicatorView* activityIndicator; | 18 | UIActivityIndicatorView* activityIndicator; |
| 19 | UIButton* backButton; | 19 | UIButton* backButton; |
| 20 | int score; | 20 | int score; |
| 21 | NSString* gameMode; | ||
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | + (GameOverScene*)sceneWithScore:(int)score; | 24 | + (GameOverScene*)sceneWithScore:(int)score gameMode:(NSString*)gameMode; |
| 24 | - (id)initWithScore:(int)score; | 25 | - (id)initWithScore:(int)score gameMode:(NSString*)gameMode; |
| 25 | - (void)newgame; | 26 | - (void)newgame; |
| 26 | - (void)submitScore; | 27 | - (void)submitScore; |
| 27 | - (void)exit; | 28 | - (void)exit; |
| diff --git a/Classes/GameOverScene.m b/Classes/GameOverScene.m index 94236ff..f2dca0b 100755 --- a/Classes/GameOverScene.m +++ b/Classes/GameOverScene.m | |||
| @@ -14,12 +14,12 @@ | |||
| 14 | 14 | ||
| 15 | @implementation GameOverScene | 15 | @implementation GameOverScene |
| 16 | 16 | ||
| 17 | + (GameOverScene*)sceneWithScore:(int)score | 17 | + (GameOverScene*)sceneWithScore:(int)score gameMode:(NSString*)gameMode |
| 18 | { | 18 | { |
| 19 | return [[[GameOverScene alloc] initWithScore:score] autorelease]; | 19 | return [[[GameOverScene alloc] initWithScore:score gameMode:gameMode] autorelease]; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | - (id)initWithScore:(int)score2 | 22 | - (id)initWithScore:(int)score2 gameMode:(NSString*)gameMode2 |
| 23 | { | 23 | { |
| 24 | self = [super init]; | 24 | self = [super init]; |
| 25 | 25 | ||
| @@ -36,6 +36,7 @@ | |||
| 36 | [theLayer addChild:backgroundImage z:0]; | 36 | [theLayer addChild:backgroundImage z:0]; |
| 37 | 37 | ||
| 38 | score = score2; | 38 | score = score2; |
| 39 | gameMode = gameMode2; | ||
| 39 | 40 | ||
| 40 | movingLayer = [[UIView alloc] initWithFrame:CGRectMake(0, -320, 480, 320)]; | 41 | movingLayer = [[UIView alloc] initWithFrame:CGRectMake(0, -320, 480, 320)]; |
| 41 | movingLayer.backgroundColor = [UIColor clearColor]; | 42 | movingLayer.backgroundColor = [UIColor clearColor]; |
| @@ -88,7 +89,7 @@ | |||
| 88 | textField.enabled = NO; | 89 | textField.enabled = NO; |
| 89 | submitSwitch.enabled = NO; | 90 | submitSwitch.enabled = NO; |
| 90 | 91 | ||
| 91 | const char* sqlQuery = [[NSString stringWithFormat:@"INSERT INTO highscores (name, score, gameMode) VALUES (\"%@\",%d,\"Collect\")", [textField text], score] UTF8String]; | 92 | const char* sqlQuery = [[NSString stringWithFormat:@"INSERT INTO highscores (name, score, gameMode) VALUES (\"%@\",%d,\"%@\")", [textField text], score, gameMode] UTF8String]; |
| 92 | sqlite3_stmt* compiled_statement; | 93 | sqlite3_stmt* compiled_statement; |
| 93 | 94 | ||
| 94 | if (sqlite3_prepare_v2([Cart_CollectAppDelegate database], sqlQuery, -1, &compiled_statement, NULL) == SQLITE_OK) | 95 | if (sqlite3_prepare_v2([Cart_CollectAppDelegate database], sqlQuery, -1, &compiled_statement, NULL) == SQLITE_OK) |
| diff --git a/Classes/JumpGameMode.h b/Classes/JumpGameMode.h new file mode 100644 index 0000000..f6a31f8 --- /dev/null +++ b/Classes/JumpGameMode.h | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | // | ||
| 2 | // JumpGameMode.h | ||
| 3 | // Cart Collect | ||
| 4 | // | ||
| 5 | // Created by Starla Insigna on 8/17/11. | ||
| 6 | // Copyright 2011 Four Island. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import "GameMode.h" | ||
| 10 | |||
| 11 | @class LedgeFactory; | ||
| 12 | |||
| 13 | @interface JumpGameMode : GameMode <CCStandardTouchDelegate> { | ||
| 14 | CCSprite* water; | ||
| 15 | int waterTick; | ||
| 16 | BOOL wave; | ||
| 17 | CGPoint gestureStartPoint; | ||
| 18 | int jumpTick; | ||
| 19 | BOOL jump; | ||
| 20 | float expectedAngle; | ||
| 21 | NSMutableSet* ledges; | ||
| 22 | LedgeFactory* factory; | ||
| 23 | int ledgeScrollSpeed; | ||
| 24 | float ledgeAccelerationRate; | ||
| 25 | float addSpeed; | ||
| 26 | } | ||
| 27 | |||
| 28 | - (void)accelerateLedgeScrolling; | ||
| 29 | - (void)randomlyAddObject:(ccTime)dt; | ||
| 30 | - (void)incrementScore; | ||
| 31 | |||
| 32 | @end | ||
| diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m new file mode 100644 index 0000000..bac3fa5 --- /dev/null +++ b/Classes/JumpGameMode.m | |||
| @@ -0,0 +1,437 @@ | |||
| 1 | // | ||
| 2 | // JumpGameMode.m | ||
| 3 | // Cart Collect | ||
| 4 | // | ||
| 5 | // Created by Starla Insigna on 8/17/11. | ||
| 6 | // Copyright 2011 Four Island. All rights reserved. | ||
| 7 | // | ||
| 8 | |||
| 9 | #import "JumpGameMode.h" | ||
| 10 | #import "SimpleAudioEngine.h" | ||
| 11 | #import "FallingObject.h" | ||
| 12 | #import "Cherry.h" | ||
| 13 | #import "Bottle.h" | ||
| 14 | #import "OneUp.h" | ||
| 15 | #import "Rock.h" | ||
| 16 | #import "GameOverScene.h" | ||
| 17 | |||
| 18 | #define kMinimumGestureLength 25 | ||
| 19 | |||
| 20 | @interface LedgeFactory : NSObject { | ||
| 21 | UIImage* leftSprite; | ||
| 22 | UIImage* midSprite; | ||
| 23 | UIImage* rightSprite; | ||
| 24 | UIImage* singleSprite; | ||
| 25 | } | ||
| 26 | |||
| 27 | - (id)init; | ||
| 28 | - (UIImage*)createLedgeWithWidth:(int)width height:(int)height; | ||
| 29 | |||
| 30 | @end | ||
| 31 | |||
| 32 | @implementation JumpGameMode | ||
| 33 | |||
| 34 | - (id)init | ||
| 35 | { | ||
| 36 | self = [super init]; | ||
| 37 | |||
| 38 | if (nil != self) | ||
| 39 | { | ||
| 40 | CCSprite* backgroundImage = [CCSprite spriteWithFile:@"SeaBeach.png"]; | ||
| 41 | backgroundImage.position = ccp(240, 160); | ||
| 42 | [self addChild:backgroundImage z:-1]; | ||
| 43 | |||
| 44 | water = [CCSprite spriteWithFile:@"water.png"]; | ||
| 45 | water.position = ccp(240, -60); | ||
| 46 | [self addChild:water]; | ||
| 47 | |||
| 48 | cart.sprite.position = ccp(120, 22+64); //86 | ||
| 49 | cart.falling = YES; | ||
| 50 | cart.delegate = self; | ||
| 51 | |||
| 52 | self.isTouchEnabled = YES; | ||
| 53 | |||
| 54 | waterTick = 0; | ||
| 55 | wave = NO; | ||
| 56 | |||
| 57 | factory = [[LedgeFactory alloc] init]; | ||
| 58 | ledges = [[NSMutableSet alloc] init]; | ||
| 59 | CCSprite* ledge = [CCSprite spriteWithTexture:[[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:6 height:2]]]; | ||
| 60 | ledge.position = ccp(80, 32); | ||
| 61 | [self addChild:ledge]; | ||
| 62 | [ledges addObject:ledge]; | ||
| 63 | |||
| 64 | ledgeScrollSpeed = 0; | ||
| 65 | ledgeAccelerationRate = 20.0f; | ||
| 66 | addSpeed = 2.5f; | ||
| 67 | } | ||
| 68 | |||
| 69 | return self; | ||
| 70 | } | ||
| 71 | |||
| 72 | - (void)onEnterTransitionDidFinish | ||
| 73 | { | ||
| 74 | [super onEnterTransitionDidFinish]; | ||
| 75 | |||
| 76 | [self schedule:@selector(accelerateLedgeScrolling) interval:ledgeAccelerationRate]; | ||
| 77 | [self schedule:@selector(randomlyAddObject:) interval:addSpeed]; | ||
| 78 | [self schedule:@selector(incrementScore) interval:1.0f]; | ||
| 79 | |||
| 80 | [self scheduleDelayedAction:^{ | ||
| 81 | wave = YES; | ||
| 82 | } delay:60.0f]; | ||
| 83 | } | ||
| 84 | |||
| 85 | - (void)tick:(ccTime)dt | ||
| 86 | { | ||
| 87 | NSMutableSet* discardedSet = [NSMutableSet set]; | ||
| 88 | int rightmost = 0; | ||
| 89 | int rightwidth = 0; | ||
| 90 | |||
| 91 | for (CCSprite* sprite in ledges) | ||
| 92 | { | ||
| 93 | sprite.position = ccp(sprite.position.x - ledgeScrollSpeed, sprite.position.y); | ||
| 94 | |||
| 95 | if ((sprite.position.x + sprite.boundingBox.size.width/2) < 0) | ||
| 96 | { | ||
| 97 | [discardedSet addObject:sprite]; | ||
| 98 | [self removeChild:sprite cleanup:YES]; | ||
| 99 | } | ||
| 100 | |||
| 101 | if (sprite.position.x > rightmost) | ||
| 102 | { | ||
| 103 | rightmost = sprite.position.x; | ||
| 104 | rightwidth = sprite.boundingBox.size.width/2; | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | for (FallingObject* object in objects) | ||
| 109 | { | ||
| 110 | if (waterTick > 0) | ||
| 111 | { | ||
| 112 | object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11)); | ||
| 113 | } else { | ||
| 114 | object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y); | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | [ledges minusSet:discardedSet]; | ||
| 119 | |||
| 120 | if (rightmost <= 480) | ||
| 121 | { | ||
| 122 | CCSprite* ledge = [CCSprite spriteWithTexture:[[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:(arc4random() % 10) height:2]]]; | ||
| 123 | ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64, 32); | ||
| 124 | [self addChild:ledge]; | ||
| 125 | [ledges addObject:ledge]; | ||
| 126 | } | ||
| 127 | |||
| 128 | if ([self cartIsObstructed:cart]) | ||
| 129 | { | ||
| 130 | cart.sprite.position = ccp(cart.sprite.position.x-ledgeScrollSpeed, cart.sprite.position.y); | ||
| 131 | } | ||
| 132 | |||
| 133 | int lastScore = score; | ||
| 134 | |||
| 135 | [super tick:dt]; | ||
| 136 | |||
| 137 | if (cart.sprite.position.y == (0-cart.sprite.boundingBox.size.height/2)) | ||
| 138 | { | ||
| 139 | [self setLives:self.lives-1]; | ||
| 140 | |||
| 141 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; | ||
| 142 | |||
| 143 | cart.sprite.position = ccp(cart.sprite.position.x, 320 + cart.sprite.boundingBox.size.height/2); | ||
| 144 | } | ||
| 145 | |||
| 146 | if (lives == 0) | ||
| 147 | { | ||
| 148 | [self unscheduleAllSelectors]; | ||
| 149 | |||
| 150 | [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInT transitionWithDuration:1.5f scene:[GameOverScene sceneWithScore:score gameMode:@"Jump"]]]; | ||
| 151 | } else if (score > lastScore) | ||
| 152 | { | ||
| 153 | if ((lastScore < 240) && (score >= 240)) | ||
| 154 | { | ||
| 155 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 156 | [self schedule:@selector(randomlyAddObject:) interval:0.6f]; | ||
| 157 | addSpeed = 0.6f; | ||
| 158 | } else if ((lastScore < 180) && (score >= 180)) | ||
| 159 | { | ||
| 160 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 161 | [self schedule:@selector(randomlyAddObject:) interval:0.7f]; | ||
| 162 | addSpeed = 0.7f; | ||
| 163 | } else if ((lastScore < 120) && (score >= 120)) | ||
| 164 | { | ||
| 165 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 166 | [self schedule:@selector(randomlyAddObject:) interval:0.8f]; | ||
| 167 | addSpeed = 0.8f; | ||
| 168 | } else if ((lastScore < 90) && (score >= 90)) | ||
| 169 | { | ||
| 170 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 171 | [self schedule:@selector(randomlyAddObject:) interval:0.9f]; | ||
| 172 | addSpeed = 0.9f; | ||
| 173 | } else if ((lastScore < 60) && (score >= 60)) | ||
| 174 | { | ||
| 175 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 176 | [self schedule:@selector(randomlyAddObject:) interval:1.0f]; | ||
| 177 | addSpeed = 1.0f; | ||
| 178 | } else if ((lastScore < 30) && (score >= 30)) | ||
| 179 | { | ||
| 180 | [self unschedule:@selector(randomlyAddObject:)]; | ||
| 181 | [self schedule:@selector(randomlyAddObject:) interval:2.0f]; | ||
| 182 | addSpeed = 2.0f; | ||
| 183 | } | ||
| 184 | } | ||
| 185 | |||
| 186 | if (wave) | ||
| 187 | { | ||
| 188 | waterTick++; | ||
| 189 | |||
| 190 | water.position = ccp(240, 140 * sin(waterTick / (36 * M_PI)) - 60); | ||
| 191 | |||
| 192 | if (waterTick == 180) | ||
| 193 | { | ||
| 194 | wave = NO; | ||
| 195 | |||
| 196 | [self scheduleDelayedAction:^{ | ||
| 197 | wave = YES; | ||
| 198 | } delay:10.0f]; | ||
| 199 | } else if (waterTick == 360) | ||
| 200 | { | ||
| 201 | wave = NO; | ||
| 202 | waterTick = 0; | ||
| 203 | |||
| 204 | [self scheduleDelayedAction:^{ | ||
| 205 | wave = YES; | ||
| 206 | } delay:60.0f]; | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | if (jump) | ||
| 211 | { | ||
| 212 | jumpTick++; | ||
| 213 | |||
| 214 | cart.sprite.position = ccp(cart.sprite.position.x, MAX(100 * sin(jumpTick / (2 * M_PI)) + 86, water.position.y+80+11)); | ||
| 215 | |||
| 216 | if (jumpTick == 20) | ||
| 217 | { | ||
| 218 | jump = NO; | ||
| 219 | jumpTick = 0; | ||
| 220 | cart.falling = YES; | ||
| 221 | } | ||
| 222 | } | ||
| 223 | } | ||
| 224 | |||
| 225 | - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event | ||
| 226 | { | ||
| 227 | UITouch* touch = [touches anyObject]; | ||
| 228 | gestureStartPoint = [touch locationInView:nil]; | ||
| 229 | } | ||
| 230 | |||
| 231 | - (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event | ||
| 232 | { | ||
| 233 | UITouch* touch = [touches anyObject]; | ||
| 234 | CGPoint gestureCurrentPosition = [touch locationInView:nil]; | ||
| 235 | CGFloat angle = atan2f(gestureCurrentPosition.y - gestureStartPoint.y, gestureCurrentPosition.x - gestureStartPoint.x); | ||
| 236 | CGFloat distance = sqrt(powf((gestureCurrentPosition.x - gestureStartPoint.x),2) + powf((gestureCurrentPosition.y - gestureStartPoint.y),2)); | ||
| 237 | |||
| 238 | if ((distance >= kMinimumGestureLength) && (angle >= expectedAngle - M_PI_4) && (angle <= expectedAngle + M_PI_4) && ((cart.sprite.position.y >= 80) && (cart.sprite.position.y <= 90))) | ||
| 239 | { | ||
| 240 | jump = YES; | ||
| 241 | cart.falling = NO; | ||
| 242 | } | ||
| 243 | } | ||
| 244 | |||
| 245 | - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration | ||
| 246 | { | ||
| 247 | [super accelerometer:accelerometer didAccelerate:acceleration]; | ||
| 248 | |||
| 249 | expectedAngle = acceleration.y*M_PI_2; | ||
| 250 | } | ||
| 251 | |||
| 252 | - (int)cartShouldFall:(Cart *)m_cart | ||
| 253 | { | ||
| 254 | int bottom = 0-m_cart.sprite.boundingBox.size.height/2; | ||
| 255 | |||
| 256 | for (CCSprite* sprite in ledges) | ||
| 257 | { | ||
| 258 | CGSize first = [m_cart.sprite boundingBox].size; | ||
| 259 | CGSize second = [sprite boundingBox].size; | ||
| 260 | |||
| 261 | if (m_cart.sprite.position.x > (sprite.position.x - second.width/2 - first.width/2)) | ||
| 262 | { | ||
| 263 | if (m_cart.sprite.position.x < (sprite.position.x + second.width/2 + first.width/2)) | ||
| 264 | { | ||
| 265 | bottom = sprite.position.y + second.height/2 + first.height/2; | ||
| 266 | break; | ||
| 267 | } | ||
| 268 | } | ||
| 269 | } | ||
| 270 | |||
| 271 | if (waterTick > 0) | ||
| 272 | { | ||
| 273 | bottom = MAX(water.position.y+80+11, bottom); | ||
| 274 | } | ||
| 275 | |||
| 276 | return bottom; | ||
| 277 | } | ||
| 278 | |||
| 279 | - (BOOL)cartIsObstructed:(Cart *)m_cart | ||
| 280 | { | ||
| 281 | for (CCSprite* sprite in ledges) | ||
| 282 | { | ||
| 283 | CGSize first = [m_cart.sprite boundingBox].size; | ||
| 284 | CGSize second = [sprite boundingBox].size; | ||
| 285 | |||
| 286 | if (m_cart.sprite.position.x > (sprite.position.x - second.width/2 - first.width/2)) | ||
| 287 | { | ||
| 288 | if (m_cart.sprite.position.x < (sprite.position.x + second.width/2 + first.width/2)) | ||
| 289 | { | ||
| 290 | if (m_cart.sprite.position.y > (sprite.position.y - second.height/2 - first.height/2)) | ||
| 291 | { | ||
| 292 | if (m_cart.sprite.position.y < (sprite.position.y + second.height/2 + first.height/2)) | ||
| 293 | { | ||
| 294 | return YES; | ||
| 295 | } | ||
| 296 | } | ||
| 297 | } | ||
| 298 | } | ||
| 299 | } | ||
| 300 | |||
| 301 | return NO; | ||
| 302 | } | ||
| 303 | |||
| 304 | - (void)accelerateLedgeScrolling | ||
| 305 | { | ||
| 306 | [self unschedule:@selector(accelerateLedgeScrolling)]; | ||
| 307 | |||
| 308 | ledgeScrollSpeed += 2; | ||
| 309 | ledgeAccelerationRate *= 2; | ||
| 310 | |||
| 311 | [self schedule:@selector(accelerateLedgeScrolling) interval:ledgeAccelerationRate]; | ||
| 312 | } | ||
| 313 | |||
| 314 | - (void)randomlyAddObject:(ccTime)dt | ||
| 315 | { | ||
| 316 | FallingObject* object; | ||
| 317 | |||
| 318 | if (score < 120) | ||
| 319 | { | ||
| 320 | int randomval = arc4random()%100; | ||
| 321 | |||
| 322 | if (randomval < 80) | ||
| 323 | { | ||
| 324 | object = [[Rock alloc] init]; | ||
| 325 | } else { | ||
| 326 | object = [[OneUp alloc] init]; | ||
| 327 | } | ||
| 328 | } else { | ||
| 329 | int randomval = arc4random()%100; | ||
| 330 | |||
| 331 | if (randomval < 70) | ||
| 332 | { | ||
| 333 | object = [[Rock alloc] init]; | ||
| 334 | } else { | ||
| 335 | object = [[OneUp alloc] init]; | ||
| 336 | } | ||
| 337 | } | ||
| 338 | |||
| 339 | int objectX = arc4random()%448+16; | ||
| 340 | object.sprite.position = ccp(objectX, 360); | ||
| 341 | object.sprite.scale = 1; | ||
| 342 | [self addChild:object.sprite]; | ||
| 343 | |||
| 344 | [objects addObject:object]; | ||
| 345 | [object release]; | ||
| 346 | |||
| 347 | if (score >= 120) | ||
| 348 | { | ||
| 349 | if (arc4random() % 100 > 80) | ||
| 350 | { | ||
| 351 | object = [[Rock alloc] init]; | ||
| 352 | |||
| 353 | objectX = arc4random()%448+16; | ||
| 354 | object.sprite.position = ccp(objectX, 360); | ||
| 355 | object.sprite.scale = 1; | ||
| 356 | [self addChild:object.sprite]; | ||
| 357 | |||
| 358 | [objects addObject:object]; | ||
| 359 | [object release]; | ||
| 360 | } | ||
| 361 | } | ||
| 362 | |||
| 363 | if (score >= 240) | ||
| 364 | { | ||
| 365 | if (arc4random() % 100 > 80) | ||
| 366 | { | ||
| 367 | object = [[Rock alloc] init]; | ||
| 368 | |||
| 369 | objectX = arc4random()%448+16; | ||
| 370 | object.sprite.position = ccp(objectX, 360); | ||
| 371 | object.sprite.scale = 1; | ||
| 372 | [self addChild:object.sprite]; | ||
| 373 | |||
| 374 | [objects addObject:object]; | ||
| 375 | [object release]; | ||
| 376 | } | ||
| 377 | } | ||
| 378 | } | ||
| 379 | |||
| 380 | - (void)incrementScore | ||
| 381 | { | ||
| 382 | [self setScore:self.score+1]; | ||
| 383 | } | ||
| 384 | |||
| 385 | @end | ||
| 386 | |||
| 387 | @implementation LedgeFactory | ||
| 388 | |||
| 389 | - (id)init | ||
| 390 | { | ||
| 391 | self = [super init]; | ||
| 392 | |||
| 393 | CGImageRef framestuff = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ledge" ofType:@"png"]] CGImage]; | ||
| 394 | CGImageRef leftRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 0, 32, 32)); | ||
| 395 | CGImageRef midRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(32, 0, 32, 32)); | ||
| 396 | CGImageRef rightRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(64, 0, 32, 32)); | ||
| 397 | CGImageRef singleRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(96, 0, 32, 32)); | ||
| 398 | leftSprite = [[UIImage alloc] initWithCGImage:leftRef]; | ||
| 399 | midSprite = [[UIImage alloc] initWithCGImage:midRef]; | ||
| 400 | rightSprite = [[UIImage alloc] initWithCGImage:rightRef]; | ||
| 401 | singleSprite = [[UIImage alloc] initWithCGImage:singleRef]; | ||
| 402 | CGImageRelease(leftRef); | ||
| 403 | CGImageRelease(midRef); | ||
| 404 | CGImageRelease(rightRef); | ||
| 405 | CGImageRelease(singleRef); | ||
| 406 | |||
| 407 | return self; | ||
| 408 | } | ||
| 409 | |||
| 410 | - (UIImage*)createLedgeWithWidth:(int)width height:(int)height | ||
| 411 | { | ||
| 412 | UIGraphicsBeginImageContext(CGSizeMake(width*32, height*32)); | ||
| 413 | |||
| 414 | for (int y=0; y<height; y++) | ||
| 415 | { | ||
| 416 | if (width == 1) | ||
| 417 | { | ||
| 418 | [singleSprite drawInRect:CGRectMake(0, y*32, 32, 32)]; | ||
| 419 | } else { | ||
| 420 | [leftSprite drawInRect:CGRectMake(0, y*32, 32, 32)]; | ||
| 421 | |||
| 422 | for (int x=1; x<(width-1); x++) | ||
| 423 | { | ||
| 424 | [midSprite drawInRect:CGRectMake(x*32, y*32, 32, 32)]; | ||
| 425 | } | ||
| 426 | |||
| 427 | [rightSprite drawInRect:CGRectMake((width-1)*32, y*32, 32, 32)]; | ||
| 428 | } | ||
| 429 | } | ||
| 430 | |||
| 431 | UIImage* result = UIGraphicsGetImageFromCurrentImageContext(); | ||
| 432 | UIGraphicsEndImageContext(); | ||
| 433 | |||
| 434 | return result; | ||
| 435 | } | ||
| 436 | |||
| 437 | @end \ No newline at end of file | ||
| diff --git a/Resources/jump.png b/Resources/jump.png new file mode 100644 index 0000000..4546088 --- /dev/null +++ b/Resources/jump.png | |||
| Binary files differ | |||
| diff --git a/Resources/jump2.png b/Resources/jump2.png new file mode 100644 index 0000000..3e83046 --- /dev/null +++ b/Resources/jump2.png | |||
| Binary files differ | |||
| diff --git a/Resources/ledge.png b/Resources/ledge.png new file mode 100644 index 0000000..0729a69 --- /dev/null +++ b/Resources/ledge.png | |||
| Binary files differ | |||
| diff --git a/Resources/venice.png b/Resources/venice.png new file mode 100644 index 0000000..512c2b4 --- /dev/null +++ b/Resources/venice.png | |||
| Binary files differ | |||
| diff --git a/Resources/water.png b/Resources/water.png new file mode 100644 index 0000000..bf4ff13 --- /dev/null +++ b/Resources/water.png | |||
| Binary files differ | |||
| diff --git a/libs/cocos2d/CCNotifications.h b/libs/cocos2d/CCNotifications.h new file mode 100755 index 0000000..8609801 --- /dev/null +++ b/libs/cocos2d/CCNotifications.h | |||
| @@ -0,0 +1,141 @@ | |||
| 1 | /* | ||
| 2 | * CCNotifications | ||
| 3 | * | ||
| 4 | * Copyright (c) 2010 ForzeField Studios S.L. | ||
| 5 | * http://forzefield.com | ||
| 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 <Foundation/Foundation.h> | ||
| 28 | #import "cocos2d.h" | ||
| 29 | |||
| 30 | #define KNOTIFICATIONMIN_SCALE 0.0001f | ||
| 31 | |||
| 32 | @interface ccNotificationData : NSObject | ||
| 33 | { | ||
| 34 | NSString *title_; | ||
| 35 | NSString *message_; | ||
| 36 | id media_; | ||
| 37 | int mediaType_; | ||
| 38 | int tag_; | ||
| 39 | BOOL animated_; | ||
| 40 | } | ||
| 41 | @property(nonatomic, retain) NSString *title; | ||
| 42 | @property(nonatomic, retain) NSString *message; | ||
| 43 | @property(nonatomic, retain) id media; | ||
| 44 | @property(nonatomic, readwrite, assign) int mediaType; | ||
| 45 | @property(nonatomic, readwrite, assign) int tag; | ||
| 46 | @property(nonatomic, readwrite, assign) BOOL animated; | ||
| 47 | |||
| 48 | @end | ||
| 49 | |||
| 50 | @protocol CCNotificationsDelegate <NSObject> | ||
| 51 | @optional | ||
| 52 | - (void) notification:(ccNotificationData*)notification newState:(char)state; | ||
| 53 | - (BOOL) touched:(int)tag; | ||
| 54 | - (void) notificationChangeState:(char)state tag:(int)tag DEPRECATED_ATTRIBUTE; | ||
| 55 | @end | ||
| 56 | |||
| 57 | @protocol CCNotificationDesignProtocol <NSObject> | ||
| 58 | - (void) setTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture; | ||
| 59 | @end | ||
| 60 | |||
| 61 | enum | ||
| 62 | { | ||
| 63 | kCCNotificationStateHide, | ||
| 64 | kCCNotificationStateAnimationOut, | ||
| 65 | kCCNotificationStateShowing, | ||
| 66 | kCCNotificationStateAnimationIn, | ||
| 67 | }; | ||
| 68 | |||
| 69 | enum | ||
| 70 | { | ||
| 71 | kCCNotificationPositionBottom, | ||
| 72 | kCCNotificationPositionTop, | ||
| 73 | }; | ||
| 74 | |||
| 75 | enum | ||
| 76 | { | ||
| 77 | kCCNotificationAnimationMovement, | ||
| 78 | kCCNotificationAnimationScale, | ||
| 79 | }; | ||
| 80 | |||
| 81 | enum | ||
| 82 | { | ||
| 83 | kCCNotificationMediaPath, | ||
| 84 | kCCNotificationMediaTexture, | ||
| 85 | }; | ||
| 86 | |||
| 87 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED | ||
| 88 | @interface CCNotifications : NSObject <CCStandardTouchDelegate> | ||
| 89 | #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) | ||
| 90 | @interface CCNotifications : NSObject | ||
| 91 | #endif | ||
| 92 | { | ||
| 93 | id <CCNotificationsDelegate> delegate_; | ||
| 94 | CCNode <CCNotificationDesignProtocol> *template_; | ||
| 95 | char state_; | ||
| 96 | char position_; | ||
| 97 | ccTime showingTime_; | ||
| 98 | ccTime timeAnimationIn_; | ||
| 99 | ccTime timeAnimationOut_; | ||
| 100 | char typeAnimationIn_; | ||
| 101 | char typeAnimationOut_; | ||
| 102 | |||
| 103 | //Caching | ||
| 104 | CCArray *cachedNotifications_; | ||
| 105 | ccNotificationData *currentNotification_; | ||
| 106 | |||
| 107 | CCActionInterval *animationIn_; | ||
| 108 | CCActionInterval *animationOut_; | ||
| 109 | } | ||
| 110 | @property(nonatomic, retain) id <CCNotificationsDelegate> delegate; | ||
| 111 | @property(nonatomic, retain) CCNode <CCNotificationDesignProtocol> *notificationDesign; | ||
| 112 | @property(nonatomic, retain) CCActionInterval *animationIn; | ||
| 113 | @property(nonatomic, retain) CCActionInterval *animationOut; | ||
| 114 | @property(nonatomic, retain) ccNotificationData *currentNotification; | ||
| 115 | @property(nonatomic, readwrite, assign) char position; | ||
| 116 | @property(nonatomic, readwrite, assign) ccTime showingTime; | ||
| 117 | |||
| 118 | + (CCNotifications *) sharedManager; | ||
| 119 | + (void) purgeSharedManager; | ||
| 120 | + (id) systemWithTemplate:(CCNode <CCNotificationDesignProtocol> *)notifications; | ||
| 121 | |||
| 122 | - (id) initWithTemplate:(CCNode <CCNotificationDesignProtocol> *)templates; | ||
| 123 | - (void) setAnimationIn:(char)type time:(ccTime)time; | ||
| 124 | - (void) setAnimationOut:(char)type time:(ccTime)time; | ||
| 125 | - (void) setAnimation:(char)type time:(ccTime)time; | ||
| 126 | - (void) updateAnimations; | ||
| 127 | |||
| 128 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image tag:(int)tag animate:(BOOL)animate waitUntilDone:(BOOL)isCached; | ||
| 129 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture tag:(int)tag animate:(BOOL)animate waitUntilDone:(BOOL)isCached; | ||
| 130 | |||
| 131 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image tag:(int)tag animate:(BOOL)animate; | ||
| 132 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture tag:(int)tag animate:(BOOL)animate; | ||
| 133 | |||
| 134 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image; | ||
| 135 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture; | ||
| 136 | |||
| 137 | - (void) addSafelyWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image tag:(int)tag animate:(BOOL)animate DEPRECATED_ATTRIBUTE; | ||
| 138 | |||
| 139 | |||
| 140 | - (void) visit; | ||
| 141 | @end \ No newline at end of file | ||
| diff --git a/libs/cocos2d/CCNotifications.m b/libs/cocos2d/CCNotifications.m new file mode 100755 index 0000000..235a6a0 --- /dev/null +++ b/libs/cocos2d/CCNotifications.m | |||
| @@ -0,0 +1,494 @@ | |||
| 1 | /* | ||
| 2 | * CCNotifications | ||
| 3 | * | ||
| 4 | * Copyright (c) 2010 ForzeField Studios S.L. | ||
| 5 | * http://forzefield.com | ||
| 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 "CCNotifications.h" | ||
| 29 | #import "CCArray.h" | ||
| 30 | #import "notificationDesign.h" | ||
| 31 | |||
| 32 | |||
| 33 | @implementation ccNotificationData | ||
| 34 | @synthesize title = title_; | ||
| 35 | @synthesize message = message_; | ||
| 36 | @synthesize media = media_; | ||
| 37 | @synthesize mediaType = mediaType_; | ||
| 38 | @synthesize tag = tag_; | ||
| 39 | @synthesize animated = animated_; | ||
| 40 | |||
| 41 | |||
| 42 | - (void) dealloc | ||
| 43 | { | ||
| 44 | [self setTitle:nil]; | ||
| 45 | [self setMessage:nil]; | ||
| 46 | [self setMedia:nil]; | ||
| 47 | [super dealloc]; | ||
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | @end | ||
| 52 | |||
| 53 | @interface CCNotifications (Private) | ||
| 54 | |||
| 55 | - (void) _updateAnimationIn; | ||
| 56 | - (void) _updateAnimationOut; | ||
| 57 | - (CCActionInterval*) _animation:(char)type time:(ccTime)time; | ||
| 58 | - (void) _showNotification; | ||
| 59 | - (void) _addNotificationToArray:(ccNotificationData*)data cached:(BOOL)isCached; | ||
| 60 | - (void) _startScheduler; | ||
| 61 | - (void) _hideNotification; | ||
| 62 | - (void) _hideNotificationScheduler; | ||
| 63 | - (void) registerWithTouchDispatcher; | ||
| 64 | - (void) _setState:(char)states; | ||
| 65 | |||
| 66 | @end | ||
| 67 | |||
| 68 | |||
| 69 | @implementation CCNotifications | ||
| 70 | @synthesize position = position_; | ||
| 71 | @synthesize notificationDesign = template_; | ||
| 72 | @synthesize animationIn = animationIn_; | ||
| 73 | @synthesize animationOut = animationOut_; | ||
| 74 | @synthesize delegate = delegate_; | ||
| 75 | @synthesize showingTime = showingTime_; | ||
| 76 | @synthesize currentNotification = currentNotification_; | ||
| 77 | |||
| 78 | static CCNotifications *sharedManager; | ||
| 79 | |||
| 80 | + (CCNotifications *)sharedManager | ||
| 81 | { | ||
| 82 | if (!sharedManager) | ||
| 83 | sharedManager = [[CCNotifications alloc] init]; | ||
| 84 | |||
| 85 | return sharedManager; | ||
| 86 | } | ||
| 87 | |||
| 88 | + (id) alloc | ||
| 89 | { | ||
| 90 | NSAssert(sharedManager == nil, @"Attempted to allocate a second instance of a singleton."); | ||
| 91 | return [super alloc]; | ||
| 92 | } | ||
| 93 | |||
| 94 | + (id) systemWithTemplate:(CCNode <CCNotificationDesignProtocol> *)notifications | ||
| 95 | { | ||
| 96 | NSAssert(sharedManager == nil, @"Attempted to allocate a second instance of a singleton. You should use setTemplate"); | ||
| 97 | sharedManager = [[CCNotifications alloc] initWithTemplate:notifications]; | ||
| 98 | |||
| 99 | return sharedManager; | ||
| 100 | } | ||
| 101 | |||
| 102 | + (void) purgeSharedManager | ||
| 103 | { | ||
| 104 | [sharedManager release]; | ||
| 105 | } | ||
| 106 | |||
| 107 | - (id) init | ||
| 108 | { | ||
| 109 | CCNode <CCNotificationDesignProtocol> *templates = [[[CCNotificationDefaultDesign alloc] init] autorelease]; | ||
| 110 | self = [self initWithTemplate:templates]; | ||
| 111 | return self; | ||
| 112 | } | ||
| 113 | |||
| 114 | - (id) initWithTemplate:(CCNode <CCNotificationDesignProtocol> *)templates | ||
| 115 | { | ||
| 116 | if( (self = [super init]) ) { | ||
| 117 | self.notificationDesign = templates; | ||
| 118 | |||
| 119 | delegate_ = nil; | ||
| 120 | state_ = kCCNotificationStateHide; | ||
| 121 | typeAnimationIn_ = kCCNotificationAnimationMovement; | ||
| 122 | typeAnimationOut_ = kCCNotificationAnimationMovement; | ||
| 123 | timeAnimationIn_ = 0.0f; | ||
| 124 | timeAnimationOut_ = 0.0f; | ||
| 125 | |||
| 126 | cachedNotifications_ = [[CCArray alloc] initWithCapacity:4]; | ||
| 127 | |||
| 128 | //Default settings | ||
| 129 | showingTime_ = 4.0f; | ||
| 130 | position_ = kCCNotificationPositionTop; | ||
| 131 | |||
| 132 | [self setAnimation:kCCNotificationAnimationMovement time:0.5f]; | ||
| 133 | //[self setAnimationIn:kCCNotificationAnimationMovement time:0.5f]; | ||
| 134 | //[self setAnimationOut:kCCNotificationAnimationScale time:0.5f]; | ||
| 135 | } | ||
| 136 | return self; | ||
| 137 | } | ||
| 138 | |||
| 139 | - (void) _setState:(char)states | ||
| 140 | { | ||
| 141 | if(state_==states) return; | ||
| 142 | state_ = states; | ||
| 143 | |||
| 144 | if([delegate_ respondsToSelector:@selector(notification:newState:)]) | ||
| 145 | [delegate_ notification:currentNotification_ newState:state_]; | ||
| 146 | |||
| 147 | if([delegate_ respondsToSelector:@selector(notificationChangeState:tag:)]) | ||
| 148 | [delegate_ notificationChangeState:state_ tag:[currentNotification_ tag]]; | ||
| 149 | } | ||
| 150 | |||
| 151 | - (void) setPosition:(char)positions | ||
| 152 | { | ||
| 153 | position_ = positions; | ||
| 154 | [self updateAnimations]; | ||
| 155 | } | ||
| 156 | |||
| 157 | - (void) setNotificationDesign:(CCNode <CCNotificationDesignProtocol>*) templates | ||
| 158 | { | ||
| 159 | if(state_!=kCCNotificationStateHide) | ||
| 160 | [template_ stopAllActions]; | ||
| 161 | |||
| 162 | if(state_==kCCNotificationStateShowing) | ||
| 163 | { | ||
| 164 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED | ||
| 165 | [[CCTouchDispatcher sharedDispatcher] removeDelegate:self]; | ||
| 166 | #endif | ||
| 167 | [[CCScheduler sharedScheduler] unscheduleSelector:@selector(_hideNotificationScheduler) forTarget:self]; | ||
| 168 | } | ||
| 169 | |||
| 170 | [templates retain]; | ||
| 171 | [template_ release]; | ||
| 172 | template_ = templates; | ||
| 173 | [template_ setVisible:NO]; | ||
| 174 | [template_ setIsRelativeAnchorPoint:YES]; | ||
| 175 | |||
| 176 | [self _setState:kCCNotificationStateHide]; | ||
| 177 | } | ||
| 178 | #pragma mark Notification Actions | ||
| 179 | |||
| 180 | - (CCActionInterval*) _animation:(char)type time:(ccTime)time | ||
| 181 | { | ||
| 182 | CCActionInterval *action = nil; | ||
| 183 | switch (type){ | ||
| 184 | case kCCNotificationAnimationMovement: | ||
| 185 | if(position_==kCCNotificationPositionBottom) | ||
| 186 | action = [CCMoveBy actionWithDuration:time position:ccp(0, template_.contentSize.height)]; | ||
| 187 | |||
| 188 | else if(position_ == kCCNotificationPositionTop) | ||
| 189 | action = [CCMoveBy actionWithDuration:time position:ccp(0, -template_.contentSize.height)]; | ||
| 190 | |||
| 191 | break; | ||
| 192 | case kCCNotificationAnimationScale: | ||
| 193 | action = [CCScaleBy actionWithDuration:time scale:(1.0f-KNOTIFICATIONMIN_SCALE)/KNOTIFICATIONMIN_SCALE]; | ||
| 194 | |||
| 195 | break; | ||
| 196 | default: break; | ||
| 197 | } | ||
| 198 | return action; | ||
| 199 | } | ||
| 200 | |||
| 201 | - (void) _updateAnimationIn | ||
| 202 | { | ||
| 203 | self.animationIn = [CCSequence actionOne:[self _animation:typeAnimationIn_ time:timeAnimationIn_] two:[CCCallFunc actionWithTarget:self selector:@selector(_startScheduler)]]; | ||
| 204 | } | ||
| 205 | |||
| 206 | - (void) _updateAnimationOut | ||
| 207 | { | ||
| 208 | CCActionInterval *tempAction = [self _animation:typeAnimationOut_ time:timeAnimationOut_]; | ||
| 209 | self.animationOut = [CCSequence actionOne:[tempAction reverse] two:[CCCallFunc actionWithTarget:self selector:@selector(_hideNotification)]]; | ||
| 210 | } | ||
| 211 | |||
| 212 | - (void) updateAnimations | ||
| 213 | { | ||
| 214 | [self _updateAnimationIn]; | ||
| 215 | [self _updateAnimationOut]; | ||
| 216 | } | ||
| 217 | |||
| 218 | - (void) setAnimationIn:(char)type time:(ccTime)time | ||
| 219 | { | ||
| 220 | typeAnimationIn_ = type; | ||
| 221 | timeAnimationIn_ = time; | ||
| 222 | [self _updateAnimationIn]; | ||
| 223 | } | ||
| 224 | |||
| 225 | - (void) setAnimationOut:(char)type time:(ccTime)time | ||
| 226 | { | ||
| 227 | typeAnimationOut_ = type; | ||
| 228 | timeAnimationOut_ = time; | ||
| 229 | [self _updateAnimationOut]; | ||
| 230 | } | ||
| 231 | |||
| 232 | - (void) setAnimation:(char)type time:(ccTime)time | ||
| 233 | { | ||
| 234 | typeAnimationIn_ = typeAnimationOut_ = type; | ||
| 235 | timeAnimationIn_ = timeAnimationOut_ = time; | ||
| 236 | [self updateAnimations]; | ||
| 237 | } | ||
| 238 | |||
| 239 | #pragma mark Notification steps | ||
| 240 | |||
| 241 | - (void) _startScheduler | ||
| 242 | { | ||
| 243 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED | ||
| 244 | [self registerWithTouchDispatcher]; | ||
| 245 | #endif | ||
| 246 | [self _setState:kCCNotificationStateShowing]; | ||
| 247 | [template_ stopAllActions]; | ||
| 248 | [[CCScheduler sharedScheduler] scheduleSelector:@selector(_hideNotificationScheduler) forTarget:self interval:showingTime_ paused:NO]; | ||
| 249 | } | ||
| 250 | |||
| 251 | - (void) _hideNotification | ||
| 252 | { | ||
| 253 | [self _setState:kCCNotificationStateHide]; | ||
| 254 | [template_ setVisible:NO]; | ||
| 255 | [template_ stopAllActions]; | ||
| 256 | [template_ onExit]; | ||
| 257 | |||
| 258 | //Release current notification | ||
| 259 | [cachedNotifications_ removeObject:currentNotification_]; | ||
| 260 | self.currentNotification = nil; | ||
| 261 | |||
| 262 | //Check next notification | ||
| 263 | [self _showNotification]; | ||
| 264 | } | ||
| 265 | |||
| 266 | - (void) _hideNotificationScheduler | ||
| 267 | { | ||
| 268 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED | ||
| 269 | [[CCTouchDispatcher sharedDispatcher] removeDelegate:self]; | ||
| 270 | #endif | ||
| 271 | [[CCScheduler sharedScheduler] unscheduleSelector:@selector(_hideNotificationScheduler) forTarget:self]; | ||
| 272 | if([currentNotification_ animated]) | ||
| 273 | { | ||
| 274 | [self _setState:kCCNotificationStateAnimationOut]; | ||
| 275 | [template_ runAction:animationOut_]; | ||
| 276 | }else | ||
| 277 | [self _hideNotification]; | ||
| 278 | } | ||
| 279 | |||
| 280 | #pragma mark Manager Notifications | ||
| 281 | |||
| 282 | - (void) _addNotificationToArray:(ccNotificationData*)data cached:(BOOL)isCached | ||
| 283 | { | ||
| 284 | if(isCached) | ||
| 285 | { | ||
| 286 | [cachedNotifications_ addObject:data]; | ||
| 287 | if([cachedNotifications_ count]==1) | ||
| 288 | [self _showNotification]; | ||
| 289 | }else{ | ||
| 290 | if(currentNotification_) | ||
| 291 | { | ||
| 292 | [cachedNotifications_ removeObject:currentNotification_]; | ||
| 293 | } | ||
| 294 | [cachedNotifications_ insertObject:data atIndex:0]; | ||
| 295 | [self _showNotification]; | ||
| 296 | } | ||
| 297 | } | ||
| 298 | |||
| 299 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image tag:(int)tag animate:(BOOL)animate waitUntilDone:(BOOL)isCached | ||
| 300 | { | ||
| 301 | ccNotificationData *data = [[ccNotificationData alloc] init]; | ||
| 302 | data.title = title; | ||
| 303 | data.message = message; | ||
| 304 | data.media = image; | ||
| 305 | data.mediaType = kCCNotificationMediaPath; | ||
| 306 | data.tag = tag; | ||
| 307 | data.animated = animate; | ||
| 308 | |||
| 309 | [self _addNotificationToArray:data cached:isCached]; | ||
| 310 | [data release]; | ||
| 311 | return data; | ||
| 312 | } | ||
| 313 | |||
| 314 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture tag:(int)tag animate:(BOOL)animate waitUntilDone:(BOOL)isCached | ||
| 315 | { | ||
| 316 | ccNotificationData *data = [[ccNotificationData alloc] init]; | ||
| 317 | data.title = title; | ||
| 318 | data.message = message; | ||
| 319 | data.media = texture; | ||
| 320 | data.mediaType = kCCNotificationMediaTexture; | ||
| 321 | data.tag = tag; | ||
| 322 | data.animated = animate; | ||
| 323 | |||
| 324 | [self _addNotificationToArray:data cached:isCached]; | ||
| 325 | [data release]; | ||
| 326 | return data; | ||
| 327 | } | ||
| 328 | |||
| 329 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image tag:(int)tag animate:(BOOL)animate | ||
| 330 | { | ||
| 331 | return [self addWithTitle:title message:message image:image tag:tag animate:animate waitUntilDone:YES]; | ||
| 332 | } | ||
| 333 | |||
| 334 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture tag:(int)tag animate:(BOOL)animate | ||
| 335 | { | ||
| 336 | return [self addWithTitle:title message:message texture:texture tag:tag animate:animate waitUntilDone:YES]; | ||
| 337 | } | ||
| 338 | |||
| 339 | /* Fast methods */ | ||
| 340 | |||
| 341 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image | ||
| 342 | { | ||
| 343 | return [self addWithTitle:title message:message image:image tag:-1 animate:YES waitUntilDone:YES]; | ||
| 344 | } | ||
| 345 | |||
| 346 | - (ccNotificationData*) addWithTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture | ||
| 347 | { | ||
| 348 | return [self addWithTitle:title message:message texture:texture tag:-1 animate:YES waitUntilDone:YES]; | ||
| 349 | } | ||
| 350 | |||
| 351 | /* Deprecated */ | ||
| 352 | - (void) addSafelyWithTitle:(NSString*)title message:(NSString*)message image:(NSString*)image tag:(int)tag animate:(BOOL)animate | ||
| 353 | { | ||
| 354 | [self addWithTitle:title message:message image:image tag:tag animate:animate waitUntilDone:YES]; | ||
| 355 | } | ||
| 356 | |||
| 357 | - (void) _showNotification | ||
| 358 | { | ||
| 359 | if([cachedNotifications_ count]==0) return; | ||
| 360 | //Get notification data | ||
| 361 | self.currentNotification = [cachedNotifications_ objectAtIndex:0]; | ||
| 362 | |||
| 363 | //Stop system | ||
| 364 | if(state_==kCCNotificationStateShowing) | ||
| 365 | { | ||
| 366 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED | ||
| 367 | [[CCTouchDispatcher sharedDispatcher] removeDelegate:self]; | ||
| 368 | #else | ||
| 369 | [[CCEventDispatcher sharedDispatcher] removeMouseDelegate:self]; | ||
| 370 | #endif | ||
| 371 | } | ||
| 372 | |||
| 373 | if(state_!=kCCNotificationStateHide) | ||
| 374 | { | ||
| 375 | [self _setState:kCCNotificationStateHide]; | ||
| 376 | |||
| 377 | [template_ setVisible:NO]; | ||
| 378 | [template_ stopAllActions]; | ||
| 379 | [template_ onExit]; | ||
| 380 | [[CCScheduler sharedScheduler] unscheduleSelector:@selector(_hideNotificationScheduler) forTarget:self]; | ||
| 381 | } | ||
| 382 | |||
| 383 | //Get variables | ||
| 384 | CCTexture2D *texture = (currentNotification_.media) ? ((currentNotification_.mediaType==kCCNotificationMediaTexture) ? (CCTexture2D*)currentNotification_.media : [[CCTextureCache sharedTextureCache] addImage:(NSString*)currentNotification_.media]) : nil; | ||
| 385 | |||
| 386 | //Prepare template | ||
| 387 | [template_ setVisible:NO]; | ||
| 388 | [template_ stopAllActions]; | ||
| 389 | [template_ onExit]; | ||
| 390 | |||
| 391 | //Prepare animation | ||
| 392 | CGSize winSize = CGSizeMake(480,320); | ||
| 393 | if(currentNotification_.animated) | ||
| 394 | { | ||
| 395 | if(position_==kCCNotificationPositionBottom){ | ||
| 396 | [template_ setAnchorPoint:ccp(0.5f, 0)]; | ||
| 397 | switch (typeAnimationIn_) { | ||
| 398 | case kCCNotificationAnimationMovement: | ||
| 399 | [template_ setScale:1.0f]; | ||
| 400 | [template_ setPosition:ccp(winSize.width/2.0f, -template_.contentSize.height)]; | ||
| 401 | |||
| 402 | break; | ||
| 403 | case kCCNotificationAnimationScale: | ||
| 404 | [template_ setScale:KNOTIFICATIONMIN_SCALE]; | ||
| 405 | [template_ setPosition:ccp(winSize.width/2.0f, 0)]; | ||
| 406 | |||
| 407 | break; | ||
| 408 | default: return; | ||
| 409 | } | ||
| 410 | |||
| 411 | }else if(position_==kCCNotificationPositionTop) | ||
| 412 | { | ||
| 413 | [template_ setAnchorPoint:ccp(0.5f, 1)]; | ||
| 414 | switch (typeAnimationIn_){ | ||
| 415 | case kCCNotificationAnimationMovement: | ||
| 416 | [template_ setScale:1.0f]; | ||
| 417 | [template_ setPosition:ccp(winSize.width/2.0f, winSize.height+template_.contentSize.height)]; | ||
| 418 | |||
| 419 | break; | ||
| 420 | case kCCNotificationAnimationScale: | ||
| 421 | [template_ setScale:KNOTIFICATIONMIN_SCALE]; | ||
| 422 | [template_ setPosition:ccp(winSize.width/2.0f, winSize.height)]; | ||
| 423 | |||
| 424 | break; | ||
| 425 | default: return; | ||
| 426 | } | ||
| 427 | } | ||
| 428 | [self _setState:kCCNotificationStateAnimationIn]; | ||
| 429 | [template_ onEnter]; | ||
| 430 | [template_ runAction:animationIn_]; | ||
| 431 | |||
| 432 | }else{ | ||
| 433 | if(position_==kCCNotificationPositionBottom) | ||
| 434 | { | ||
| 435 | [template_ setAnchorPoint:ccp(0.5f, 0)]; | ||
| 436 | [template_ setPosition:ccp(winSize.width/2.0f, 0)]; | ||
| 437 | }else if(position_==kCCNotificationPositionTop) | ||
| 438 | { | ||
| 439 | [template_ setAnchorPoint:ccp(0.5f, 1)]; | ||
| 440 | [template_ setPosition:ccp(winSize.width/2.0f, winSize.height)]; | ||
| 441 | } | ||
| 442 | [self _startScheduler]; | ||
| 443 | } | ||
| 444 | |||
| 445 | //Update template | ||
| 446 | [template_ setTitle:[currentNotification_ title] message:[currentNotification_ message] texture:texture]; | ||
| 447 | [template_ setVisible:YES]; | ||
| 448 | } | ||
| 449 | |||
| 450 | #pragma mark Touch Events | ||
| 451 | |||
| 452 | #ifdef __IPHONE_OS_VERSION_MAX_ALLOWED | ||
| 453 | - (void) registerWithTouchDispatcher | ||
| 454 | { | ||
| 455 | [[CCTouchDispatcher sharedDispatcher] addStandardDelegate:self priority:INT_MIN]; | ||
| 456 | } | ||
| 457 | |||
| 458 | - (void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event | ||
| 459 | { | ||
| 460 | UITouch *touch = [touches anyObject]; | ||
| 461 | CGPoint point = [[CCDirector sharedDirector] convertToGL:[touch locationInView:[touch view]]]; | ||
| 462 | CGRect rect = [template_ boundingBox]; | ||
| 463 | if(CGRectContainsPoint(rect, point)) | ||
| 464 | if([delegate_ respondsToSelector:@selector(touched:)] && [delegate_ touched:[currentNotification_ tag]]) | ||
| 465 | [self _hideNotificationScheduler]; | ||
| 466 | } | ||
| 467 | #endif | ||
| 468 | |||
| 469 | #pragma mark Other methods | ||
| 470 | |||
| 471 | - (void) visit | ||
| 472 | { | ||
| 473 | [template_ visit]; | ||
| 474 | } | ||
| 475 | |||
| 476 | - (NSString*) description | ||
| 477 | { | ||
| 478 | return [NSString stringWithFormat:@"<%@ = %08X>", [self class], self]; | ||
| 479 | } | ||
| 480 | |||
| 481 | -(void) dealloc | ||
| 482 | { | ||
| 483 | CCLOG(@"cocos2d: deallocing %@", self); | ||
| 484 | |||
| 485 | sharedManager = nil; | ||
| 486 | [cachedNotifications_ release]; | ||
| 487 | [self setCurrentNotification:nil]; | ||
| 488 | [self setNotificationDesign:nil]; | ||
| 489 | [self setDelegate:nil]; | ||
| 490 | [self setAnimationIn:nil]; | ||
| 491 | [self setAnimationOut:nil]; | ||
| 492 | [super dealloc]; | ||
| 493 | } | ||
| 494 | @end \ No newline at end of file | ||
| diff --git a/libs/cocos2d/notificationDesign.h b/libs/cocos2d/notificationDesign.h new file mode 100644 index 0000000..856fb74 --- /dev/null +++ b/libs/cocos2d/notificationDesign.h | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | /* | ||
| 2 | * CCNotifications | ||
| 3 | * | ||
| 4 | * Copyright (c) 2010 ForzeField Studios S.L. | ||
| 5 | * http://forzefield.com | ||
| 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 <Foundation/Foundation.h> | ||
| 29 | #import "CCNotifications.h" | ||
| 30 | #import "cocos2d.h" | ||
| 31 | |||
| 32 | @interface CCNotificationDefaultDesign : CCLayerColor <CCNotificationDesignProtocol> | ||
| 33 | { | ||
| 34 | CCLabelTTF *title_; | ||
| 35 | CCLabelTTF *message_; | ||
| 36 | CCSprite *image_; | ||
| 37 | } | ||
| 38 | |||
| 39 | @end \ No newline at end of file | ||
| diff --git a/libs/cocos2d/notificationDesign.m b/libs/cocos2d/notificationDesign.m new file mode 100644 index 0000000..470d402 --- /dev/null +++ b/libs/cocos2d/notificationDesign.m | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /* | ||
| 2 | * CCNotifications | ||
| 3 | * | ||
| 4 | * Copyright (c) 2010 ForzeField Studios S.L. | ||
| 5 | * http://forzefield.com | ||
| 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 "notificationDesign.h" | ||
| 29 | |||
| 30 | @implementation CCNotificationDefaultDesign | ||
| 31 | |||
| 32 | - (id) init | ||
| 33 | { | ||
| 34 | CGSize size = CGSizeMake(480,320); | ||
| 35 | self = [self initWithColor:ccc4(42, 68, 148, 180) width:size.width height:38]; | ||
| 36 | if (self != nil) { | ||
| 37 | title_ = [CCLabelTTF labelWithString:@" " fontName:@"Arial" fontSize:12]; | ||
| 38 | [title_ setIsRelativeAnchorPoint:NO]; | ||
| 39 | [title_ setAnchorPoint:CGPointZero]; | ||
| 40 | [title_ setPosition:ccp(52, 20)]; | ||
| 41 | |||
| 42 | message_ = [CCLabelTTF labelWithString:@" " fontName:@"Arial" fontSize:15]; | ||
| 43 | [message_ setIsRelativeAnchorPoint:NO]; | ||
| 44 | [message_ setAnchorPoint:CGPointZero]; | ||
| 45 | [message_ setPosition:ccp(52, 3)]; | ||
| 46 | |||
| 47 | image_ = [CCSprite node]; | ||
| 48 | [image_ setPosition:ccp(26, 19)]; | ||
| 49 | |||
| 50 | [self addChild:title_]; | ||
| 51 | [self addChild:message_]; | ||
| 52 | [self addChild:image_]; | ||
| 53 | } | ||
| 54 | return self; | ||
| 55 | } | ||
| 56 | |||
| 57 | - (void) setTitle:(NSString*)title message:(NSString*)message texture:(CCTexture2D*)texture{ | ||
| 58 | [title_ setString:title]; | ||
| 59 | [message_ setString:message]; | ||
| 60 | if(texture){ | ||
| 61 | CGRect rect = CGRectZero; | ||
| 62 | rect.size = texture.contentSize; | ||
| 63 | [image_ setTexture:texture]; | ||
| 64 | [image_ setTextureRect:rect]; | ||
| 65 | //Same size 32x32 | ||
| 66 | [image_ setScaleX:32.0f/rect.size.width]; | ||
| 67 | [image_ setScaleY:32.0f/rect.size.height]; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | - (void) updateColor | ||
| 72 | { | ||
| 73 | //Gradient code | ||
| 74 | ccColor3B colorFinal = ccc3(0, 50, 100); | ||
| 75 | |||
| 76 | squareColors_[0] = ccc4(color_.r, color_.g, color_.b, opacity_); | ||
| 77 | squareColors_[1] = ccc4(color_.r, color_.g, color_.b, opacity_); | ||
| 78 | squareColors_[2] = ccc4(colorFinal.r, colorFinal.g, colorFinal.b, opacity_); | ||
| 79 | squareColors_[3] = ccc4(colorFinal.r, colorFinal.g, colorFinal.b, opacity_); | ||
| 80 | } | ||
| 81 | |||
| 82 | @end \ No newline at end of file | ||
