-1

The question was here for a long time with bounty and no satisfying solution for me. I erased the first post and am posting instead a question that can be answered quickly with a yes or no so I can proceed with my doings.

If you could answer it really fast before it's deleted by "not a good question". Is using a custom shape from PhysicsEditor to Nape the same as doing it with Box2D? (ofc changing syntax)

If you could then give a look in that link then say it's the same process in Nape that'll be enought thanks.

I ask this because I found the Box2D tutorial easier to follow so far.

public var floor:Body;

floor = new Body(BodyType.STATIC);
var floorShape:PhysicsData = new PhysicsData();
floor.shapes.add(floorShape); // Error: Implicit coercion of a value of type PhysicsData to an unrelated type nape.shape:Shape.
floor.space = space;
RAO
  • 71
  • 1
  • 13

1 Answers1

0

Update:

According to a comment on this blog post, it sounds like recent versions of Nape have broken compatibility with the physics editor. Specifically, the graphic and graphicUpdate properties no longer exist on body objects. The solution suggested is to remove references to those properties.

I'm not in a position to be able to test this, but you could try updating the createBody method of your floor class as follows:

public static function createBody(name:String /*,graphic:DisplayObject=null*/):Body {
    var xret:BodyPair = lookup(name);
    //if(graphic==null) return xret.body.copy();

    var ret:Body = xret.body.copy();
    //graphic.x = graphic.y = 0;
    //graphic.rotation = 0;
    //var bounds:Rectangle = graphic.getBounds(graphic);
    //var offset:Vec2 = Vec2.get(bounds.x-xret.anchor.x, bounds.y-xret.anchor.y);

    //ret.graphic = graphic;
    /*
    ret.graphicUpdate = function(b:Body):void {
        var gp:Vec2 = b.localToWorld(offset);
        graphic.x = gp.x;
        graphic.y = gp.y;
        graphic.rotation = (b.rotation*180/Math.PI)%360;
    }   
    */
    return ret;
}
net.uk.sweet
  • 12,444
  • 2
  • 24
  • 42
  • I have all that, main class, nape space. I didn't know how to implement the physics generated code into it. Going to look at your sample thx – RAO Jun 20 '14 at 11:00
  • I'm guessing a bit here, but you should just be able to add it TO a body or AS a body in your nape space. Why not post a stripped down version of the class in your question? – net.uk.sweet Jun 20 '14 at 11:04
  • Hadn't seen you updated the post... Thought I'd get a warning on top of the page for that aswell. All I saw last days was "Your bounty on the question [...] expires in x days". Going to check it out thx – RAO Jun 27 '14 at 11:04
  • Sooo, cleared all 15 errors, one left: _Implicit coercion of a value of type PhysicsData to an unrelated type nape.shape:Shape_ -- In the line `floor.shapes.add(floorShape);` – RAO Jun 27 '14 at 19:17
  • Most of the errors were fixed when I changed `s.cbType = cbType;` to `s.cbTypes.add(cbType);` 5 others were related to the graphics thingy as you pointed out – RAO Jun 27 '14 at 19:19
  • No, there's still the _Implicit coercion of a value of type PhysicsData to an unrelated type nape.shape:Shape_ in the line `floor.shapes.add(floorShape);` – RAO Jun 28 '14 at 11:07