Search code examples
cocos2d-iphonekobold2d

How to make the click work AND How do I delay a function in init? XCODE


    blue = [CCMenuItemImage itemFromNormalImage:@"blue.png" selectedImage:@"blueclick.png"];
    [blue setPosition:ccp(175, 350)];
    blue.scale = .75;
    [self addChild:blue  z: 5];



 id move = [CCMoveBy actionWithDuration:1.0f position:CGPointMake(334, 321.75)];
    [blue runAction:move];

Why won't it change to the second image (blueclick.png) when I click it? ALSO how would I delay this function?


Solution

  • Try this code to run action with delay:

          id delay    = [CCDelayTime actionWithDuration:delay];
          id move     = [CCMoveTo actionWithDuration:0.4 position:ccp(x, y)];
          id sequence = [CCSequence actions:delay, move, nil];
          [card.sprite runAction:sequence];