Your first iPhone Game in Cocos2D – Part 1: Menus and Transitions

First-Game-Cocos2D-SliderImg First-Game-Cocos2D-SliderImg
First-Game-Cocos2D-SliderImg First-Game-Cocos2D-SliderImg
In this tutorial i’m going to show you how to create a simple but very comprehensive for beginners game in Cocos2D for the iPhone. This first part is going to focus on the Cocos2D basics and how to create menus, scenes and transitions between them.

I n this tutorial i’m going to show you how to create a simple but very comprehensive for beginners game in Cocos2D for the iPhone. This first part is going to focus on the Cocos2D basics and how to create menus, scenes and transitions between them.


Before you go on:

You need to have installed the iPhone SDK and the Cocos2D framework for iPhone. If you don’t know what i’m talking about or you know but you don’t have either of them installed you should check http://www.oscarvgg.com/installing-cocos2d-for-iphone/ before reading this tutorial.

I’ll assume that you have basic knowledge of programming and a minimal knowledge of the Objective-C language (by minimal i mean creating variables, methods and call them, classes, instance objects, etc.) and use of Xcode. This tutorial is focused in Cocos2D only.

I´ll also assume that you understand the basic concepts of the Cocos2D framework like what is a “scene”, the “director”, a “layer” and a “sprite”. If you don´t, then go to http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:basic_concepts, there you´ll find all the information you need to understand how Cocos2D works.


Creating a new Cocos2D project.

Open Xcode and click on File->New Proyect. Then select “User Templates” in the left sidebar of the “New Project Window” and double click “Cocos2d Aplication”.

The Programmer Lifestyle - Your first Game in Cocos2D image 1

Give a name to your project. I’m going to call mine: “FirstGame”.


Understanding the App Delegate.

In “Groups and Files”, double click on classes to expand it and then click on [Your game Name]AppDelegate.m, mine is FirstGameAppDelegate.m.

The Programmer Lifestyle - Your first Game in Cocos2D image 2

This file is the most important of your app, it is responsible for managing all your application behaviors for all the different states it can have, as all it’s methods are listeners for Application Events. For Example, if your app goes to background, the AppDelegate automatically runs the method applicationDidEnterBackground.

The first method you’ll find in the implementation file of the FirstGameAppDelegate class is applicationDidFinishLaunching. This method, as it’s name says it, runs when you launch your app. At the beginning it creates an instance of a the director, the one that handles everything that has to do with the scenes.

In the next line it sets the initial orientation of the screen. By default it is set to landscape-left with kCCDeviceOrientationLandscapeLeft, you can change it to landscape-right with kCCDeviceOrientationLandscapeRight, to portrait with kCCDeviceOrientationPortrait or even to portrait-upside down with CCDeviceOrientationPortraitUpsideDown. For now i’m going to leave it like it is.

The last line of the method is [[CCDirector sharedDirector] runWithScene: [HelloWorld scene]];, it tells the director with what scene is the application going to start, in this case it is “HelloWorld”.

The Programmer Lifestyle - Your first Game in Cocos2D image

Creating the Gameplay layer.

Click on File->New File… click on “User Templates”, “Cocos2D 0.99.4” and double click CCNode Class.

The Programmer Lifestyle - Your first Game in Cocos2D image 4

I’ll call my new class “GamePlay”, you can give it the name you want (just make sure it has the .m extension) and click Finish.

The Programmer Lifestyle - Your first Game in Cocos2D image 5

Now open GamePlay.h, make it extend CCLayer and add the scene method. It should look like this:

1
2
3
4
5
6
#import Foundation/Foundation.h;
#import "cocos2d.h";
@interface GamePlay : CCLayer {
}
+(id) scene;
@end

In GamePlay.m, add the implementation of the scene method and an empty init method, like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+(id) scene {
    // 'scene' is an autorelease object.
    CCScene *scene = [CCScene node];
    // 'layer' is an autorelease object.
    GamePlay *layer = [GamePlay node];
    // add layer as a child to scene
    [scene addChild: layer];
    // return the scene
    return scene;
}
 
-(id) init {
    if( (self=[super init] )) {
    }
    return self;
}

