index.html
<html>
<body>
<head>
<!--[if IE]><script src="lib/excanvas.js"></script><![endif]-->
<!--<script src="libs/prototype-1.6.0.2.js"></script> -->
<!-- <script src="//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script> -->
<style type="text/css">
canvas {
border: 1px solid green;
}
</style>
<script type="text/javascript" src="libs/jquery-1.7.1.min.js"></script>
<!-- box2djs -->
<script src="libs/Box2dWeb-2.1.a.3.min.js"></script>
<!-- <script src="libs/box2d.js"></script> -->
<script src='js/box2dutils.js'></script>
<script src='js/game.js'></script>
</head>
<canvas id="game" width="600" height="400"></canvas>
</body>
</html>
game.js
box2dutils.js
By this tutorial:
http://net.tutsplus.com/tutorials/html-css-techniques/build-your-first-game-with-html5/
now I cannot understand why there is no offset fo objects - all of them are drawed on the bottom left corner.
I think lines like this
var tV = b2Math.AddVV(poly.m_position, b2Math.b2MulMV(poly.m_R, poly.m_vertices[0]));
had to do the offsetting but they do not work, as you can see I commended out in drawShape() function those lines for at least for code to work.
When I uncomment
var vert = poly.GetVertices();
var tV = b2Math.AddVV(poly.m_position, b2Math.MulMV(poly.m_R, vert[0]));
I get error:
Uncaught TypeError: Cannot read property 'col1' of undefined
What is col1 ? I cannot under stacnd. I look at the framewokr core file and see the function
b2Math.MulMV = function (A, v) {
var u = new b2Vec2(A.col1.x * v.x + A.col2.x * v.y, A.col1.y * v.x + A.col2.y * v.y);
return u;
}
So it expects col1. But I did not see anywhere in the examples the col1.
vert[0] does not have col1
Here is from the console what this object look like - after the word 'poly':
http://pasteboard.co/KKHiMQd.png
I create the object using CreateBody and CreateFixture so they should care. I don't get it :( spent whole sunday and did not even finish simple thing :(