0
votes

ive run into some trouble with my spritebuilder project and i cant find a workaround. Im using the flappyfly tutorial to create a game. In the tutorial there is an Obstacle.ccb in spritebuilder and obstacle.h/m in xcode. The obstacles get spawned into the main scene with this code

- (void)spawnNewObstacle {
  CCNode *previousObstacle = [_obstacles lastObject];
  CGFloat previousObstacleXPosition = previousObstacle.position.x;

  if (!previousObstacle) {
    // this is the first obstacle
    previousObstacleXPosition = firstObstaclePosition;
  }

  Obstacle *obstacle = (Obstacle *)[CCBReader load:@"Obstacle"];
  obstacle.position = ccp(previousObstacleXPosition + distanceBetweenObstacles, 0);
  [obstacle setupRandomPosition];
  obstacle.zOrder = DrawingOrderPipes;
  [_physicsNode addChild:obstacle];
  [_obstacles addObject:obstacle];
}

What i want to accomplish is to have these obstacles still spawning randomly. I dont want my hero to collide with the obstacles, instead i want the obstacles to act as a physics body, so you can jump on it, the problem is that when i disable hero and obstacle collision, the mainscene still imports the obstacles.m but no physics is being applied, even though physics is on in the obstacles.ccb, and the hero is able to go through the obstacles. The only way i can make it an actual physics body is to add the obstacles.ccb to the mainscene.ccb under the physics node. This works but then of course obstacles dont spawn randomly. Any workaround?

1

1 Answers

0
votes

If you want them to keep spawning and for your hero to be able to jump on them without having to go to game over, i suggest setting a collision group for them