We just created the scene where our gameplay is going to be but we are not going to add it for now, you’ve got to wait for part 2.


Creating a menu.

Open HelloWorldScene.m and find the init method. Erase everything within “if( (self=[super init] ))” and let’s create a menu in it’s place. If you are a little lost, don’t worry, it is normal. HelloWord is  the first scene that the user is going to see when the app starts, this menu comes to be the main menu of the game.

First we have to set the font, type:

1
[CCMenuItemFont setFontName:@"Marker Felt"];

I chose “Marker Felt”, you can use other font that you like.

Next we set the size, i want it to be 35.

1
[CCMenuItemFont setFontSize:35];

Now we are going to create a menu item. This item is what is going send us to the gameplay when selected.

1
2
3
CCMenuItem *Play = [CCMenuItemFont itemFromString:@"PLAY" 
                    target:self 
                    selector:@selector(goToGameplay:)];

I called it Play, but it is just the name of the object, in the screen it is going to say “PLAY” because i’m passing itemFromString:@”Play”. We are targeting self and we are saying that the method that is going to be executed when the user tab “Play” is “goToGameplay” as selector:@selector(goToGameplay:)], but we haven’t created it yet, we can worry about that later, for now let’s finish with the menu.

By now we have just defined a menu item, not the menu itself. So we have to create a ccmenu object and add the Play item to it:

1
CCMenu *menu = [CCMenu menuWithItems: Play, nil];

You can add as many items as you want but never forget to add nil at the end of the list.

Let’s position the menu to the center of the screen

1
menu.position = ccp(240, 160);

(240, 160) is the center of the screen of every iPhone-iPod touch, even those who has retina display. Cocos2D works with points, not pixels, points. If you are using an iPhone-iPod touch previous to iPhone 4, a point is equivalent to one pixel, if not, you are using a devise with retina display, in that case a point is equivalent to four pixels, so the screen of every iPhone-iPod touch is 480×320 points, you don’t have to worry about the resolution of the screen, Cocos2D takes care of that. (Retina display resolution is 960×640 and it has the same 3.5-inch (diagonal) screen as earlier iPhones).

If you are working with an iPad, your resolution is 1024×768 and the center of your screen is 512×384 pixels so you have to position the menu at cpp(512, 384).

And finally we say the scene to add the menu to itself.

1
[self addChild:menu];

Your init method should look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-(id) init {
 
    // always call "super" init
    // Apple recommends to re-assign "self" with the "super" return value
    if( (self=[super init] )) {
 
        [CCMenuItemFont setFontName:@"Marker Felt"];
        [CCMenuItemFont setFontSize:35];
 
        CCMenuItem *Play = [CCMenuItemFont itemFromString:@"Play" 
                                           target:self
                                           selector:@selector(play:)];
 
        menu.position = ccp(240, 160);
        [menu alignItemsVerticallyWithPadding:10];
        [self addChild:menu]; 
    } return self;
}

Switching to Gameplay with transition:

In order to switch to the gameplay scene you have to create the goToGameplay method. But before that, don’t forget to import the gameplay scene, if you do, Xcode is not going to know what is gameplay and is going to insult you. You just have to type #import “GamePlay.h” at the beginning of the code.

Ok, type:

1
2
-(void) play: (id) sender {
}

Now we tell the director to replace the scene with this line of code:

1
2
3
4
5
[[CCDirector sharedDirector]
    replaceScene:[CCFadeTransition transitionWithDuration:1 
                                   scene:[GamePlay node]
                 ]
];

We are saying: “Use the transition CCFadeTransition lasting one second to replace this scene with Gameplay scene”, easy as pie.

You can use other transitions like CCShrinkGrowTransition or CCPageTurnTransition among others that i don’t remember. To learn more about transitions types you can always check the API documents.

After the last step, your HelloWorldScene.m file should look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#import "HelloWorldScene.h"
#import "GamePlay.h"
 
// HelloWorld implementation
@implementation HelloWorld
+(id) scene {
    // 'scene' is an autorelease object.
    CCScene *scene = [CCScene node];
    // 'layer' is an autorelease object.
    HelloWorld *layer = [HelloWorld node];
    // add layer as a child to scene
    [scene addChild: layer];
    // return the scene
    return scene;
}
 
