[QuickBox2D] Soft Object #4
隣り合う丸は糸でつないで、天井の2点からゴムぶら下げた
/**
* Copyright Kay ( http://wonderfl.net/user/Kay )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ewg3
*/
// forked from Kay's [QuickBox2D] Soft Object #3
// forked from Kay's [QuickBox2D] Soft Object #2
// forked from Kay's forked from: QuickBox2D sample
// forked from mash's QuickBox2D sample
/*
* 隣り合う丸は糸でつないで、天井の2点からゴムぶら下げた
*/
package {
import flash.display.*;
import com.actionsnippet.qbox.*;
import flash.geom.*;
import flash.events.*;
public class FlashTest extends MovieClip {
private const SW:Number = stage.stageWidth;
private const SH:Number = stage.stageHeight;
private const radius:Number = 1.2;
private const outRadius:Number = 5;
private const jHz:Number = 2;
private const nColor:int = 0xff0000;
private var outer:Array = new Array();
private const dotNum:int = 12;
public function FlashTest() {
var sim:QuickBox2D = new QuickBox2D(this, { debug:false, gravityX:0, gravityY:0.2 });
var anchorA:QuickObject = sim.addCircle({x:0,y:-SH/30,width:SH/30, radius:radius, density:0, fillAlpha:0, lineAlpha:0});
var anchorB:QuickObject = sim.addCircle({x:SH/30,y:-SH/30,width:SH/30, radius:radius, density:0, fillAlpha:0, lineAlpha:0});
var center:Point = new Point(SW/2/30, SH/2/30);
// Outer
for (var o:int = 0; o < dotNum; o++) {
var nR:Number = Math.PI*2/dotNum*o;
var dot:QuickObject = sim.addCircle({x:center.x+outRadius*Math.cos(nR), y:center.y+outRadius*Math.sin(nR), radius:radius, fillColor:0xcc9966, lineAlpha:0 });
outer.push(dot);
if (o > 0) {
sim.addJoint({a:outer[o-1].body, b:dot.body, lineAlpha:0});
}
sim.addJoint({a:dot.body, b:anchorA.body, frequencyHz:jHz, lineAlpha:0});
sim.addJoint({a:dot.body, b:anchorB.body, frequencyHz:jHz, lineAlpha:0});
}
sim.addJoint({a:outer[dotNum-1].body, b:outer[0].body, frequencyHz:0, lineAlpha:0});
for (o = 0; o < dotNum; o++) {
outer[o].y = 0;
}
sim.start();
sim.mouseDrag();
}
}
}