Created
August 15, 2012 13:37
-
-
Save whitmanc/3360240 to your computer and use it in GitHub Desktop.
Cocos2d-iphone prevent physics objects overlap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event | |
{ | |
CGPoint touchPoint = [touch locationInView:[touch view]]; | |
touchPoint = [[CCDirector sharedDirector] convertToGL:touchPoint]; | |
if(isTouch){ | |
// | |
// Move the flake, check into consideration finger placement | |
// relative to the flake | |
// | |
CGPoint point = [self convertTouchToNodeSpace:touch]; | |
cpShape *shape = [smgr getShapeAt:point]; | |
if (shape && [shape->body->data class] != [cpCCSprite class]) { | |
touchedFlake.shape->body->p=ccpSub(touchPoint, difTouch); | |
} | |
if (shape && [shape->body->data class] == [cpCCSprite class]) { | |
[smgr morphShapeToActive:touchedFlake.shape mass:1]; | |
return; | |
} | |
if (shape == NULL) { | |
touchedFlake.shape->body->p=ccpSub(touchPoint, difTouch); | |
} | |
[smgr rehashShape:touchedFlake.shape]; | |
lastMovePoint = touchPoint; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment