You could look in the "exporters" folder to look at the source code of the pin behavior. If you want to do it in Construct Classic I think in the examples section there is an example of arrows sticking into an object, which does basically the same thing as the pin behavior.
Off the top of my head you could do pin like this:
1 Create two sprites, childSprite and parentSprite.
2 Give childSprite four instance variables: parent,dist,ang,relAng.
Parent will store the uid of the parentSprite to be pinned to, use -1 for none.
Dist and ang are the distance and angle to position from the parent.
RelAng is the relative angle between the parent and child.
3 Here's an example of an event to setup a pin.
On ChildSprite collides with parentSprite
- --childSprite: set parent to parentSprite.uid
- --childSprite: set dist to distance(parentSprite.x,parentSprite.y,self.x,self.y)
- --childSprite: set ang to angle(parentSprite.x,parentSprite.y,self.x,self.y)
- --childSprite: set relAng to self.angle-parentSprite.angle
4 Then position the pinned objects with:
For each childSprite
Pick parentSprite by uid childSprite.parent
---childSprite: set position to parentSprite
---childSprite: move self.dist pixels at angle self.ang
---childSprite: set angle to parentSprite.angle+self.relAng
The collision response will be interesting, you have choice of either doing the motion yourself or seeing if you can bend the physics behavior to your own devices. Either way you'll want the center of mass. Instead of just finding an average of the positions you need to incorporate mass which is simple enough.
And then you can calculate the force and torque to apply to it with roughly this:
Linear force =applied force magnitude* dist from com to applied force loc * cos(angle of applied force- angle from applied force to com)
Angular torque is the same as above except use sin instead of cos.