ios7 - iOS Sprite Kit didBeginContact not work correctly -
i have 2 images without background triangles, want connect 1 triangle another, sprite kit thinking images square not triangle, , call me didbegincontact not in right time, example:
i create sprite this:
self.sprite = [skspritenode spritenodewithimagenamed:spritename]; [self.sprite setsize:cgsizemake(40, 40)]; self.sprite.physicsbody = [skphysicsbody bodywithrectangleofsize:self.sprite.size]; self.sprite.physicsbody.mass = 0; self.sprite.physicsbody.usesprecisecollisiondetection = yes; self.sprite.physicsbody.categorybitmask = category; self.sprite.physicsbody.collisionbitmask = 0; self.sprite.physicsbody.contacttestbitmask = category; self.sprite.physicsbody.dynamic = yes;
contacts between 2 bodies depend upon physicsbody, not texture. so, when use
self.sprite.physicsbody = [skphysicsbody bodywithrectangleofsize:self.sprite.size];
you attaching rectangular physicsbody.
you need create triangular physicsbody using method:
[skphysicsbody bodywithpolygonfrompath:path];
read on method here.
in order values creating path, can use skphysicsbody path generator tool.
Comments
Post a Comment