Please excuse the double posting kind of, but now I got some code snippets since I can't yet figure this one out:
I got two bodies as seen in the attach picture and my goal is to make the string between them not that stiff, but more to an elastic behavior!
So, this is what I wrote on an ADDED_TO_STAGE event:
and of course this is the function called to join the two bodies:
To be mentioned that I am moving the larger body using the arrow keys, around the scene and the small round body bounces below!
Everything works perfectly only that I cannot obtain the elastic string effect and is really driving me nuts :) as it would look much more realistic!
Please, please guys, if you got any kind of suggestions or done something like that in the past, let me know!
Thank you again for your awesome work!
Gamez-Factory
I got two bodies as seen in the attach picture and my goal is to make the string between them not that stiff, but more to an elastic behavior!
So, this is what I wrote on an ADDED_TO_STAGE event:
Code:
private function addedHandler(event : Event) : void {
var firstJoint : Object = new Object();
firstJoint = {name:"j1", alpha:0, x:7.2, y:-76, type:"", fHz:1, dRatio:1.5, cConected:true, skin:"", t2n:"j2"};
var secondJoint : Object = new Object();
secondJoint = {name:"j2", alpha:0, x:2.10, y:-23.45, type:"Revolute", fHz:1, dRatio:1.5, cConected:true, skin:"Rope", t2n:"j1"};
jointMe(firstJoint, secondJoint);
}
var firstJoint : Object = new Object();
firstJoint = {name:"j1", alpha:0, x:7.2, y:-76, type:"", fHz:1, dRatio:1.5, cConected:true, skin:"", t2n:"j2"};
var secondJoint : Object = new Object();
secondJoint = {name:"j2", alpha:0, x:2.10, y:-23.45, type:"Revolute", fHz:1, dRatio:1.5, cConected:true, skin:"Rope", t2n:"j1"};
jointMe(firstJoint, secondJoint);
}
and of course this is the function called to join the two bodies:
Code:
public function jointMe(firstJoint : Object, secondJoint : Object) : void {
// FirstJoint init:
var _firstJoint : WCKJoint = new WCKJoint();
_firstJoint.name = firstJoint["name"];
_firstJoint.type = firstJoint["type"];
_firstJoint.frequencyHz = firstJoint["fHz"];
_firstJoint.dampingRatio = firstJoint["dRatio"];
_firstJoint.collideConnected = firstJoint["cConected"];
_firstJoint.connectorClassName = firstJoint["skin"];
_firstJoint.x = firstJoint["x"];
_firstJoint.y = firstJoint["y"];
_firstJoint.target1Name = "";
_firstJoint.target2Name = firstJoint["t2n"];
_firstJoint.alpha = firstJoint["alpha"];
gameJoints[firstJoint["name"]] = _firstJoint;
this.addChild(_firstJoint);
// SecondJoint init:
var _secondJoint : wck.Joint = new WCKJoint();
_secondJoint.name = secondJoint["name"];
_secondJoint.type = secondJoint["type"];
_secondJoint.frequencyHz = secondJoint["fHz"];
_secondJoint.dampingRatio = secondJoint["dRatio"];
_secondJoint.collideConnected = secondJoint["cConected"];
_secondJoint.connectorClassName = secondJoint["skin"];
_secondJoint.x = secondJoint["x"];
_secondJoint.y = secondJoint["y"];
_firstJoint.target1Name = "";
_secondJoint.target2Name = secondJoint["t2n"];
_secondJoint.alpha = secondJoint["alpha"];
gameJoints[secondJoint["name"]] = _secondJoint;
this.addChild(_secondJoint);
}
// FirstJoint init:
var _firstJoint : WCKJoint = new WCKJoint();
_firstJoint.name = firstJoint["name"];
_firstJoint.type = firstJoint["type"];
_firstJoint.frequencyHz = firstJoint["fHz"];
_firstJoint.dampingRatio = firstJoint["dRatio"];
_firstJoint.collideConnected = firstJoint["cConected"];
_firstJoint.connectorClassName = firstJoint["skin"];
_firstJoint.x = firstJoint["x"];
_firstJoint.y = firstJoint["y"];
_firstJoint.target1Name = "";
_firstJoint.target2Name = firstJoint["t2n"];
_firstJoint.alpha = firstJoint["alpha"];
gameJoints[firstJoint["name"]] = _firstJoint;
this.addChild(_firstJoint);
// SecondJoint init:
var _secondJoint : wck.Joint = new WCKJoint();
_secondJoint.name = secondJoint["name"];
_secondJoint.type = secondJoint["type"];
_secondJoint.frequencyHz = secondJoint["fHz"];
_secondJoint.dampingRatio = secondJoint["dRatio"];
_secondJoint.collideConnected = secondJoint["cConected"];
_secondJoint.connectorClassName = secondJoint["skin"];
_secondJoint.x = secondJoint["x"];
_secondJoint.y = secondJoint["y"];
_firstJoint.target1Name = "";
_secondJoint.target2Name = secondJoint["t2n"];
_secondJoint.alpha = secondJoint["alpha"];
gameJoints[secondJoint["name"]] = _secondJoint;
this.addChild(_secondJoint);
}
To be mentioned that I am moving the larger body using the arrow keys, around the scene and the small round body bounces below!
Everything works perfectly only that I cannot obtain the elastic string effect and is really driving me nuts :) as it would look much more realistic!
Please, please guys, if you got any kind of suggestions or done something like that in the past, let me know!
Thank you again for your awesome work!
Gamez-Factory