im new to programming, i have tried the ray wenderlich tutorial but im still confused.
i have a sprite called rock, and a sprite called player, im trying to detect collision between them. but im extremely confused. in need of some help.
-(void)addRock {
CCSprite *rock = [CCSprite spriteWithFile:@"rock.png"
rect:CGRectMake(0, 0, 27, 40)];
// Determine where to spawn the target along the X axis
CGSize winSize = [[CCDirector sharedDirector] winSize];
int minX = rock.contentSize.width/2;
int maxX = winSize.width - rock.contentSize.width/2;
int rangeX = maxX - minX;
int actualX = (arc4random() % rangeX) + minX;
// Create the target slightly off-screen along the right edge,
// and along a random position along the X axis as calculated above
rock.position = ccp(actualX, 500);
[self addChild:rock];
// Determine speed of the sprite
int actualDuration = 5;//speed of sprite
}
- (id)init {
if ((self=[super init])) {
CGSize winSize = [[CCDirector sharedDirector] winSize];
CCSprite *player = [CCSprite spriteWithFile:@"Player.png"
rect:CGRectMake(0, 0, 27, 40)];
player.position = ccp(winSize.width/2, winSize.height/4+15);
[self addChild:player];
[self schedule:@selector(gameLogicRock:) interval:0.2];
they are the two sprites, they spawn and position correctly, i only need to detect collision