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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:29:04+00:00 2026-06-05T22:29:04+00:00

Im starting with CoCos2d development and I think I have some issues with nodespace,

  • 0

Im starting with CoCos2d development and I think I have some issues with nodespace, and actions, this is my code and nothings moving although I seem to have no errors when running the code, any comments are appreciated:

    +(id) create {
    return [[self alloc] init];}

    -(id) init {
        if ((self = [super init]))
        {
        CGSize scSize = [[CCDirector sharedDirector] winSize];

    self.position = ccp(0,scSize.height);;


    touchArea = [CCSprite spriteWithFile:@"touchArea.png"]; 
    [touchArea setAnchorPoint:ccp(0, 0.5)];
    [self addChild:touchArea];


    obj_1 = [CCSprite spriteWithFile:@"obj1.png"];
    obj_2 = [CCSprite spriteWithFile:@"obj2.png"];
    obj_3 = [CCSprite spriteWithFile:@"obj3.png"];

    obj_tab = [NSMutableArray arrayWithObjects:obj_1, obj_2, obj_3, nil];


        for (int i=0; i < obj_tab.count; i++)
        {
            CCSprite *obj = [obj_tab objectAtIndex:i];
            float offSetPos = ((float)(i+1)) / (obj_tab.count +1);
            CGPoint pos = ccp(scSize.width*offSetPos, 0);
            obj.position = pos;
            [obj setAnchorPoint:ccp(0.5, -0.25)];
            [touchArea addChild:obj];
        }

    velocidad = 3;
    destino = ccp(0,-100);
    //[self scheduleUpdate];
    [self moveIt] // <-- Edited to call another method
 }   
    return self;

}

-(void) moveit{
    CCMoveTo *moverAction = [CCMoveTo actionWithDuration:5 position:ccp(0,0)];
    CCCallFunc *onEndAction = [CCCallFunc actionWithTarget:self selector:@selector(onEndMove:)];
    CCSequence *moveSequence = [CCSequence actions: moverAction, onEndAction, nil];
    [touchArea runAction:moveSequence];
{

-(void) update:(ccTime)delta {

}

-(void)onEndMove:(id)sender{
    NSLog(@"OnEndMove fired");
}

-(void) onEnter{
    [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:-1 swallowsTouches:YES];
}

-(void) onExit {
    [[CCTouchDispatcher sharedDispatcher] removeDelegate:self];
}


-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{

    CGRect boundingBox = touchArea.boundingBox;
    boundingBox.origin = CGPointZero;

    BOOL isTouchHandled = CGRectContainsPoint(boundingBox, [touchArea convertTouchToNodeSpace: touch]);

    //NSLog(@"touchLocation y = %f", touchLocation.y);
    //NSLog(@"touchArea y = %f", touchArea.position.y);

    if (isTouchHandled){
        NSLog(@"Touch Handled");
    }

    return isTouchHandled;

}
@end
  • 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-05T22:29:05+00:00Added an answer on June 5, 2026 at 10:29 pm

    I am assuming that ‘self’ , the class of the code showed above, derives from CCNode. Make certain that ‘self’ is running, it must be a descendant of CCNode, and will be running when it is added to a running node. This is what happens in a CCNode’s onEnter (taken from version 1.0.1):

    -(void) onEnter
    {
        [children_ makeObjectsPerformSelector:@selector(onEnter)];  
        [self resumeSchedulerAndActions];
    
        isRunning_ = YES;
    }
    

    this is where the scheduler and actions are enabled for the node. If it is never invoked, your actions will not run.

    You could move your moveIt code to the onEnter method, which will be invoked when the object becomes running.

    -(void) onEnter{
        CCLOG(@"%@<onEnter> : invoked",self.class);
        [self moveIt];
        [super onEnter];   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m starting my development in Cocos2D and I wish to make this card effect
Starting from this example: http://support.microsoft.com/kb/828736 I have tried to add a test function in
I know Cocos2d 2.0 is in alpha and will obviously have certain issues with
starting with priority_queue s, I have a problem like this: I need elements to
Starting this morning my Eclipse indigo have projects and files with gray light color.
In a game I'm starting to make using cocos2d, I have a subclass of
Just starting off on iPhone development and I'm looking for some input as to
Starting with this code: new Person(ET).WithAge(88) How can it be refactored to: new Person(ET,
I have worked some with Cocos2d for iPhone and find it delightful. I am
Starting around Friday night, and continuing as of this morning, we have been seeing

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.