Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8961199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:49:57+00:00 2026-06-15T15:49:57+00:00

I have implemented the CCLabelProtocol and CCRGBAProtocol with a class which I named Label:

  • 0

I have implemented the CCLabelProtocol and CCRGBAProtocol with a class which I named Label:

#import <cocos2d.h>

@interface Label : CCNode <CCLabelProtocol, CCRGBAProtocol>

@property (nonatomic, copy, readwrite) NSString* string;
@property (nonatomic, readwrite) ccColor3B color;
@property (nonatomic, readwrite) GLubyte opacity;

- (id) initWithString: (NSString*) aString;

@end

Since it comes handy I also made a initWithString method:

#import "Label.h"

@implementation Label

@synthesize string,opacity,color;

- (id) initWithString: (NSString*) aString
{
    if(self=[super init])
    {
        string= aString;
        color.r=255;
        color.g=0;
        color.b=0;
        opacity= 10;
    }
    return self;
}

- (ccColor3B) color
{
    return color;
}

@end

Then in the HelloWorldLayer’s init method I do this:

    Label* label= [[Label alloc]initWithString: @"Start"];
    CCMenuItemLabel* item= [CCMenuItemLabel itemWithLabel: label block:^(id sender)
    {
        NSLog(@"Label Clicked");
    }];
    CCMenu* menu= [CCMenu menuWithItems: item, nil];
    [self addChild: menu];

I am using the a plain cocos2d template, so this is inside a CCLayer class.
The screen is black, I don’t get the label to appear as I want.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:49:58+00:00Added an answer on June 15, 2026 at 3:49 pm

    That’s because you merely adopted some protocols, but subclassed from CCNode. CCNode is a non-rendering (invisible) node.

    If you want a label, subclass from CCLabelTTF and omit the protocols since CCLabelTTF already implements them.

    However it’s overkill to create a CCLabelTTF subclass unless you want to change how the label behaves or renders. If all you need to change is text and color, use the CCLabelTTF initializers and its color property.

    Label* label = [CCLabelTTF labelWithString:@"Start" fontName:@"Arial" fontSize:24];
    label.color = ccRED;
    CCMenuItemLabel* item = [CCMenuItemLabel itemWithLabel: label block:^(id sender)
    {
        NSLog(@"Label Clicked");
    }];
    CCMenu* menu = [CCMenu menuWithItems:item, nil];
    [self addChild:menu];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have implemented galleryview in one screen named display_image.xml in which i have shown
I have implemented a custom designer class which inherits from DocumentDesigner. The standard Form
I have implemented the IEquatable interface in a class with the following code. public
I have implemented a simple linked list class and I would now like to
I have implemented the two classes shown at http://tomcat.apache.org/tomcat-6.0-doc/aio.html which gives a messenger application
I have implemented a recursive function on image which call its neighbor pixels until
I have implemented INotifyPropertyChanged to the following class public class FactoryItems : INotifyPropertyChanged {
I have implemented the SortedBindingList class shown at http://www.martinwilley.com/net/code/forms/sortablebindinglist.html I have then successfully added
I have implemented button which clicks and opens dialog with spinner inside as described
We have implemented an iphone app which uses the facebook chat, partly over xmpp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.