Cocos2D CCMenu – An Example

By | April 28, 2011

Hi,

While using cocos2D you may need to create some scenes with menu items on it. This example given below shows , how to create a cocos2D menu scene with menu items using images. You can have your own custom fancy image text indicating menu items using this.


//Creating the three menu items.
//You can use different images for selected view & normal view.
//On clicking menu will show selectedImage
CCMenuItemImage *Item1 = [CCMenuItemImage
                        itemFromNormalImage:@"Walk.png"
                        selectedImage:@"WalkTwo.png"
                        target:self
                        selector:@selector(walkAction:)];

CCMenuItemImage *Item2 = [CCMenuItemImage
			           itemFromNormalImage:@"Run.png"
				       selectedImage:@"RunTwo.png"
				       target:self
				       selector:@selector(runAction:)];

CCMenuItemImage *Item3 = [CCMenuItemImage
				       itemFromNormalImage:@"Jump.png"
				       selectedImage:@"JumpTwo.png"
				       target:self
				       selector:@selector(jumpAction:)];

//Adding menu items to the CCMenu. Don't forget to include 'nil'
CCMenu *selectMenu= [CCMenu menuWithItems:Item1, Item2, Item3, nil];
//Aligning & Adding CCMenu child to the scene
[selectMenu alignItemsVertically];
[self addChild:selectMenu];


//Different functions on below get called according to the menu item clicked.
- (void)walkAction:(id)sender
{
    [[CCDirector sharedDirector] replaceScene:[WalkingScene node]];
}

- (void)runAction:(id)sender
{
   [[Director sharedDirector] replaceScene:[runningScene node]];
}

- (void)jumpAction:(id)sender
{
    [[Director sharedDirector] replaceScene:[jumpingScene node]];
}

🙂

