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 7010731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:02:02+00:00 2026-05-27T22:02:02+00:00

I want to set the class tile value by click on the button if

  • 0

I want to set the class tile value by click on the button

  • if click onPlus it will have a string value = @”+”
  • if click onMinus it will have a string value = @”-“

here are the code

//Class Tile

@interface Tile : TouchableNode {
     NSString *val;
}

-(void) setVal:(NSString *)v
{
    val = v;
}

-(NSString *) getVal
{
    return val;
}

And the in another class

I have a code like this

for(Tile *tile in player)
{
    if (tile.getVal == @"P") {
        if (pauseStatus == 0) {
            pauseStatus = 1;

            [[CCDirector sharedDirector] pause];
            CGSize size = [[CCDirector sharedDirector] winSize];
            pauseLayer=[[CCLayer alloc] init];
            pauseLayer.anchorPoint=ccp(0,0);
            pauseLayer = [CCLayerColor layerWithColor: ccc4(0, 0, 255, 125) width: 300 height: 150];
            pauseLayer.position = ccp(size.width/2, size.height/2);       
            pauseLayer.isRelativeAnchorPoint = YES;
            [self addChild: pauseLayer z:8];

            //Here are 2 two button that when user click it will have @"+" value or @"-"
            plusBtn = [CCMenuItemImage itemFromNormalImage:@"plus.png" selectedImage:@"plus.png"     target:self selector:@selector(onPlus:)];
            minusBTn = [CCMenuItemImage itemFromNormalImage:@"minus.png" selectedImage:@"minus.png"      target:self selector:@selector(onMinus:)];

            pauseMenu = [CCMenu menuWithItems:plusBtn, minusBTn, nil];
            [pauseMenu alignItemsHorizontally];
            [self addChild:pauseMenu z:10];
        }
    }
}

and I have onPlus & onMinus method that I want to send object tile to that method

-(void)onPlus:(Tile *) set
{
    NSString *plus = @"+";
    [set setVal:plus];
}

-(void)onMinus:(Tile *) set
{
    NSString *minus = @"-";
    [set setVal:minus];
}

How to pass the object tile to the method??
Or it have another way to make it??

  • 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-27T22:02:03+00:00Added an answer on May 27, 2026 at 10:02 pm

    CCMenuItemImage inherits from CCNode, which has a void* userData property. If you assign tile to userData, you could fetch it back from the (id)sender in your onPlus/onMinus methods.

    plusBtn = [CCMenuItemImage itemFromNormalImage:@"plus.png" selectedImage:@"plus.png"     target:self selector:@selector(onPlus:)];
    plusBtn.userData = (void*)tile; // You may need a bridge cast in ARC
    minusBTn = [CCMenuItemImage itemFromNormalImage:@"minus.png" selectedImage:@"minus.png"      target:self selector:@selector(onMinus:)];
    minusBTn.userData = (void*)tile;
    
    -(void)onPlus:(id)senderObj {
        CCNode *sender = (CCNode*)senderObj;
        Tile *myTile = (Tile*)sender.userData; // Again you may need a bridge cast here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a required field, string attribute{get; set} in a class and want to
I have a base class for all my textboxes and I want to set
I have a static variable partner in the class. And I want to set
I create a combobox in a class and want to set the selected value
I have an SWC with a class called Content. I want to set it
I have a singleton initializer which is a class method. I want to set
I have the following code files: public interface IMod { string Name { get;
I want to set a read-only attribute inside a class method. I have already
I have a cocoa class set up that I want to use to connect
In a class, if I want to set the text to the text value

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.