// on "init" you need to initialize your instance
 
-(id) init {
    // always call "super" init
    // Apple recommends to re-assign "self" with the "super" return value 
    if( (self=[super init] )) {
 
        [CCMenuItemFont setFontName:@"Marker Felt"]; 
        [CCMenuItemFont setFontSize:35];
        CCMenuItem *Play = [CCMenuItemFont itemFromString:@"Play"
                                           target:self
                                           selector:@selector(goToGameplay:)]; 
 
        CCMenu *menu = [CCMenu menuWithItems: Play, nil]; 
        menu.position = ccp(240, 160);
        [menu alignItemsVerticallyWithPadding:10];
        [self addChild:menu]; 
    }
 
    return self;
}
 
-(void) goToGameplay: (id) sender { 
 
    [[CCDirector sharedDirector] 
           replaceScene:[CCTransitionFade
               transitionWithDuration:1 
               scene:[GamePlay node]
           ]];
}
 
// on "dealloc" you need to release all your retained objects 
- (void) dealloc { 
    // in case you have something to dealloc, do it in this method 
    // in this particular example nothing needs to be released. 
    // cocos2d will automatically release all the children (Label) 
    // don't forget to call "super dealloc"
 
    [super dealloc]; 
} 
@end

Testing the app:

Click build and run.

The Programmer Lifestyle - Your first Game in Cocos2D image 6

If you did everything well your iphone simulator should open and display the menu that we’ve created.

The Programmer Lifestyle - Your first Game in Cocos2D image 7

When you click Play, it should take you to our empty gameplay scene, it is a black square because we haven’t added anything to it yet.

The Programmer Lifestyle - Your first Game in Cocos2D image

Conclusion:

In this tutorial we have learned how to create a Cocos2D app from a template, we understood how the director works and how to create a scene, a menu and how to add transitions between scenes.

In the next part i will show you how to create a pause scene for the gameplay, how to add sprites and backgrounds to scenes.

Until then.

Go forward: Your first Game in Cocos2D – Part 2: Sprites and More Transitions
Or if you feel ready: Your first Game in Cocos2D – Part 3: The Gameplay

Tags: , , , , , , , , , , , , , , , , , , , ,

Software Engineer and iOS developer, from Caracas, Venezuela, with a tremendous weakness for hamburgers.

