CCNode addChild from method

113 views Asked by At

I am trying to add a CCNode to my scene.

It works using this in the scene class (Level.m) itself:

- (void)didLoadFromCCB {
    CCLOG(@"didLoadFromCCB");
    self.userInteractionEnabled = TRUE;

     CCNode *node = [CCBReader load:@"NodeClassName"];

     node.position = ccp(10 , 54);

     [self addChild:node];
}

now I am trying to do the same thing but now by calling a method of another class (Cursor.m) which looks like this:

-(void) place: (int) yPos{


    CCNode * node = [CCBReader load:@"NodeClassName"];

    node.position = ccp(10 , yPos);

    [self addChild:node];


    NSLog(@"placed");

}

Level.m:

- (void)didLoadFromCCB {
    CCLOG(@"didLoadFromCCB");
    self.userInteractionEnabled = TRUE;

    Cursor *co = [[Cursor alloc] init];
    [co place: 54];
}

why is this not working?

0

There are 0 answers