mayobutter, thank you for your work! It's very impressive stuff.
I have a question: how to turn body from static to dynamic in a right way?
I'm just start to study wck and writing some test examples.
In this example I've created the world on stage, than attached some static boxes(boxes extends shapes.Box), and than attached listeners to boxes to handle collisions.
On mouse click ball fired, and after collision boxes falling down... but just the body (ball collides with invisible virtual bodies), box sprites remains on the same place, they don't move.
Here is how it looks:
http://en.novikovd.com/wcktest/test_wck.htmlWhy sprite don't follow the body it attached to?
And what am I doing wrong here:
Code:
package
{
import Box2DAS.Common.V2;
import Box2DAS.Dynamics.ContactEvent;
import flash.geom.Point;
import shapes.Box;
import shapes.Circle;
import wck.World;
import misc.Util;
import Box2DAS.Dynamics.b2Body;
import flash.events.MouseEvent;
public class test01 extends World
{
private var c:Circle;
private var box:Box;
public function test01()
{
super();
for (var i:int = 0; i < 8; i++) {
for (var j:int = 0; j < 7; j++){
box = new boxie();
box.type = "Static";
box.restitution = 0.2;
box._density = 10;
Util.addChildAtPos(this, box, new Point(10 + i * 30, -110 + 40 * j));
box.addEventListener( ContactEvent.BEGIN_CONTACT, onContact);
box.reportBeginContact = true;
}
}
listenWhileVisible(stage, MouseEvent.MOUSE_DOWN, handleMouseDown);
}
private function onContact(e:ContactEvent):void
{
if ( e.other.GetBody().GetFixtureList().GetUserData() is circle) {
e.fixture.GetBody().SetType(2);
}
}
private function handleMouseDown(e:MouseEvent):void
{
c = new circle();
c.width = 15;
c.height = 15;
c.restitution = 0.5;
c._density = 12;
c._linearVelocity = new V2(8, -10);
c.bullet = true;
Util.addChildAtPos(this, c, new Point( -240, 150));
}
}
}