81 Responses to “Your first iPhone Game in Cocos2D – Part 1: Menus and Transitions” Subscribe

  1. Peter September 29, 2010 at 4:27 AM #

    Hi Oscar,
    Thank you for this tutorial, when do you think the next one will be up?

    -Peter

    • OscarVGG September 29, 2010 at 11:20 AM #

      i believe this weekend i’ll Finish writing it…

  2. Peter September 29, 2010 at 12:28 PM #

    great to hear, I am aching to get on with it :)

  3. Paul September 29, 2010 at 2:59 PM #

    Thanks for the simple tut. Can’t wait to see the next!

  4. watch full movies online September 30, 2010 at 11:33 AM #

    I want to thank you for your efforts you have made in making this blog. I am hoping the same good work from you in the future as well. In fact your great writing abilities has inspired me to start my own blog. Really the blogging is spreading its wings rapidly. Your content is a fine example of it.

    • OscarVGG September 30, 2010 at 1:55 PM #

      Thanks for your comments. It is always good to know that your work is inspiring other people.

  5. Miguel September 30, 2010 at 10:54 PM #

    Dude, I absolutely loved reading this blogpost. You have convinced me to subscribe to your blog, but where can I find the RSS feed?

  6. Tony October 1, 2010 at 4:04 PM #

    Thank you for the great tutorial. It is the best explanation if some of these concepts Ive seen yet.

    I would love to see something from you talking about accessing and moving layers vs the camera. This is something I am having a hard time getting to work correctly.

  7. Free online dating October 2, 2010 at 9:58 PM #

    Hello – I must say, I’m impressed with your site. I had no trouble navigating through all the tabs and information was very easy to access. I found what I wanted in no time at all. Pretty awesome. Would appreciate it if you add forums or something, it would be a perfect way for your clients to interact. Great job!

    • OscarVGG October 3, 2010 at 1:46 AM #

      Thanks for your good comments, I appreciate that people value my work.

      I’m actually working in a forum for the site right know, i don’t know when it’s going to be finished, i’m taking my time because i wan’t it to look good.

  8. Tomato Planter Upside Down October 4, 2010 at 3:11 PM #

    I came across this website trying to find some answers to my question about summer gardening. This blog wasn’t exactly what I was trying to find, it did manage to help answer some of my more unrelated questions that I wasn’t able to find an answer to some time ago. I’m impressed by your viewpoint as well. :D

  9. droid x phone case October 4, 2010 at 5:53 PM #

    Reading this reminds me of my old room mate. That guy was one of the smartest characters I know, but he was a little beatnik for my tastes though. Anyways I liked reading this, thanks. Will give me something to talk about when I see him.

  10. Velma Dural October 5, 2010 at 1:19 PM #

    This is the first blog I read on my new Ipad. I’ll be back.

  11. Valentin Miscavage October 8, 2010 at 3:54 PM #

    Thanks, do you happen to have a facebook i can follow up? really interested.cya

  12. wczasy nad morzem October 8, 2010 at 6:11 PM #

    Thanks For Your post, was added to my bookmarks.

  13. Panamafoto October 9, 2010 at 5:17 AM #

    Kudos from one brainiac to another. :)

  14. Gidget Nitzschke October 9, 2010 at 7:29 AM #

    Very nice post.

  15. Emo October 9, 2010 at 8:01 PM #

    I actually think so too:P I have been searching around the web for some time today, and its really hard to find something good to read on blogs=P Maybe thats because there are too much of those around =) But this website actually keeps catching my attention=) Great posts, and kawai design ^__^. Ill be sure to give it more time now =]

  16. tirage tarot gratuit October 10, 2010 at 8:49 AM #

    Thanks for this page. I’ve read it in the metro with my phone and found it very interesting.

  17. sale blackfriday 2010 October 12, 2010 at 12:12 PM #

    Many thanks very much for the info. I have been looking for this for a while with Bing and it has been a true undertaking.

  18. lymph nodes October 12, 2010 at 2:04 PM #

    Hi, Thanks for the awesome post you have! Im following your blog now

  19. Abortion Clinic October 14, 2010 at 4:40 AM #

    Great wordpress blog here.. It’s hard to find quality writing like yours these days. I really appreciate people like you! take care and see you soon

  20. Big Bang Theory October 14, 2010 at 5:30 AM #

    This is a great knowledge. Thank you very much for sharing those post. I will absolutely check it out.

  21. Hot Daily News October 14, 2010 at 6:29 PM #

    I love the way you write and also the theme on your blog. Did you code this yourself or was it done by a professional? I’m very very impressed.

    • OscarVGG October 14, 2010 at 9:08 PM #

      Yes, it was done by a professional: me. I Hope this is not spam, sorry if your intensions are real.

      Thanks anyway!

  22. Jake Konecny October 14, 2010 at 10:53 PM #

    Freakin nice blog.

  23. christmas gifts for dad October 15, 2010 at 11:48 AM #

    Aw, this was a really quality post. In theory I’d like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate alot and never seem to get something done.

  24. Kristofer Torrance October 16, 2010 at 5:58 PM #

    man please more more more of this stuff

  25. test equipment leasing October 16, 2010 at 8:54 PM #

    shares utilize a excellent web-site decent Gives thanks for the working hard to guide me

  26. eason insurance October 17, 2010 at 6:10 AM #

    Maybe the top post I have read ever!!!

    Jodi

  27. Ong Swee Pie November 6, 2010 at 12:28 PM #

    I tried this tutorial, followed the instructions and found that the game autoquits when it is run. After analyzing the code and tutorial I found that there was a part of this tutorial which is a bit misleading.

    The part is:

    at the Switching to Gameplay with transition part of the tutorial we are told to type :
    -(void) play: (id) sender {
    }

    It should be :
    -(void) goToGameplay: (id) sender {
    }

    Good thing there’s a “how the code should look like part” so I could compare my code. LOL

    Good tutorial BTW Thumbs up :D

    • OscarVGG November 7, 2010 at 10:56 PM #

      Thanks for your correction, sometimes i modify the code in Xcode but I forget to change the text of the tutorial… :S

  28. Andrew November 8, 2010 at 7:11 AM #

    Hi,

    Thanks for taking the time to explain the basics of getting Cocos up and running, much appreciated. Just a quick note, on the section ‘Creating a Menu’ and the bottom, where you show the code listing entitled ‘Your init method should look like this:’ you don’t declare the menu variable. Nothing major, but made me chuckle a little, as you did include it in the breakdown above it. Anyway, thanks again for a very helpful article.

  29. udaykanth December 12, 2010 at 6:58 AM #

    Can you please upload the source code for this

  30. Mr.Brian Design December 15, 2010 at 9:44 PM #

    Hi Oscar,
    This tutorial was very easy to follow. The build succeeded but then
    -Got an error message about Base SDK not available (?) something in the (Active Executable Menu)
    -I changed Xcode Project Settings (Base SDK for All Configurations) to iOS 4.0 simulator
    and Project Format: Xcode 3.2 compatible

    The app launched in iPhone simulator but it Show the Cocos logo (full screen) then switched to landscape view and displayed only the cocos icon.

    When I selected iOS Simulator 3.2 and build/run, The iPad simulator opened and did the same thing.

    Any idea what I am doing wrong here?

  31. Thromordyn December 17, 2010 at 1:08 PM #

    *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil’

    Something tells me that’s not supposed to happen. After the first failure, I copied your code exactly, fixed the spacing (which doesn’t actually matter in C), and it gave me that again. And again.

    • Thromordyn December 20, 2010 at 10:47 AM #

      Pay me no mind. I entered
      - (void)play:(id)sender {
      instead of
      - (void)goToGameplay:(id)sender {

      No idea how I did that, but there you go.

  32. Dan December 31, 2010 at 11:48 PM #

    When I tried to build the code I got an error on CCFadeTransition with a litte looking found that it should have been CCTransitionFade

  33. ahmad January 10, 2011 at 7:00 PM #

    Help… Im getting a CCFadeTransition Undeclared error…

    • OscarVGG July 12, 2011 at 5:23 PM #

      Version issue. The answer is posted later

  34. Matt January 26, 2011 at 7:01 PM #

    Hi,

    Excellent tutorial so far. I just noticed an error in this line:

    [[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:1 scene:[GamePlay node]]];

    CCFadeTransition should be CCTransitionFade. Just a small mistake.

    Going to continue with the tutorial. I’ll let you know if there are any more errors.

    • OscarVGG July 12, 2011 at 5:17 PM #

      Is a version issue

  35. Pradeep February 3, 2011 at 7:48 AM #

    Great tutorial, but stil i got an error
    “/Documents/FirstGame/Classes/HelloWorldScene.m:61: error: ‘CCFadeTransition’ undeclared (first use in this function)”

  36. zoran February 3, 2011 at 8:10 PM #

    found 5 errors in the code when i try to run simulator after 1st step…

    in your tut for example, theres differences between what you’re putting down step by step to add between “if( (self=[super init] ))” in HelloWorldScene.m and your example of what it should look like, also i don’t fully know what i’m doin just yet, so if you’d include the source code for your tut series it would be really awesome for all us ubber noobs… respect!

    • OscarVGG July 12, 2011 at 5:15 PM #

      I’ll think about it… I believe you learn more when you try to fix the problem yourself instead of using already written code… But definitively going to think about it!

  37. Yimmie February 20, 2011 at 9:58 PM #

    First thanks for posting this it’s super helpful. However, I am receiving this error and I’m not sure how to get around it. Where should I declare ‘CCFadeTransition’?

    …/HelloWorldScene.m:64: error: ‘CCFadeTransition’ undeclared (first use in this function)

    • Yimmie February 22, 2011 at 2:03 PM #

      I found the problem. I should have been calling CCTransitionFade rather then CCFadeTransition. That seems to have fixed it.

  38. Alejandra February 21, 2011 at 4:12 PM #

    hey =D your blog is great.
    I had a little trouble to compile this =C
    it sends the error: ‘CCFadeTransition’ undeclared
    I tried using the other that you menction but it always says the same, could you help me?

  39. Randumb February 21, 2011 at 7:14 PM #

    When I build and run I get 1 error: CCFadeTransition undeclared (first use in this function). Obviously it needs to be used somewhere else in the function, but I am a noob and am not sure how to solve this. Help would be appreciated!

    • OscarVGG July 12, 2011 at 5:08 PM #

      They changed it to CCTransitionFade in the new version…

  40. Boat Cover February 24, 2011 at 6:40 AM #

    Wonderful article post on the blog bro. This particular is just a tremendously nicely structured blog post, just the data I was looking just for. Thank you.

  41. tursesePoth March 5, 2011 at 6:54 PM #

    Hi. I like your website but i can tell it probably isn’t getting much traffic? If you want to help imrpove that check this website out, he has a short video that i really suggest you watch. Commission Crusher P.S this isn’t my website and i’m not spamming your blog, i don’t care if you delete this comment. I am only trying to help you improve your site.

  42. KML April 3, 2011 at 7:06 PM #

    Oscar, thank you very much for posting these tutorials!

    I was able to get this one working with Xcode 4 and the RC of Cocos2d (cocos2d-iphone-1.0.0-rc.tar.gz) with just a few changes:

    1. In my project template I didn’t have HelloWorldScene.m or .h so I used HelloWorldLayer.m and .h

    2. I had to manually create the GamePlay.m and .h files; the Cocos2d file templates aren’t ready yet for Xcode 4. Perhaps I missed them but if you could post the source code for the files in the tutorial that would likely help many people.

    3. CCFadeTransition is now CCTransitionFade

  43. Boogle April 11, 2011 at 2:37 PM #

    Great tutorial but:

    [[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:1 scene:[GamePlay node]]];

    should be:

    [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1 scene:[GamePlay node]]];

  44. sj VOIP June 2, 2011 at 9:29 PM #

    ip pbx system to curl until flights to new jersey.

  45. Mike June 9, 2011 at 11:31 AM #

    Hi Oscar,
    One minor correction in goToGameplay:

    [[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:1 scene:[GamePlay node]]];

    should be:

    [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1 scene:[GamePlay node]]];

    • OscarVGG July 12, 2011 at 12:33 PM #

      Yes, it changed in the new version. i’ll update it as soon as possible

  46. Digital Workshed June 13, 2011 at 10:16 AM #

    CCFadeTransition has been changed to CCTransitionFade in the latest version of cocos2d

    • OscarVGG July 12, 2011 at 12:28 PM #

      Thanks for clarification. Stay around, we may need you!

  47. Wm Horkey June 22, 2011 at 8:24 AM #

    Hey! I know this is somewhat off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having trouble finding one? Thanks a lot!

    • OscarVGG July 12, 2011 at 12:16 PM #

      It’s in the wordpress plugins list. You can find it in the Plugins section of the admin panel.

  48. Dudley Presley July 1, 2011 at 9:51 AM #

    Incredibly maintained and respected net directory. Rid entry and moderation. Augment your relation and you inclination feel the power of our directory. setakowa.

  49. Kath July 6, 2011 at 11:07 AM #

    The code compiles (with the updated CCTransitionFade reference) in Xcode 3.2.6 and cocos2d 0.99.5, but it crashes before the “Play” menu displays. I am trying to figure it out but am not very familiar with the debugger. Thank you for the tutorial! Hopefully I can figure it out as I familiarize myself with Objective C and cocos2d.

  50. Paul August 14, 2011 at 7:25 PM #

    Hello Oscar, I love your tutorial, but I keep getting errors and I have no idea what I’m doing wrong. The errors are:

    In GamePlay.m:
    LLVM GCC Error: no super class declared in @interface for ‘GamePlay’

    Sematic Issue: no super class declared in @interface for ‘GamePlay’

    Cannot find interface declaration for ‘GamePlay’

    Warning: ‘GamePlay’ may not respond to ‘-addChild:z:’

    In PauseScene.m:
    Parse Issue: Expected identifier

    Warning: ‘CCTransitionFade’ may no respond to ‘+transitionWithDuration

    -Please Help, I have no idea what I’m doing!

    • OscarVGG August 24, 2011 at 5:01 PM #

      You may have forgotten to extend or inherit form CCLayer or something like that…

      Let me know if you could fix it.

  51. Paul August 27, 2011 at 7:02 PM #

    I’m sorry, but could you elaborate some more? I don’t know where to put such things.

