The code below is using quickbox2d and i am trying to add a touch feature so I can use this on my air android apps. I am trying to just make certain items draggable not all. But my touch methods dont seem to fire off. Also how do I get scope of a crcle that is drawn using the quickbox2d class?
package
{
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display.MovieClip;
import flash.events.TouchEvent;
//import flash.events.TransformGestureEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import com.actionsnippet.qbox.*;
public class Box2d extends MovieClip
{
public var testMC:MovieClip = new test_mc() as MovieClip;
public function Box2d()
{
Multitouch.inputMode=MultitouchInputMode.TOUCH_POINT;
trace("Box2d");
// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var sim:QuickBox2D = new QuickBox2D(this);
sim.createStageWalls();
//sim.addBox({x:3, y:3, width:1, height:1});
//sim.addCircle({x:4, y:6, radius:1});
sim.addBox({x:4, y:3, width:1, height:1});
sim.addCircle({x:3, y:3, radius: 45 / 30});
sim.addBox({x:1, y:6, width:4, height:0.25, density:0, angle:0.1});
sim.addCircle({x:3, y:10, radius:1});
sim.addCircle({x:8, y:10, radius:0.5});
// store references to each part of the group
/*var circleA:QuickObject = sim.addCircle({x:0, y:0, radius:0.5});
var circleB:QuickObject = sim.addCircle({x:2, y:0, radius:0.5});
var middleBox:QuickObject = sim.addBox({x:1, y:0, width:1.5, height:0.5});
// create the group using the addGroup() method
sim.addGroup({objects:[circleA, circleB, middleBox], x:6, y:6}); */
// create a circle
/* sim.addCircle({x:16, y:3, radius:1, density:0.2});
// create a bunch of boxes
var boxes:Array = [];
for (var i:int = 0; i<20; i++){
var h:Number = 1 - i / 20;
boxes.push(sim.addBox({x:i, y:i * h, width:1, height:h}));
}
// group all the boxes together
sim.addGroup({objects:boxes, x:3, y:3});
//Coloring Rigid Bodies and Using setDefault()
sim.addCircle({x:3, y:3, radius:1,
fillColor:0xFF0000,
lineThickness:10,
lineColor:0xFFFF00});
sim.addCircle({x:6, y:3, radius:1,
fillColor:0xFF0000,
lineThickness:10,
lineColor:0xFFFF00});
sim.addCircle({x:9, y:3, radius:1,
fillColor:0x000022,
lineThickness:5,
lineColor:0x6666FF});
sim.addBox({x:12, y:4, width:2, height:2,
fillColor:0xFF0000,
lineThickness:10,
lineColor:0x00FF00});
//Skinning bodies (using moviClips to do so in the next few lines
sim.addCircle({x:3, y:3, radius: 45 / 30, skin:CircleFace, scaleSkin:false});
sim.addCircle({x:6, y:3, radius:1, skin:OddPizza});
sim.addCircle({x:6, y:6, radius:0.5, skin:OddPizza});
sim.addCircle({x:6, y:10, radius:2, skin:OddPizza});
sim.addBox({x:12, y:3, width:3, height: 50 / 30, skin:Mail});
sim.addBox({x:18, y:3, width:3, height: 3, skin:Mail});
*/
sim.start();
sim.main.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
sim.main.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
sim.main.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);
}
public function onTouchBegin(e:TouchEvent):void
{
e.target.startTouchDrag(e.touchPointID, false);
trace("touch begin");
}
public function onTouchMove(evt:TouchEvent):void {
evt.target.alpha = 0.5;
trace("touch move");
}
public function onTouchEnd(e:TouchEvent):void
{
e.target.stopTouchDrag(e.touchPointID);
e.target.alpha = 1;
trace("touch end");
}
}
}