Reputation: 1033
I have used the code below for collision detection. but as CCParallaxNode moves on in infinite scrolling. my positions goes wrong. i have tries every possible solution till yet. but everything gives me wrong values in parallax.
for (CCSprite *sp in PathsArray) {
if (sp.tag==500) {
CGPoint sprect=[self convertToWorldSpace:sp.position];
CGRect pillerRect=CGRectMake(sprect.x, sprect.y, sp.boundingBox.size.width, sp.boundingBox.size.height);
CGRect heroRect=CGRectMake(charcterObject.boundingBox.origin.x, charcterObject.boundingBox.origin.y, charcterObject.sp4.boundingBox.size.width, charcterObject.sp4.boundingBox.size.height);
if (CGRectIntersectsRect(heroRect, pillerRect)) {
[self stopJumping];
}
}
}
Upvotes: 0
Views: 63
Reputation: 9079
For this to work, both rectangles have to be in the same coordinate system. You should probably get position for *sp as
CGPoint sprect=[sp.parent convertToWorldSpace:sp.position];
because sp.position is in the parent's coordinates system.
Upvotes: 1