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:

imgur

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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -