Box2d demo

60 views
Skip to first unread message

Andy Leedy

unread,
Dec 30, 2014, 11:33:02 PM12/30/14
to androi...@googlegroups.com
Ok I took a shot at getting Box2d working in DroidScript.

I used this as resource:

It is fully working except the ground seems to pivot occasionally. I may not quite have the settings correct, or it could be Droidscript not sure.

Perhaps someone else even has a better working demo they can post or possibly post a fix to what I've provided.

Note: You'll need to edit this line to your screen size to try it out (line 36 in MyApp.html)
<canvas id="c" width="600" height="800"></canvas>

It would be cool to see Box2d added to Droidscript. :)

MyApp.spk

Andy Leedy

unread,
Dec 30, 2014, 11:47:31 PM12/30/14
to androi...@googlegroups.com
I forgot to cleanup the code a bit...

Here is a better version to try.
MyApp.spk

Dave Smart

unread,
Jan 3, 2015, 8:09:42 AM1/3/15
to androi...@googlegroups.com
Hi Andy,

That's a good start...  its worth noting that the requestAnimFrame() method is very slow on Android (about 15fps in my experience) so you might be better off using a setInterval() call instead.

Also I think you might get much better performance by not using the HTML5 canvas but combining the Box2d engine with a GLView instead :)

Regards
David
Reply all
Reply to author
Forward
0 new messages