Hello,
I created a chain of CircleParticles connected to each other with
SpringContraints. One CircleParticle is draggable. I want the chain
(rope) to hold his length. Now is stretches out according how far you
would drag the circleparticle.
I build is with Flash CS3 so this code can be placed on the first
frame. No extra classes build yet. I added one extra class
"DragableCircleParticle" which can be found in the files from this
group (http://groups.google.com/group/ape-general/files).
import org.cove.ape.*;
APEngine.init(1/4);
APEngine.container = this;
APEngine.addMasslessForce(new Vector(0,8));
var color1:uint = 0x00ff00;
var color2:uint = 0xff00ff;
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
var anker:CircleParticle = new CircleParticle(240,0,10, true);
defaultGroup.addParticle(anker);
var cp1:CircleParticle = new CircleParticle(250,10,1);
defaultGroup.addParticle(cp1);
var sc1:SpringConstraint = new SpringConstraint(anker, cp1, 0.5,
false, 1);
sc1.restLength = 10;
sc1.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc1);
var cp2:CircleParticle = new CircleParticle(250,20,1);
defaultGroup.addParticle(cp2);
var sc2:SpringConstraint = new SpringConstraint(cp1, cp2, 0.5, false,
1);
sc2.restLength = 10;
sc2.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc2);
var cp3:DragableCircleParticle = new DragableCircleParticle(250,30,5);
defaultGroup.addParticle(cp3);
var sc3:SpringConstraint = new SpringConstraint(cp2, cp3, 0.5, false,
1);
sc3.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc3);
var cp4:CircleParticle = new CircleParticle(250,20,1);
defaultGroup.addParticle(cp4);
var sc4:SpringConstraint = new SpringConstraint(cp3, cp4, 0.5, false,
1);
sc4.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc4);
var cp5:CircleParticle = new CircleParticle(250,10,1);
defaultGroup.addParticle(cp5);
var sc5:SpringConstraint = new SpringConstraint(cp4, cp5, 0.5, false,
1);
sc5.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc5);
var sc6:SpringConstraint = new SpringConstraint(cp5, anker, 0.5,
false, 1);
sc6.setStyle(1, color1, 1, color2);
defaultGroup.addConstraint(sc6);
APEngine.addGroup(defaultGroup);
addEventListener(Event.ENTER_FRAME, run);
function run(evt:Event):void {
APEngine.step();
APEngine.paint();
}
function mouseDownHandler(evt:Event):void {
trace("click");
}