summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xCart Collect.xcodeproj/project.pbxproj46
-rwxr-xr-xClasses/Cart_CollectAppDelegate.m4
-rwxr-xr-xClasses/GameLayer.h14
-rwxr-xr-xClasses/GameLayer.m84
-rwxr-xr-xClasses/PauseLayer.h22
-rwxr-xr-xClasses/PauseLayer.m68
-rw-r--r--Classes/TutorialBubble.h29
-rw-r--r--Classes/TutorialBubble.m177
-rwxr-xr-xResources/framestuff.pngbin0 -> 678 bytes
9 files changed, 329 insertions, 115 deletions
diff --git a/Cart Collect.xcodeproj/project.pbxproj b/Cart Collect.xcodeproj/project.pbxproj index 2ca790c..b3c5dfa 100755 --- a/Cart Collect.xcodeproj/project.pbxproj +++ b/Cart Collect.xcodeproj/project.pbxproj
@@ -40,7 +40,6 @@
40 3F7D0F4F13D8F17C00B6CE14 /* newgame2.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F7D0F4B13D8F17C00B6CE14 /* newgame2.png */; }; 40 3F7D0F4F13D8F17C00B6CE14 /* newgame2.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F7D0F4B13D8F17C00B6CE14 /* newgame2.png */; };
41 3F8394F313D732330059AEE8 /* pause.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F8394F213D732330059AEE8 /* pause.png */; }; 41 3F8394F313D732330059AEE8 /* pause.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F8394F213D732330059AEE8 /* pause.png */; };
42 3F8394F513D7328E0059AEE8 /* pause2.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F8394F413D7328E0059AEE8 /* pause2.png */; }; 42 3F8394F513D7328E0059AEE8 /* pause2.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F8394F413D7328E0059AEE8 /* pause2.png */; };
43 3F8394F813D7336D0059AEE8 /* PauseLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F8394F713D7336D0059AEE8 /* PauseLayer.m */; };
44 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F83955213D739B10059AEE8 /* MainMenuLayer.m */; }; 43 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F83955213D739B10059AEE8 /* MainMenuLayer.m */; };
45 3F8395B813D744420059AEE8 /* cartdata.sqlite3 in Resources */ = {isa = PBXBuildFile; fileRef = 3F8395B713D744420059AEE8 /* cartdata.sqlite3 */; }; 44 3F8395B813D744420059AEE8 /* cartdata.sqlite3 in Resources */ = {isa = PBXBuildFile; fileRef = 3F8395B713D744420059AEE8 /* cartdata.sqlite3 */; };
46 3F8395D113D746200059AEE8 /* libsqlite3.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F8395D013D746200059AEE8 /* libsqlite3.0.dylib */; }; 45 3F8395D113D746200059AEE8 /* libsqlite3.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F8395D013D746200059AEE8 /* libsqlite3.0.dylib */; };
@@ -85,6 +84,8 @@
85 50F4144910692EE7002A0D5E /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144410692EE7002A0D5E /* Default.png */; }; 84 50F4144910692EE7002A0D5E /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144410692EE7002A0D5E /* Default.png */; };
86 50F4144A10692EE7002A0D5E /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144510692EE7002A0D5E /* fps_images.png */; }; 85 50F4144A10692EE7002A0D5E /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144510692EE7002A0D5E /* fps_images.png */; };
87 50F4144B10692EE7002A0D5E /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144610692EE7002A0D5E /* Icon.png */; }; 86 50F4144B10692EE7002A0D5E /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144610692EE7002A0D5E /* Icon.png */; };
87 6C29041013EAEB590032DA0F /* TutorialBubble.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C29040F13EAEB590032DA0F /* TutorialBubble.m */; };
88 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C29041113EAEC8A0032DA0F /* framestuff.png */; };
88 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C5179C513DF3839006F1F38 /* Morning1.png */; }; 89 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C5179C513DF3839006F1F38 /* Morning1.png */; };
89 DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; }; 90 DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; };
90 DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; }; 91 DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; };
@@ -330,8 +331,6 @@
330 3F8394AC13D72E2C0059AEE8 /* ValuableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValuableObject.h; sourceTree = "<group>"; }; 331 3F8394AC13D72E2C0059AEE8 /* ValuableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValuableObject.h; sourceTree = "<group>"; };
331 3F8394F213D732330059AEE8 /* pause.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pause.png; sourceTree = "<group>"; }; 332 3F8394F213D732330059AEE8 /* pause.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pause.png; sourceTree = "<group>"; };
332 3F8394F413D7328E0059AEE8 /* pause2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pause2.png; sourceTree = "<group>"; }; 333 3F8394F413D7328E0059AEE8 /* pause2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pause2.png; sourceTree = "<group>"; };
333 3F8394F613D7336D0059AEE8 /* PauseLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PauseLayer.h; sourceTree = "<group>"; };
334 3F8394F713D7336D0059AEE8 /* PauseLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PauseLayer.m; sourceTree = "<group>"; };
335 3F83955113D739B10059AEE8 /* MainMenuLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainMenuLayer.h; sourceTree = "<group>"; }; 334 3F83955113D739B10059AEE8 /* MainMenuLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainMenuLayer.h; sourceTree = "<group>"; };
336 3F83955213D739B10059AEE8 /* MainMenuLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainMenuLayer.m; sourceTree = "<group>"; }; 335 3F83955213D739B10059AEE8 /* MainMenuLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainMenuLayer.m; sourceTree = "<group>"; };
337 3F8395B713D744420059AEE8 /* cartdata.sqlite3 */ = {isa = PBXFileReference; lastKnownFileType = file; path = cartdata.sqlite3; sourceTree = "<group>"; }; 336 3F8395B713D744420059AEE8 /* cartdata.sqlite3 */ = {isa = PBXFileReference; lastKnownFileType = file; path = cartdata.sqlite3; sourceTree = "<group>"; };
@@ -374,6 +373,9 @@
374 50F4144510692EE7002A0D5E /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = "<group>"; }; 373 50F4144510692EE7002A0D5E /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = "<group>"; };
375 50F4144610692EE7002A0D5E /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; }; 374 50F4144610692EE7002A0D5E /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
376 50F4144710692EE7002A0D5E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 375 50F4144710692EE7002A0D5E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
376 6C29040E13EAEB590032DA0F /* TutorialBubble.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TutorialBubble.h; sourceTree = "<group>"; };
377 6C29040F13EAEB590032DA0F /* TutorialBubble.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TutorialBubble.m; sourceTree = "<group>"; };
378 6C29041113EAEC8A0032DA0F /* framestuff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = framestuff.png; sourceTree = "<group>"; };
377 6C5179C513DF3839006F1F38 /* Morning1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Morning1.png; sourceTree = "<group>"; }; 379 6C5179C513DF3839006F1F38 /* Morning1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Morning1.png; sourceTree = "<group>"; };
378 DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 380 DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
379 DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 381 DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
@@ -654,6 +656,7 @@
654 2D500B1D0D5A766B00DBA0E3 /* Classes */ = { 656 2D500B1D0D5A766B00DBA0E3 /* Classes */ = {
655 isa = PBXGroup; 657 isa = PBXGroup;
656 children = ( 658 children = (
659 6C5887E313EE3ED900B5A80A /* Items */,
657 E0F81035120A173C005866B8 /* GameConfig.h */, 660 E0F81035120A173C005866B8 /* GameConfig.h */,
658 E0F81036120A173C005866B8 /* RootViewController.h */, 661 E0F81036120A173C005866B8 /* RootViewController.h */,
659 E0F81037120A173C005866B8 /* RootViewController.m */, 662 E0F81037120A173C005866B8 /* RootViewController.m */,
@@ -661,27 +664,16 @@
661 507022A2107672FA00393637 /* Cart_CollectAppDelegate.m */, 664 507022A2107672FA00393637 /* Cart_CollectAppDelegate.m */,
662 3FE79CD213D4DE37001A6B93 /* GameLayer.h */, 665 3FE79CD213D4DE37001A6B93 /* GameLayer.h */,
663 3FE79CD313D4DE37001A6B93 /* GameLayer.m */, 666 3FE79CD313D4DE37001A6B93 /* GameLayer.m */,
664 3F6C7C4D13D5E1B600C038FE /* FallingObject.h */,
665 3F6C7C4E13D5E1B600C038FE /* FallingObject.m */,
666 3F6C7C6B13D5E51800C038FE /* Cherry.h */,
667 3F6C7C6C13D5E51800C038FE /* Cherry.m */,
668 3F6C7C6E13D5E54E00C038FE /* Bottle.h */,
669 3F6C7C6F13D5E54E00C038FE /* Bottle.m */,
670 3F6C7C7113D5E57100C038FE /* OneUp.h */,
671 3F6C7C7213D5E57100C038FE /* OneUp.m */,
672 3F6C7EE213D636CF00C038FE /* Rock.h */,
673 3F6C7EE313D636CF00C038FE /* Rock.m */,
674 3F6C7EE713D6377D00C038FE /* GameOverLayer.h */, 667 3F6C7EE713D6377D00C038FE /* GameOverLayer.h */,
675 3F6C7EE813D6377D00C038FE /* GameOverLayer.m */, 668 3F6C7EE813D6377D00C038FE /* GameOverLayer.m */,
676 3F8394AC13D72E2C0059AEE8 /* ValuableObject.h */,
677 3F8394F613D7336D0059AEE8 /* PauseLayer.h */,
678 3F8394F713D7336D0059AEE8 /* PauseLayer.m */,
679 3F83955213D739B10059AEE8 /* MainMenuLayer.m */, 669 3F83955213D739B10059AEE8 /* MainMenuLayer.m */,
680 3F83955113D739B10059AEE8 /* MainMenuLayer.h */, 670 3F83955113D739B10059AEE8 /* MainMenuLayer.h */,
681 3F03221413D78F8C00E6A708 /* HighscoreListController.h */, 671 3F03221413D78F8C00E6A708 /* HighscoreListController.h */,
682 3F03221513D78F8C00E6A708 /* HighscoreListController.m */, 672 3F03221513D78F8C00E6A708 /* HighscoreListController.m */,
683 3F03221713D7904E00E6A708 /* Highscore.h */, 673 3F03221713D7904E00E6A708 /* Highscore.h */,
684 3F03221813D7904E00E6A708 /* Highscore.m */, 674 3F03221813D7904E00E6A708 /* Highscore.m */,
675 6C29040E13EAEB590032DA0F /* TutorialBubble.h */,
676 6C29040F13EAEB590032DA0F /* TutorialBubble.m */,
685 ); 677 );
686 path = Classes; 678 path = Classes;
687 sourceTree = "<group>"; 679 sourceTree = "<group>";
@@ -699,6 +691,7 @@
699 3F6C7F4D13D647B600C038FE /* Sprites */ = { 691 3F6C7F4D13D647B600C038FE /* Sprites */ = {
700 isa = PBXGroup; 692 isa = PBXGroup;
701 children = ( 693 children = (
694 6C29041113EAEC8A0032DA0F /* framestuff.png */,
702 3F6C7EE013D636BE00C038FE /* rock.png */, 695 3F6C7EE013D636BE00C038FE /* rock.png */,
703 3F63FA3E13D4EE53003B3D14 /* oneup.png */, 696 3F63FA3E13D4EE53003B3D14 /* oneup.png */,
704 3F63FA3C13D4EE4D003B3D14 /* cherry.png */, 697 3F63FA3C13D4EE4D003B3D14 /* cherry.png */,
@@ -828,6 +821,24 @@
828 path = Resources; 821 path = Resources;
829 sourceTree = "<group>"; 822 sourceTree = "<group>";
830 }; 823 };
824 6C5887E313EE3ED900B5A80A /* Items */ = {
825 isa = PBXGroup;
826 children = (
827 3F6C7C4D13D5E1B600C038FE /* FallingObject.h */,
828 3F6C7C4E13D5E1B600C038FE /* FallingObject.m */,
829 3F6C7C6B13D5E51800C038FE /* Cherry.h */,
830 3F6C7C6C13D5E51800C038FE /* Cherry.m */,
831 3F6C7C6E13D5E54E00C038FE /* Bottle.h */,
832 3F6C7C6F13D5E54E00C038FE /* Bottle.m */,
833 3F6C7C7113D5E57100C038FE /* OneUp.h */,
834 3F6C7C7213D5E57100C038FE /* OneUp.m */,
835 3F6C7EE213D636CF00C038FE /* Rock.h */,
836 3F6C7EE313D636CF00C038FE /* Rock.m */,
837 3F8394AC13D72E2C0059AEE8 /* ValuableObject.h */,
838 );
839 name = Items;
840 sourceTree = "<group>";
841 };
831 E02BBB19126CC2F5006E46A2 /* cocos2d */ = { 842 E02BBB19126CC2F5006E46A2 /* cocos2d */ = {
832 isa = PBXGroup; 843 isa = PBXGroup;
833 children = ( 844 children = (
@@ -1289,6 +1300,7 @@
1289 3F7D0F4E13D8F17C00B6CE14 /* newgame.png in Resources */, 1300 3F7D0F4E13D8F17C00B6CE14 /* newgame.png in Resources */,
1290 3F7D0F4F13D8F17C00B6CE14 /* newgame2.png in Resources */, 1301 3F7D0F4F13D8F17C00B6CE14 /* newgame2.png in Resources */,
1291 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */, 1302 6C5179C613DF3839006F1F38 /* Morning1.png in Resources */,
1303 6C29041213EAEC8A0032DA0F /* framestuff.png in Resources */,
1292 ); 1304 );
1293 runOnlyForDeploymentPostprocessing = 0; 1305 runOnlyForDeploymentPostprocessing = 0;
1294 }; 1306 };
@@ -1325,10 +1337,10 @@
1325 3F6C7C7313D5E57100C038FE /* OneUp.m in Sources */, 1337 3F6C7C7313D5E57100C038FE /* OneUp.m in Sources */,
1326 3F6C7EE413D636CF00C038FE /* Rock.m in Sources */, 1338 3F6C7EE413D636CF00C038FE /* Rock.m in Sources */,
1327 3F6C7EE913D6377D00C038FE /* GameOverLayer.m in Sources */, 1339 3F6C7EE913D6377D00C038FE /* GameOverLayer.m in Sources */,
1328 3F8394F813D7336D0059AEE8 /* PauseLayer.m in Sources */,
1329 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */, 1340 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */,
1330 3F03221613D78F8C00E6A708 /* HighscoreListController.m in Sources */, 1341 3F03221613D78F8C00E6A708 /* HighscoreListController.m in Sources */,
1331 3F03221913D7904E00E6A708 /* Highscore.m in Sources */, 1342 3F03221913D7904E00E6A708 /* Highscore.m in Sources */,
1343 6C29041013EAEB590032DA0F /* TutorialBubble.m in Sources */,
1332 ); 1344 );
1333 runOnlyForDeploymentPostprocessing = 0; 1345 runOnlyForDeploymentPostprocessing = 0;
1334 }; 1346 };
diff --git a/Classes/Cart_CollectAppDelegate.m b/Classes/Cart_CollectAppDelegate.m index 201422f..7547601 100755 --- a/Classes/Cart_CollectAppDelegate.m +++ b/Classes/Cart_CollectAppDelegate.m
@@ -139,9 +139,9 @@
139-(void) applicationDidEnterBackground:(UIApplication*)application { 139-(void) applicationDidEnterBackground:(UIApplication*)application {
140 [[CCDirector sharedDirector] stopAnimation]; 140 [[CCDirector sharedDirector] stopAnimation];
141 141
142 if ([[CCDirector sharedDirector] runningScene].tag == 436) 142 if ([[CCDirector sharedDirector] runningScene].tag == GAME_SCENE)
143 { 143 {
144 [[CCDirector sharedDirector] replaceScene:[PauseLayer sceneWithScene:[[CCDirector sharedDirector] runningScene]]]; 144 [((GameLayer*)[[[CCDirector sharedDirector] runningScene] getChildByTag:GAME_LAYER]) pause];
145 } 145 }
146} 146}
147 147
diff --git a/Classes/GameLayer.h b/Classes/GameLayer.h index 88a1406..e72b551 100755 --- a/Classes/GameLayer.h +++ b/Classes/GameLayer.h
@@ -15,9 +15,13 @@
15#import "Rock.h" 15#import "Rock.h"
16#import "GameOverLayer.h" 16#import "GameOverLayer.h"
17#import "ValuableObject.h" 17#import "ValuableObject.h"
18#import "PauseLayer.h"
19#import "CocosDenshion.h" 18#import "CocosDenshion.h"
20#import "SimpleAudioEngine.h" 19#import "SimpleAudioEngine.h"
20#import "TutorialBubble.h"
21#import "MainMenuLayer.h"
22
23#define GAME_SCENE 436
24#define GAME_LAYER 437
21 25
22@interface GameLayer : CCLayer { 26@interface GameLayer : CCLayer {
23 NSMutableSet* objects; 27 NSMutableSet* objects;
@@ -28,11 +32,19 @@
28 int lives; 32 int lives;
29 float addSpeed; 33 float addSpeed;
30 CCSprite* cartSprite; 34 CCSprite* cartSprite;
35 TutorialBubble* currentTutorial;
36
37 CCLayerColor* shadedLayer;
38 CCLayer* pauseLayer;
31} 39}
32 40
41@property (nonatomic,retain) TutorialBubble* currentTutorial;
33+ (CCScene*)scene; 42+ (CCScene*)scene;
34- (id)init; 43- (id)init;
35- (void)updateLabels; 44- (void)updateLabels;
36- (void)pause; 45- (void)pause;
46- (void)unpause;
47- (void)mainmenu;
48- (void)endTutorial;
37 49
38@end 50@end
diff --git a/Classes/GameLayer.m b/Classes/GameLayer.m index 32ca483..2ec8ef5 100755 --- a/Classes/GameLayer.m +++ b/Classes/GameLayer.m
@@ -11,6 +11,8 @@
11 11
12@implementation GameLayer 12@implementation GameLayer
13 13
14@synthesize currentTutorial;
15
14+ (CCScene*)scene 16+ (CCScene*)scene
15{ 17{
16 CCScene* scene = [CCScene node]; 18 CCScene* scene = [CCScene node];
@@ -19,9 +21,10 @@
19 [scene addChild:backgroundLayer]; 21 [scene addChild:backgroundLayer];
20 22
21 GameLayer* layer = [GameLayer node]; 23 GameLayer* layer = [GameLayer node];
24 layer.tag = GAME_LAYER;
22 [scene addChild:layer]; 25 [scene addChild:layer];
23 26
24 scene.tag = 436; 27 scene.tag = GAME_SCENE;
25 28
26 return scene; 29 return scene;
27} 30}
@@ -266,13 +269,13 @@
266 return self; 269 return self;
267} 270}
268 271
269-(void) onEnter 272- (void)onEnter
270{ 273{
271 [super onEnter]; 274 [super onEnter];
272 275
273 [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 60)]; 276 [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 60)];
274 [self schedule:@selector(tick:) interval:1.0f/60.0f]; 277 [self schedule:@selector(tick:) interval:1.0f/60.0f];
275 [self schedule:@selector(randomlyAddObject:) interval:addSpeed]; 278 [self schedule:@selector(randomlyAddObject:) interval:addSpeed];
276} 279}
277 280
278- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration 281- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
@@ -295,7 +298,78 @@
295 298
296- (void)pause 299- (void)pause
297{ 300{
298 [[CCDirector sharedDirector] replaceScene:[PauseLayer sceneWithScene:[[CCDirector sharedDirector] runningScene]]]; 301 if (self.currentTutorial != nil)
302 {
303 [self.currentTutorial removeFromSuperview];
304 }
305
306 [self pauseSchedulerAndActions];
307
308 shadedLayer = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)];
309 [[[CCDirector sharedDirector] runningScene] addChild:shadedLayer];
310
311 pauseLayer = [CCLayer node];
312 CCLabelBMFont* scoreLabel2 = [CCLabelBMFont labelWithString:@"PAUSE" fntFile:@"helvetica.fnt"];
313 scoreLabel2.position = ccp(240,90);
314 [pauseLayer addChild:scoreLabel2];
315
316 CCMenuItemImage* pauseButton = [CCMenuItemImage itemFromNormalImage:@"pause2.png" selectedImage:@"pause.png" target:self selector:@selector(unpause)];
317 CCMenu* pauseMenu = [CCMenu menuWithItems:pauseButton, nil];
318 [pauseMenu setPosition:ccp(480-8-16, 320-8-16)];
319 [pauseLayer addChild:pauseMenu];
320
321 CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(mainmenu)];
322 CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil];
323 myMenu.position = ccp(240, 60);
324 [pauseLayer addChild:myMenu];
325
326 [[[CCDirector sharedDirector] runningScene] addChild:pauseLayer];
327}
328
329- (void)unpause
330{
331 [[[CCDirector sharedDirector] runningScene] removeChild:shadedLayer cleanup:YES];
332 [[[CCDirector sharedDirector] runningScene] removeChild:pauseLayer cleanup:YES];
333
334 shadedLayer = nil;
335 pauseLayer = nil;
336
337 if (self.currentTutorial != nil)
338 {
339 [[[CCDirector sharedDirector] openGLView] addSubview:self.currentTutorial];
340 } else {
341 [self resumeSchedulerAndActions];
342 }
343}
344
345- (void)mainmenu
346{
347 [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]];
348}
349
350- (void)setCurrentTutorial:(TutorialBubble *)m_currentTutorial
351{
352 @synchronized(self)
353 {
354 if (currentTutorial != m_currentTutorial)
355 {
356 [currentTutorial release];
357 currentTutorial = [m_currentTutorial retain];
358 }
359 }
360
361 if (currentTutorial != nil)
362 {
363 [currentTutorial setTarget:self action:@selector(endTutorial)];
364 [[[CCDirector sharedDirector] openGLView] addSubview:currentTutorial];
365 [self pauseSchedulerAndActions];
366 }
367}
368
369- (void)endTutorial
370{
371 self.currentTutorial = nil;
372 [self resumeSchedulerAndActions];
299} 373}
300 374
301@end 375@end
diff --git a/Classes/PauseLayer.h b/Classes/PauseLayer.h deleted file mode 100755 index aae5d6c..0000000 --- a/Classes/PauseLayer.h +++ /dev/null
@@ -1,22 +0,0 @@
1//
2// PauseLayer.h
3// Cart Collect
4//
5// Created by iD Student Account on 7/20/11.
6// Copyright 2011 __MyCompanyName__. All rights reserved.
7//
8
9#import <Foundation/Foundation.h>
10#import "cocos2d.h"
11#import "GameLayer.h"
12
13@interface PauseLayer : CCLayer {
14 CCScene* game;
15}
16
17+ (CCScene*)sceneWithScene:(CCScene*)scene;
18- (id)initWithScene:(CCScene*)scene;
19- (void)unpause;
20- (void)newgame;
21
22@end
diff --git a/Classes/PauseLayer.m b/Classes/PauseLayer.m deleted file mode 100755 index 53574b2..0000000 --- a/Classes/PauseLayer.m +++ /dev/null
@@ -1,68 +0,0 @@
1//
2// PauseLayer.m
3// Cart Collect
4//
5// Created by iD Student Account on 7/20/11.
6// Copyright 2011 __MyCompanyName__. All rights reserved.
7//
8
9#import "PauseLayer.h"
10
11@implementation PauseLayer
12
13+ (CCScene*)sceneWithScene:(CCScene*)scene2
14{
15 CCScene* scene = [CCScene node];
16
17 CCLayerColor* backgroundLayer = [CCLayerColor layerWithColor:ccc4(255, 255, 255, 255)];
18 CCSprite* backgroundImage = [CCSprite spriteWithFile:@"SeaBeach.png"];
19 backgroundImage.position = ccp(240,160);
20 [backgroundLayer addChild:backgroundImage];
21 [scene addChild:backgroundLayer];
22
23 CCLayerColor* backgroundLayer2 = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)];
24 [scene addChild:backgroundLayer2];
25
26 PauseLayer* layer = [[[PauseLayer alloc] initWithScene:scene2] autorelease];
27 [scene addChild:layer];
28
29 return scene;
30}
31
32- (id)initWithScene:(CCScene*)scene
33{
34 self = [super init];
35
36 if (nil != self)
37 {
38 game = [scene retain];
39
40 CCLabelBMFont* scoreLabel = [CCLabelBMFont labelWithString:@"PAUSE" fntFile:@"helvetica.fnt"];
41 scoreLabel.position = ccp(240,90);
42 [self addChild:scoreLabel];
43
44 CCMenuItemImage* pauseButton = [CCMenuItemImage itemFromNormalImage:@"pause2.png" selectedImage:@"pause.png" target:self selector:@selector(unpause)];
45 CCMenu* pauseMenu = [CCMenu menuWithItems:pauseButton, nil];
46 [pauseMenu setPosition:ccp(480-8-16, 320-8-16)];
47 [self addChild:pauseMenu];
48
49 CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(newgame)];
50 CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil];
51 myMenu.position = ccp(240, 60);
52 [self addChild:myMenu];
53 }
54
55 return self;
56}
57
58- (void)unpause
59{
60 [[CCDirector sharedDirector] replaceScene:game];
61}
62
63- (void)newgame
64{
65 [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]];
66}
67
68@end
diff --git a/Classes/TutorialBubble.h b/Classes/TutorialBubble.h new file mode 100644 index 0000000..4ce3352 --- /dev/null +++ b/Classes/TutorialBubble.h
@@ -0,0 +1,29 @@
1//
2// TutorialBubble.h
3// Cart Collect
4//
5// Created by Starla Insigna on 8/4/11.
6// Copyright 2011 Four Island. All rights reserved.
7//
8
9#import <UIKit/UIKit.h>
10#import "cocos2d.h"
11
12@interface TutorialBubble : UIView {
13 UILabel* textView;
14 UIImage* background;
15 UIImageView* imageView;
16 UIImageView* arrowView;
17 UIButton* button;
18 id target;
19 SEL action;
20 NSString* name;
21}
22
23@property (readonly) NSString* name;
24- (id)initWithText:(NSString*)text name:(NSString*)name;
25- (id)initWithText:(NSString*)text name:(NSString*)name spriteReference:(CCSprite*)spriteReference;
26- (void)buttonPressed:(id)sender;
27- (void)setTarget:(id)sender action:(SEL)action;
28
29@end
diff --git a/Classes/TutorialBubble.m b/Classes/TutorialBubble.m new file mode 100644 index 0000000..b85aa31 --- /dev/null +++ b/Classes/TutorialBubble.m
@@ -0,0 +1,177 @@
1//
2// TutorialBubble.m
3// Cart Collect
4//
5// Created by Starla Insigna on 8/4/11.
6// Copyright 2011 Four Island. All rights reserved.
7//
8
9#import "TutorialBubble.h"
10
11@implementation TutorialBubble
12
13@synthesize name;
14
15- (id)initWithText:(NSString*)text name:(NSString*)m_name
16{
17 self = [super init];
18
19 textView = [[UILabel alloc] init];
20 textView.text = text;
21 textView.font = [UIFont systemFontOfSize:14.0f];
22 CGSize size = [textView.text sizeWithFont:textView.font constrainedToSize:CGSizeMake(200, 300) lineBreakMode:UILineBreakModeWordWrap];
23 textView.lineBreakMode = UILineBreakModeWordWrap;
24 textView.numberOfLines = 0;
25 textView.frame = CGRectMake(8, 8, size.width, size.height);
26
27 button = [UIButton buttonWithType:UIButtonTypeCustom];
28 [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
29
30 CGImageRef framestuff = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"framestuff" ofType:@"png"]] CGImage];
31 CGImageRef topLeftRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 0, 8, 8));
32 CGImageRef topRightRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(8, 0, 8, 8));
33 CGImageRef bottomLeftRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 8, 8, 8));
34 CGImageRef bottomRightRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(8, 8, 8, 8));
35 CGImageRef topBorderRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 16, 8, 8));
36 CGImageRef leftBorderRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(8, 16, 8, 8));
37 CGImageRef rightBorderRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 24, 8, 8));
38 CGImageRef bottomBorderRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(8, 24, 8, 8));
39 UIImage* topLeft = [UIImage imageWithCGImage:topLeftRef];
40 UIImage* topRight = [UIImage imageWithCGImage:topRightRef];
41 UIImage* bottomLeft = [UIImage imageWithCGImage:bottomLeftRef];
42 UIImage* bottomRight = [UIImage imageWithCGImage:bottomRightRef];
43 UIImage* topBorder = [UIImage imageWithCGImage:topBorderRef];
44 UIImage* leftBorder = [UIImage imageWithCGImage:leftBorderRef];
45 UIImage* rightBorder = [UIImage imageWithCGImage:rightBorderRef];
46 UIImage* bottomBorder = [UIImage imageWithCGImage:bottomBorderRef];
47 CGImageRelease(topLeftRef);
48 CGImageRelease(topRightRef);
49 CGImageRelease(bottomLeftRef);
50 CGImageRelease(bottomRightRef);
51 CGImageRelease(topBorderRef);
52 CGImageRelease(leftBorderRef);
53 CGImageRelease(rightBorderRef);
54 CGImageRelease(bottomBorderRef);
55
56 CGSize boxSize = CGSizeMake(size.width, size.height);
57
58 UIGraphicsBeginImageContext(CGSizeMake(boxSize.width+16, boxSize.height+16));
59 CGContextRef context = UIGraphicsGetCurrentContext();
60 UIGraphicsPushContext(context);
61 [topLeft drawInRect:CGRectMake(0, 0, 8, 8)];
62 [topBorder drawInRect:CGRectMake(8, 0, boxSize.width, 8)];
63 [topRight drawInRect:CGRectMake(8+boxSize.width, 0, 8, 8)];
64 [rightBorder drawInRect:CGRectMake(8+boxSize.width, 8, 8, boxSize.height)];
65 [bottomRight drawInRect:CGRectMake(8+boxSize.width, 8+boxSize.height, 8, 8)];
66 [bottomBorder drawInRect:CGRectMake(8, 8+boxSize.height, boxSize.width, 8)];
67 [bottomLeft drawInRect:CGRectMake(0, 8+boxSize.height, 8, 8)];
68 [leftBorder drawInRect:CGRectMake(0, 8, 8, boxSize.height)];
69 CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]);
70 CGContextFillRect(context, CGRectMake(8, 8, boxSize.width, boxSize.height));
71 UIGraphicsPopContext();
72 background = UIGraphicsGetImageFromCurrentImageContext();
73 UIGraphicsEndImageContext();
74
75 imageView = [[UIImageView alloc] initWithImage:background];
76 [imageView setFrame:CGRectMake(0, 0, boxSize.width+16, boxSize.height+16)];
77 [button addSubview:imageView];
78 [button addSubview:textView];
79
80 button.frame = CGRectMake(0, 0, boxSize.width+16, boxSize.height+16);
81 [self addSubview:button];
82 self.frame = CGRectMake(240-(boxSize.width+16)/2, 160-(boxSize.height+16)/2, boxSize.width+16, boxSize.height+16);
83
84 name = [m_name retain];
85
86 return self;
87}
88
89- (id)initWithText:(NSString*)text name:(NSString*)m_name spriteReference:(CCSprite*)spriteReference
90{
91 self = [self initWithText:text name:m_name];
92
93 button.frame = CGRectMake(8, 8, button.frame.size.width, button.frame.size.height);
94 self.frame = CGRectMake(0, 0, button.frame.size.width+16, button.frame.size.height+16);
95
96 CGRect spriteBounds = CGRectMake(spriteReference.position.x-spriteReference.contentSize.width/2, 320-spriteReference.position.y-spriteReference.contentSize.height/2, spriteReference.contentSize.width*spriteReference.scale, spriteReference.contentSize.height*spriteReference.scale);
97 CGPoint boxLoc;
98 CGPoint arrowLoc;
99 int arrowRotation;
100
101 if (spriteBounds.origin.y > self.frame.size.height)
102 {
103 arrowRotation = 0;
104
105 if (CGRectGetMidX(spriteBounds) < button.frame.size.width)
106 {
107 boxLoc = CGPointMake(0, spriteBounds.origin.y-self.frame.size.height - 8);
108 arrowLoc = CGPointMake(spriteBounds.origin.x + 4, 8+button.frame.size.height);
109 } else {
110 boxLoc = CGPointMake(CGRectGetMaxX(spriteBounds) - self.frame.size.width, spriteBounds.origin.y-self.frame.size.height - 8);
111 arrowLoc = CGPointMake(button.frame.size.width - spriteBounds.size.width/2 + 4, 8+button.frame.size.height);
112 }
113 } else if (spriteBounds.origin.x > self.frame.size.width)
114 {
115 arrowRotation = 270;
116
117 if (CGRectGetMidY(spriteBounds) < button.frame.size.height)
118 {
119 boxLoc = CGPointMake(spriteBounds.origin.x-self.frame.size.width-8, 0);
120 arrowLoc = CGPointMake(8+button.frame.size.width, spriteBounds.origin.y+4);
121 } else {
122 boxLoc = CGPointMake(spriteBounds.origin.y-self.frame.size.width-8, CGRectGetMaxY(spriteBounds) - self.frame.size.height);
123 arrowLoc = CGPointMake(8+button.frame.size.width, button.frame.size.height - spriteBounds.size.height/2 + 4);
124 }
125 } else if ((480 - CGRectGetMaxX(spriteBounds)) > self.frame.size.width)
126 {
127 arrowRotation = 90;
128
129 if (CGRectGetMidY(spriteBounds) < button.frame.size.height)
130 {
131 boxLoc = CGPointMake(CGRectGetMaxX(spriteBounds), 0);
132 arrowLoc = CGPointMake(0, spriteBounds.origin.y+4);
133 } else {
134 boxLoc = CGPointMake(CGRectGetMaxX(spriteBounds), CGRectGetMaxY(spriteBounds) - self.frame.size.height);
135 arrowLoc = CGPointMake(0, button.frame.size.height - spriteBounds.size.height/2 + 4);
136 }
137 }
138
139 CGImageRef framestuff = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"framestuff" ofType:@"png"]] CGImage];
140 CGImageRef arrowRef = CGImageCreateWithImageInRect(framestuff, CGRectMake(0, 32, 8, 8));
141 UIImage* arrow = [UIImage imageWithCGImage:arrowRef];
142 CGImageRelease(arrowRef);
143
144 arrowView = [[UIImageView alloc] initWithImage:arrow];
145 arrowView.transform = CGAffineTransformMakeRotation(arrowRotation * (M_PI / 180));
146 arrowView.frame = CGRectMake(arrowLoc.x, arrowLoc.y, 8, 8);
147 [self addSubview:arrowView];
148
149 self.frame = CGRectMake(boxLoc.x, boxLoc.y, self.frame.size.width, self.frame.size.height);
150
151 return self;
152}
153
154- (void)buttonPressed:(id)sender
155{
156 [self removeFromSuperview];
157
158 if (target != nil)
159 {
160 [target performSelector:action];
161 }
162}
163
164- (void)setTarget:(id)sender action:(SEL)m_action
165{
166 target = sender;
167 action = m_action;
168}
169
170- (void)dealloc
171{
172 [name release];
173
174 [super dealloc];
175}
176
177@end
diff --git a/Resources/framestuff.png b/Resources/framestuff.png new file mode 100755 index 0000000..3a5c8d0 --- /dev/null +++ b/Resources/framestuff.png
Binary files differ