Trackbacks/Pingbacks

  1. The Programmer Lifestyle - October 3, 2010

    [...] If you are not following this series it would be helpful if you read first the previous part: http://www.oscarvgg.com/your-first-game-in-cocos2d-part-1-menus-and-transitions/ [...]

  2. The Programmer Lifestyle - October 12, 2010

    [...] http://www.oscarvgg.com/your-first-game-in-cocos2d-part-1-menus-and-transitions/ [...]

  3. http://%/bvyfdee - November 21, 2010

    … trackback …..

    R¨¦el succ¨¨s disponible en petit portions jour apr¨¨s jour. Vous devrez faire plaisir de la vie quotidien peu tr¨¦sor doudoune moncler http://doudouneeddy.blog-libre.net/ doudoune monclerIl est crucial chose dans la mesure du succ¨¨s…

  4. http://%/bvwrteo - November 21, 2010

    … trackback …..

    Excellent morceau de contenu mat¨¦riel, c’est-¨¤-dire tr¨¨s semblable ¨¤ un site Web que j’ai. Veuillez tester les un jour et volontiers s’en aller m’a comenet sur elle et dire me ce que vous pensez. moncler http://doudounebadia.skyrock.com/ doudou…

  5. jelqing - April 16, 2011

    Very nice!…

    Wow you are very very talented!! keep up the awesome work. You are very talented & I only wish I could write as good as you do :)

  6. Matilde - June 12, 2011

    hello…

    really good article. Ready to hear more next week,my blog http://talonmpgraham.blog.ca/2011/06/12/adressing-wedding-invites-envelopes-11302585/ Many Thanks….

  7. TadWinett - June 16, 2011

    really good article…

    I have spent a bit of time going through your posts, more than I should have but I must say, its worth it! http://blue071.speedywap.net/?p=5 many Thanks….

  8. Khantelle - June 20, 2011

    hello…

    Hello there thanks for the quality post! http://alva11.blogs.sapo.pt/ ,i’d a great read.thank you for your article,My problem continues to be resolved….

  9. Kenzing - June 20, 2011

    very helpful…

    I preferred to thank you for this good article. http://qmdxb.mijnweblog.eu/ I by all odds liked every little bit of it…

  10. Benzing - June 21, 2011

    Great…

    You did a great job! http://denisse.mojblog.hr/p-an-available-letter-to-victorias-secret/221144.html

  11. Eugenie - June 22, 2011

    Great…

    You did a great job! http://davida.novoblog.com/blog/gnral/2011/06/20/tom-fords-bubbles-at-selfridges-video

  12. Frederic - June 26, 2011

    quality post…

    I have spent a bit of time going through your posts! http://denice.glowindia.com/Blog-Entry/why-tom-fords-beard-sells-makeup ,i had a good read….

  13. Dehmer - June 27, 2011

    Greate…

    It’s such a great site! http://www.gather.com/viewArticle.action?articleId=281474979501921 Great post, I just bookmarked it on Digg….

Leave a Reply

 

Marketie – Build your brand on twitter


The last few weeks a friend and I have been working on an app to help people market their brand [...]

First Look: Foundation Framework


Foundation is a framework for prototyping flexible web pages quickly and for any devices. It was created by ZURB, a U.S. [...]

Cocos2D Tips: Performance: CCSprite


Older iDevices (previous to iPhone 3GS) used to store images in power-of-two sizes of length and width. This means that [...]

Guess who’s back?


People is reading less, that’s a fact!. So blogs with very long posts are almost obsolete, at least in the [...]

How to make an iPhone App – Part 5: The Accelerometer


Yes, your iPhone has an accelerometer. I know this is not a physics class but the best way to define it is saying that it is a device to detect the magnitude and direction of acceleration. iDevices uses it to detect rotation, shake gestures, among others.

How to make an iPhone App – Part 4: Navigation Controller


Now that we know how to create a table views, we are going to use that knowledge to create a new project using a navigation controller to see a more detailed view of the tittle in the cell of the table view.