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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:38:29+00:00 2026-05-24T22:38:29+00:00

I’ve recently picked up app writing as a hobby and I’ve run into a

  • 0

I’ve recently picked up app writing as a hobby and I’ve run into a problem with my first app. My first app attempt is fairly simple…a domino game. I started out using an NSObject class to describe each tile, but I think I’ve decided that CCSprite is easier for me at the moment.

The first step was creating an NSArray of all the tiles and then shuffling them. This is where I’m getting stuck….

Domino.h

#import <Foundation/Foundation.h>
#import "cocos2d.h"

@interface Domino : CCSprite {
    int int_leading;
    int int_trailing;
    int int_suitrank;
    int int_trickvalue;

    NSString *str_tilename;
    NSString *str_mirrortilename;

}


@property  int int_leading,int_trailing, int_suitrank, int_trickvalue; 

@property(nonatomic, retain) NSString *str_tilename;
@property(nonatomic, retain) NSString *str_mirrortilename;

-(void) print;
-(void) setTileName: (NSString *) theTileName;
-(void) setMirrorName: (NSString *) theMirrorName;
-(NSString *) str_tilename;
-(NSString *) str_mirrortilename;

@end

Domino.m

@implementation Domino

@synthesize int_leading,int_trailing, int_suitrank, int_trickvalue, str_tilename, str_mirrortilename;
//@synthesize char_tilename, char_mirrortilename;

-(void) print     { 
    NSLog (@"%i/%i", int_leading, int_trailing);}

-(void) setTileName: (NSString *) theTileName;
{
    str_tilename=[[NSString alloc] initWithString: theTileName];
}

-(void) setMirrorName: (NSString *) theMirrorName;
{
    str_mirrortilename=[[NSString alloc] initWithString: theMirrorName];
}

-(NSString *) str_tilename
{
    return str_tilename;
}

-(NSString *) str_mirrortilename
{
    return str_mirrortilename;
}
@end

helloworld.m

// Import the interfaces
#import "HelloWorldLayer.h"
#import "Domino.h"
// HelloWorldLayer implementation
@implementation HelloWorldLayer
+(CCScene *) scene
{
    // 'scene' is an autorelease object.
    CCScene *scene = [CCScene node];

    // 'layer' is an autorelease object.
    HelloWorldLayer *layer = [HelloWorldLayer node];

    // add layer as a child to scene
    [scene addChild: layer];

    // return the scene
    return scene;
}
// on "init" you need to initialize your instance
-(id) init
{
    if( (self=[super init] )) {
        //NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    Domino *d00 =[[Domino alloc] init];
        NSString *TileName= @"0-0.png";
        NSString *MirrorName= @"0-0.png";
        [d00 setTileName: TileName];
        [d00 setMirrorName: MirrorName];
        d00.int_leading=0;
        d00.int_trailing=0;
.
.
.
.
.
.
.
.
        movableSprites = [[NSMutableArray alloc] init];

    //build initial array of tiles
        NSArray *uniquetiles = [NSArray arrayWithObjects:
        d00,d01,d02,d03,d04,d05,d06, 
            d11,d12,d13,d14,d15,d16,     
                d22,d23,d24,d25,d26,
                    d33,d34,d35,d36,
                        d44,d45,d46,
                            d55,d56,
                                d66,
        nil];  

 //shuffle integer array representing tile index number
    int tile[28];    // array of tile row ids;

        for (int i=0; i<28; i++) {
            tile[i] = i;  // fill the array in order
        }

        for (int i=0; i<(27-1); i++) {
            int r = i + (arc4random() % (27-i)); // Random remaining position.
            int temp = tile[i]; tile[i] = tile[r]; tile[r] = temp;

        }
        int i=30;
        Domino *sprite =[[Domino alloc] init];
        for(int h = 1; h < 8; ++h) {

            for(int w=0;w<4; ++w){

                i=tile[(h-1)*4+(w)];        
                NSString *name=[[uniquetiles objectAtIndex:i]valueForKey:@"str_tilename"];
                CGPoint spriteOffset = ccp(100+60*w, 45+25*h);
NSLog(@" client Id : %@",[CCSprite spriteWithSpriteFrameName:name]);

                sprite=[CCSprite spriteWithSpriteFrameName:name];
                sprite.scale=.50;
                sprite.int_leading=1; //program fails here 

When I try to set the value of the tile, I end up getting a “Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[CCSprite setInt_leading:]” What am I doing different here than what I just did before when I defined d00?

  • 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-24T22:38:30+00:00Added an answer on May 24, 2026 at 10:38 pm

    Well for one thing that is bothering me, you never actually set up a image for the sprite to use. I see you setting up the strings to load an image but I don’t see you loading the image.

    More importantly I am guessing is that you did not set any rules for your properties. I expect making:

    @property  int int_leading,int_trailing, int_suitrank, int_trickvalue; 
    

    Into:

    @property  (nonatomic, retain) int int_leading,int_trailing, int_suitrank, int_trickvalue; 
    

    would fix your problem. (or assign)

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I am writing an app with both english and french support. The app requests
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.