93 thoughts on “Cocos2D CCMenu – An Example

  1. webcamsex shemale

    Hello webmaster. I like your blog about Cocos2D CCMenu – An Example | Coderz Heaven.

    But i have a question not related to subject: Do you use a seperate posting program or do you make your blogs in the wordpress admin? If you post your answer here below, i will read this in the next couple of day’s.

    Thanks webcamsex shemale

    Reply
    1. Malik Post author

      @Sennheiser Headphones-> :)very glad to see the nice comment… thank you so much…

      Reply
  2. Benjamin Kirmer

    Fantastic write-up! Very high-quality line between “key phrase stuffing” and using which key phrase(s) in your title, outline, H1, bullets, and paragraphs (alt textual content) on the house web page or various key terms on sub-pages. We normally try to use the main keyword on the house page concerning 5 occasions as naturally as achievable. Various key phrases on sub-pages 2-3 and 2 occasions in blogs. Nick any thoughts on numbers. I realize just about every site is different, but you even now necessity a avenue map and each and every site even now solely has 1 landing web page.

    Reply
  3. Pingback: mmog

  4. Carly Friis

    Nice! Thanx! I always wanted to write in my blog something like that. Would it be OK if I take part of your post to my blog?

    Reply
  5. Danica Coklow

    It’s not that I want to replicate your web-site, but I really like the design. Could you tell me which design are you using? Or was it custom made?

    Reply
  6. Luke Atwater

    Just want to say your article is as astonishing. The clearness in your post is just great and i can assume you are an expert on this subject. Well with your permission allow me to grab your feed to keep up to date with forthcoming post. Thanks a million and please carry on the rewarding work Bogføring

    Reply
    1. Malik Post author

      we will… and thank you for paying attention…

      Reply
  7. gential warts

    Hi there, just located your website through Google, and located it to be really informative. Cheers!

    Reply
  8. electric wall heaters

    There are some interesting points in time in this article but I don’t know if I see all of them center to heart. There is some validity but I will take hold opinion until I look into it further. Good article , thanks and we want more! Added to FeedBurner as well

    Reply
  9. Great Wolf Lodge Coupons

    Hi I absolutely dig this article and it is too informational so I am gonna save. One thing to say the Superb research you have done is greatly exceptional . No one does that additional research these days? Bravo 🙂 Also one more suggestion to you is that you caninstall any Translator for your Global Audience 🙂

    Reply
  10. image capture

    I do not even know how I ended up here, but I thought this post was great. I do not know who you are but definitely you’re going to a famous blogger if you aren’t already 😉 Cheers!

    Reply
    1. Soorya

      great inspirational comment friend.Hope we can achieve that

      Reply
  11. Great Wolf Lodge Coupons

    Hello I absolutely like your article and it has been so excellent thus I am gonna save. One thing to say the Superb research you have done is trully exceptional !! Who goes that extra mile these days? Hats off to You !!! Also another tip you definetlyget any Translator for your Global Users .

    Reply
  12. dota 2 release date

    This internet site is really a walk-through for all the info you wanted about this and didn’t know who to ask. Glimpse here, and you will actually find it.

    Reply
  13. costume queen

    Good write-up, I am normal visitor of one’s web site, maintain up the excellent operate, and It is going to be a regular visitor for a long time.

    Reply
  14. Malik Post author

    @Dota 2 Release Date-> that’s what we intended for…

    Reply
  15. QRP

    I was very pleased to find this web-site.I wanted to thanks for your time for this wonderful read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you blog post.

    Reply
  16. halloween

    Good web site! I truly love how it is easy on my eyes and the data are well written. I’m wondering how I could be notified when a new post has been made. I’ve subscribed to your RSS which must do the trick! Have a nice day!

    Reply
  17. how to make jar candles

    Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed surfing around your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon!

    Reply
  18. Southwest Promo Code

    Man I like this comment and it was so fabulous and I am definetly going to save it. I Have to say the Superb analysis you have done is greatly remarkable.No one goes that extra mile these days? Bravo!!! Just another suggestion you caninstall a Translator for your Worldwide Readers !

    Reply
  19. Marry Nohe

    I am curious to find out what blog system you’re using? I’m having some small security problems with my latest site and I would like to find something more safe. Do you have any recommendations?

    Reply
  20. Hotels in Athens

    Excellent blog here! Also your website loads up fast! What web host are you using? Can I get your affiliate link to your host? I wish my web site loaded up as quickly as yours lol

    Reply
  21. Pests Control Gramercy  NYC

    Hello, you used to write fantastic, but the last few posts have been kinda boring… I miss your tremendous writings. Past few posts are just a little out of track! come on!

    Reply
  22. Athens Hotels

    Great artical, I unfortunately had some problems printing this article out, The print formating looks a little screwed over, something you might want to look into.

    Reply
  23. how to eradicate bed bugs upper west side

    I do not even know how I ended up right here, however I believed this post was good. I do not realize who you are but definitely you are going to a famous blogger if you are not already 😉 Cheers!

    Reply
  24. tmj surgery

    I’m not sure where you’re getting your info, but great topic. I needs to spend some time learning much more or understanding more. Thanks for fantastic information I was looking for this information for my mission.

    Reply
  25. my asian gf

    Like any blog article I always have an opinion and I like this one so I subscribed to your RSS This is very intresting. I have joined your feed and look forward to seeking more of your great post.

    Reply
  26. Framingham Realtor

    I discovered this site by performing a key phrase look for my niche. I am so glad I stumbled on your site. You’ve yourself a loyal reader now.

    Reply
  27. caring for roses

    Lovely site! I am loving it!! Will be back later to read some more. I am bookmarking your feeds also

    Reply
  28. 02 Sim Cards

    I enjoy the helpful information you produce in your posts. I’ll bookmark your site and check again here frequently. I’m quite sure I will learn lots of new information right here.

    Reply
  29. Pingback: Kasper Suits

  30. centro benessere

    First-class news it is surely. I have been waiting for this information.

    Reply
  31. Sanjuana Lairson

    Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that.

    Reply
  32. Landmann Gasgrill

    Hey there just wanted to give you a quick heads up. The text in your post seem to be running off the screen in Firefox. I’m not sure if this is a format issue or something to do with browser compatibility but I figured I’d post to let you know. The layout look great though! Hope you get the problem resolved soon. Thanks

    Reply
  33. Lorelei Herner

    Do you want to consider interchanging hyperlinks?

    Reply
  34. videosxxx

    Eye-catching document, but in my perspective question haven’t been exhausted. I hope for further development of the topic, I’ll be watching for sequential entries. I look forward to additional entries.

    Reply
  35. bed bugs nyc

    Normally I don’t learn post on blogs, however I would like to say that this write-up very compelled me to check out and do so! Your writing taste has been amazed me. Thank you, quite great post.

    Reply
  36. fumigation new york city

    hi!,I like your writing so much! proportion we communicate more approximately your post on AOL? I need an expert on this space to resolve my problem. May be that’s you! Having a look ahead to look you.

    Reply
  37. patek phillippe

    excellent article, very related to my interest thank you so much

    Reply
  38. sennheiser headphone

    After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.

    Reply
  39. pest control price ny

    I have been exploring for a little bit for any high quality articles or blog posts on this kind of house . Exploring in Yahoo I finally stumbled upon this site. Reading this info So i am satisfied to exhibit that I’ve a very just right uncanny feeling I discovered just what I needed. I so much definitely will make sure to do not overlook this web site and give it a glance a continuing.

    Reply
  40. trucos guerras tribales

    dude, this is so cool you are a pro blogger

    Reply
  41. Elisa Jazwa

    I’m not sure if you notice this but, your blog isn’t working in internet explorer.

    Reply
  42. Linh Morelen

    I was suggested this web site by my cousin. I am not sure whether this post is written by him as nobody else know such detailed about my problem. You are amazing! Thanks!

    Reply
  43. exterminators nyc

    I truly appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thx again!

    Reply
  44. Health Insurance

    Good website! I really love how it is nice on my eyes it is. I am wondering how I could be notified when a new post has been made. I’ve subscribed to your feed which may do the trick? Have a great day!

    Reply
  45. Margret

    Hey what theme do you use for your blog ? I just stumbled on it and think it would work well on one of my website. Cheers

    Reply
  46. Melvin

    Spot on with this write-up, I truly assume this web site wants far more consideration. I’ll probably be once more to read much more, thanks for that info.

    Reply
  47. Goerge

    Thank you for another informative blog. Where else could I get that type of info written in such a perfect way? I have a project that I’m just now working on, and I have been on the look out for such info.

    Reply
  48. Lissa Segawa

    fantastic post, very informative. I wonder why the other experts of this sector do not notice this. You should continue your writing. I am confident, you have a great readers’ base already!

    Reply
  49. Dan

    Do you people have a facebook or twitter fan page? I searched for one on facebook or myspace but could not discover one, I would love to become a fan!

    Reply
    1. James

      Hello Dan,
      We are already there on Facebook and twitter, just search for coderzheaven.

      Reply
  50. buy phentermine

    Hiya! You some sort of expert? Great message. Are you able to inform me how you can subscribe your weblog?

    Reply
  51. personal trainer

    Utterly indited subject matter, Really enjoyed reading .

    Reply
  52. fix bad credit

    Thanks for an concept, you sparked at thought from a angle I hadn’t given thoguht to yet. Now lets see if I can do something with it.

    Reply
  53. den kinesiske mur bredde

    Dude, this blog is awesome! Just my 2 Cents!

    Reply
  54. Rosario Bellinder

    I hadn’t been utilizing my rss reader for a whilst and I have a substantial backlog of stuff to catch up on. pleased to have taken the time to catch up on your blog though. Cheers.

    Reply
  55. John

    My spouse and I across here by a another web address plus thought We should check it out. We enjoy Cocos2D CCMenu – An Example | Coderz Heaven and what I see therefore now I am following you. Looking forward to looking into the blog page Cocos2D CCMenu – An Example | Coderz Heaven again Moreover my best feelings go out to the people at Japan hopefully you are ok plus free from danger Web Site Builders !!!

    Reply
  56. Maisie Bacher

    So, are you going to follow up on this article, I’ve been checking back often.

    Reply
  57. Pingback: Tahari Dresses

  58. Benny Kady

    I’m having a strange problem I cannot make my reader pick up your feed, I’m using google reader by the way.

    Reply
  59. Pingback: Pokemon online

Leave a Reply

Your email address will not be published.