Skip to main content
added 7 characters in body
Source Link
iPatel
  • 168
  • 8

I just put my logic.

You have updateRunning method, in this method hasyou have a logic of move coin at right to left.

Here you need to use CCMoveTo Action,

// move the coin until it leaves the left edge of the screen
if (coin.position.x > (coin.contentSize.width * (-1)))
{
   [coin runAction:
     [CCSequence actions: // Here set MoveDuration as you need , may be "5";
      [CCMoveTo actionWithDuration:MoveDuration position:ccp(coin.position.x - (xSpeed*delta), coin.position.y)],
      [CCCallBlockN actionWithBlock:^(CCNode *node) {
         // Here do stuff when your action is performed.
     }],
      nil]];
}

And also call your updateRunning method with specific time by using NSTimer such like, call updateRunning

[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(updateRunning) userInfo:nil repeats:YES]; /// Set Time interval as you need; 

I just put my logic.

You have updateRunning method, in this method has logic of move coin at right to left.

Here you need to use CCMoveTo Action,

// move the coin until it leaves the left edge of the screen
if (coin.position.x > (coin.contentSize.width * (-1)))
{
   [coin runAction:
     [CCSequence actions: // Here set MoveDuration as you need , may be "5";
      [CCMoveTo actionWithDuration:MoveDuration position:ccp(coin.position.x - (xSpeed*delta), coin.position.y)],
      [CCCallBlockN actionWithBlock:^(CCNode *node) {
         // Here do stuff when your action is performed.
     }],
      nil]];
}

And also call your updateRunning method with specific time by using NSTimer such like, call updateRunning

[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(updateRunning) userInfo:nil repeats:YES]; /// Set Time interval as you need; 

I just put my logic.

You have updateRunning method, in this method you have a logic of move coin at right to left.

Here you need to use CCMoveTo Action,

// move the coin until it leaves the left edge of the screen
if (coin.position.x > (coin.contentSize.width * (-1)))
{
   [coin runAction:
     [CCSequence actions: // Here set MoveDuration as you need , may be "5";
      [CCMoveTo actionWithDuration:MoveDuration position:ccp(coin.position.x - (xSpeed*delta), coin.position.y)],
      [CCCallBlockN actionWithBlock:^(CCNode *node) {
         // Here do stuff when your action is performed.
     }],
      nil]];
}

And also call your updateRunning method with specific time by using NSTimer such like, call updateRunning

[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(updateRunning) userInfo:nil repeats:YES]; /// Set Time interval as you need; 
Source Link
iPatel
  • 168
  • 8

I just put my logic.

You have updateRunning method, in this method has logic of move coin at right to left.

Here you need to use CCMoveTo Action,

// move the coin until it leaves the left edge of the screen
if (coin.position.x > (coin.contentSize.width * (-1)))
{
   [coin runAction:
     [CCSequence actions: // Here set MoveDuration as you need , may be "5";
      [CCMoveTo actionWithDuration:MoveDuration position:ccp(coin.position.x - (xSpeed*delta), coin.position.y)],
      [CCCallBlockN actionWithBlock:^(CCNode *node) {
         // Here do stuff when your action is performed.
     }],
      nil]];
}

And also call your updateRunning method with specific time by using NSTimer such like, call updateRunning

[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(updateRunning) userInfo:nil repeats:YES]; /// Set Time interval as you need;