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

  • SEARCH
  • Home
  • 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 7082885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:06:36+00:00 2026-05-28T07:06:36+00:00

I am probably staring the answer in the face, however. I want to assign

  • 0

I am probably staring the answer in the face, however.

I want to assign a random colour to a CCLabelTTF string. When I try to set the return type of (CCColor3B *) and assign it CCLabelTTF.color = [self randomColor] I get incompatible assignment errors, both in the method, and at the above assignment. Method code:

-(ccColor3B *)randomColor
{
float r = arc4random() % 255;
float g = arc4random() % 255;
float b = arc4random() % 255;
ccColor3B *color =  {r,g,b,1};
return color;
}

I think I am trying to obtain a return value which is the wrong type, or assign a read-only value, but information on CCColor3B is scarce. Thanks in advance.

  • 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-05-28T07:06:37+00:00Added an answer on May 28, 2026 at 7:06 am

    From Cocos2d class documentation, the property color of CCSprite is not a pointer (it is a struct)

    -(ccColor3B) color [read, write, assign]

    You need to change your method as follows

    -(ccColor3B)randomColor
    {
    float r = arc4random() % 255;
    float g = arc4random() % 255;
    float b = arc4random() % 255;
    return ccc3(r,g,b);
    }
    

    You can find the definition of ccColor3B in the docs for CCTypes.h (line 43)

    typedef struct _ccColor3B {
    GLubyte r;
    GLubyte g;
    GLubyte b; } ccColor3B;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following string which will probably contain ~100 entries: String foo =
Okay this is probably a really dumb question, however it's really starting to hurt.
Im thinking this is correct, but probably WAY off. I have a string formatted
I suspect there's probably an easy answer to this I'm just not seeing, but
There is probably a really easy answer to this but my brain just isn't
This is probably a stupid question but my googling isn't finding a satisfactory answer.
This is probably very simple, but I simply cannot find the answer myself :(
This has probably been answered dozens of times, couldn't find the answer though... Anyway,
simple question, probably easy for you to answer. I have a dll named MigrationSteps.dll
There's probably a Google search that'll answer this question but for the life of

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.