Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Mastering Cocos2d Cross-Platform Game Development
  • Table Of Contents Toc
  • Feedback & Rating feedback
Mastering Cocos2d Cross-Platform Game Development

Mastering Cocos2d Cross-Platform Game Development

By : Alex Ogorek
4.5 (4)
close
close
Mastering Cocos2d Cross-Platform Game Development

Mastering Cocos2d Cross-Platform Game Development

4.5 (4)
By: Alex Ogorek

Overview of this book

If you are a developer who is experienced with Cocos2d and Objective-C, and want to take your game development skills to the next level, this book is going to help you achieve your goal.
Table of Contents (10 chapters)
close
close
9
Index

Creating buttons via CCButton and CCLayout

Cocos2d 3.0 changed the way buttons are displayed. If you've used previous versions of Cocos2d, you're probably familiar with CCMenu. That is no longer the way to create and display tappable buttons in Cocos2d. Instead, we're going to use CCButton and place them in a node of the CCLayout type. If you skipped the sprite sheet section, I strongly recommend that you go back and read it. It will save you from many frustrating moments as the project progresses.

For the book's project, we'll be adding the menu button in the bottom-left corner. Like I said, it's extremely easy to add the buttons once you have the images included in the project.

Open the MainScene.m file, and add these lines of code below the code for the labels in the init method:

CCButton *btnMenu = [CCButton buttonWithTitle:@""
  spriteFrame:[CCSpriteFrame frameWithImageNamed:@"btnMenu.png"]];
btnMenu.position = ccp(winSize.width * 0.125...
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Mastering Cocos2d Cross-Platform Game Development
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon