Then in that case, your
cpSpaceAddCollisionPairFunc(space, 1, 2, &spriteToWallCollision, self);
Would be 1, 2 or something. Where 1 is your static object and 2 is your moving object.
Then "a" is your wall, and "b" is your sprite.
So change your collision function to be:
static int spriteToWallCollision(cpShape *a, cpShape *b, cpContact *contacts, int numContacts, cpFloat normal_coef, void *data)
{
MySprite *sprite = b->data;
MySprite *wall = a->data;
if( sprite ) {
[sprite stopAllActions];
[sprite setPosition:ccp(b->body->p.x-(b->body->p.x-a->body->p.x)/2 + 2, b->body->p.y-(b->body->p.y-a->body->p.y)/2 + 2)];
}
return 0;
}
Probably barking up the wrong tree. The move is just so the collisions stop. What you really need to do is get the b->body->p.x - a->body->p.x and find out if it is positive or negative. Then add or take 1 from the current x of b. Then repeat for the y. That will make it look like the object just stops.