ios - trouble getting collision point -


hey i'm trying point of collision , create joint @ point 2 nodes. i'm not sure results mean or how want.

i don't have access contact points see in other posts. cccontactset collision gives me number of points , normal.

i output normal during collision begin , (1.0, -0.0) left wall, (-0.0, 1.0) bottom wall, (-1.0, 0.0) right wall, (-0.0, -1.0) top wall. don't understand them basically. know referring second hullpiece though because no matter how rotate or position booster during collision, results stay same. change if rotate hullpiece.

so how contact points create joint? supposed use normal that, , if how?

newsprite = ccsprite(imagenamed: "booster.png") newsprite.position = cgpoint(x: 200, y: 200) newsprite.scale = 4.0 let spritephysics = ccphysicsbody(rect: newsprite.texturerect, cornerradius: 0) spritephysics.collisiontype = "booster" spritephysics.sensor = true newsprite.physicsbody = spritephysics editorphysics.addchild(newsprite)  newsprite2 = ccsprite(imagenamed: "hullpiece.png") newsprite2.position = cgpoint(x: 200, y: 200) newsprite2.scale = 4.0 let spritephysics2 = ccphysicsbody(rect: newsprite2.texturerect, cornerradius: 0) spritephysics2.collisiontype = "hull" spritephysics2.sensor = true newsprite2.physicsbody = spritephysics2 editorphysics.addchild(newsprite2)  func ccphysicscollisionbegin(pair: ccphysicscollisionpair!, booster: ccnode!, hull: ccnode!) -> objcbool {     nslog("contact point\(pair.contacts.count) \(pair.contacts.normal)")     return true } 

you access contact points through contacts property of ccphysicscollisionpair.

here's contacts struct looks like:

typedef struct cccontactset {     /// number of contact points in set.     /// count 1 or 2.     int count;      /// normal of contact points.     cgpoint normal;      /// array of contact points.     struct {         /// absolute position of contact on surface of each shape.         cgpoint pointa, pointb;          /// penetration distance of 2 shapes.         /// value negative.         cgfloat distance;     } points[2]; } cccontactset; 

through points array can access exact collision position each involved shape.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -