Cocos2D CCMenu – An Example

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. 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

  2. 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.

  3. Pingback: mmog
  4. 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?

  5. 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?

  6. 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

  7. 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

  8. 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 :)

  9. 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!

  10. 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 .

  11. 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.

  12. 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!

  13. 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!

  14. 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 !

  15. 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?

  16. 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

  17. 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!

  18. 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.

  19. 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!

  20. 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.

  21. 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.

  22. 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.

  23. 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.

  24. Pingback: Kasper Suits
  25. 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.

  26. 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

  27. 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.

  28. 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.

  29. 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.

  30. 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.

  31. 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.

  32. 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!

  33. 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!

  34. 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!

  35. 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

  36. 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.

  37. 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.

  38. 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!

  39. 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!

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

  41. 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.

  42. 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.

  43. 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 !!!

  44. Pingback: Tahari Dresses
  45. I’m having a strange problem I cannot make my reader pick up your feed, I’m using google reader by the way.

  46. Pingback: Pokemon online

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>