Hey guys!
Thanks to Robodude and Techy! I was able figure out how to spew my random sprites using this method:
-(void) moveKale {
int ranmX = rand() % 400;
id animation = [CCMoveTo actionWithDuration:6 position: ccp(ranmX,-50)];
for(int i = 0; i < 1; i++)
{
int ranX = rand() % 450;
int ranY = rand() % 420;
if ( ranY > 300 ) {
kale3 = [CCSprite spriteWithFile:@"Kale2.png"];
kale3.position = ccp(ranX,ranY);
[self addChild:kale3 z:30 tag:kTagKale];
[kale3 runAction: animation];
}
}
};
I've ran into a little problem though. I tried adding the distance formula in the same method that creates the kale3 sprite,and I also tried writing a seperate one to check for collision:
-(void)collision {
[self getChildByTag:kTagAndi];
[self getChildByTag:kTagKale];
float xDif = kale3.position.x - andi.position.x;
float yDif = kale3.position.y - andi.position.y;
float distance = sqrt(xDif * xDif + yDif * yDif);
if (distance < 30) {
[self unschedule:@selector(moveKale)];
}
But for some reason! It just isn't working! Sigh. IS it because my method is cycling every 1 second and it will only check for that one second on that sprite? Or do I just need to take a chill pill and re-think this thing?!