How to link Nape to actual graphics?

56 views
Skip to first unread message

Leo Cavalcante

unread,
Aug 28, 2017, 8:59:59 PM8/28/17
to Nape Physics
Right,
I've Nape working great and I can see it through debugger,
but how can I make it work with actual graphics? From simple vectors to bitmap assets?
Cheers!

T1m_

unread,
Aug 28, 2017, 11:55:03 PM8/28/17
to Nape Physics

It depends on framework/engine you use. Nape itself provides basic drawing only for debugging purposes. Some Haxe/AS3 game engines provides Nape support out of the box, I suppose, so you need to look at them. But inside any of them will be simple principle: get a body's x/y/rotation and write it to properties of a display object.

Sample from pixi.haxe engine:
function _onUpdate(elapsedTime:Float) {
        _space
.step(1 / 60);

       
for(i in 0 ... _pballs.length) {
            _balls
[i].position.x = _pballs[i].position.x;
            _balls
[i].position.y = _pballs[i].position.y;
            _balls
[i].rotation = _pballs[i].rotation;
       
}
}


Leo Cavalcante

unread,
Aug 29, 2017, 9:09:59 AM8/29/17
to Nape Physics
Alright, exactly what I suspected, thanks!

Leo Cavalcante

unread,
Aug 29, 2017, 11:23:14 PM8/29/17
to Nape Physics
Decided to handle it by myself + OpenFl:
https://github.com/multisolution/haxe-game
A lot more work, but a lot more control and learn, I guess.

Feedback appreciated!
Reply all
Reply to author
Forward
0 new messages