0

file where I am getting error:

http://pastebin.com/7Pk45vUf

this error is thorwn at line:

var tV = b2Math.AddVV(poly.m_position, b2Math.b2MulMV(poly.m_R, poly.GetVertices()[0]));  

I am starting to break the mouse, I cannot understand why it does not have this method.

I am working by tutorial

http://net.tutsplus.com/tutorials/html-css-techniques/build-your-first-game-with-html5/

but it is with old box2d versio and I use newest version and there is so many differences. I fixed some of them, but am stuck at this point.

MY 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> -->
 <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='js/box2dutils.js'></script>  
  <script src='js/game.js'></script>  
</head>

  <canvas id="game" width="600" height="400"></canvas>  
  </body>
 </html>

game.js:

// some variables that we gonna use in this demo  
var initId = 0;  
var player = function(){  
    this.object = null;  
    this.canJump = false;  
};  
var world;  
var ctx;  
var canvasWidth;  
var canvasHeight;  
var keys = [];  


// HTML5 onLoad event  
//Event.observe(window, 'load', function() {  

$(document).ready(function() { //jquery doc ready

    world = createWorld(); // box2DWorld  

    var canvasElm = document.getElementById('game');  
    ctx = canvasElm.getContext('2d'); // 2  

    canvasWidth = parseInt(canvasElm.width);  
    canvasHeight = parseInt(canvasElm.height);  
    initGame(); // 3  
    step(); // 4  
// 5  
    window.addEventListener('keydown',handleKeyDown,true);  
    window.addEventListener('keyup',handleKeyUp,true);  
});


function initGame(){  
    // create 2 big platforms  
    createBox(world, 3, 230, 60, 180, true, 'ground');  
    createBox(world, 560, 360, 50, 50, true, 'ground');  
    // create small platforms  
    for (var i = 0; i < 5; i++){  
        createBox(world, 150+(80*i), 360, 5, 40+(i*15), true, 'ground');  
    }  
    // create player ball  
    /*
    var ballSd = new b2CircleDef();  
    ballSd.density = 0.1;  
    ballSd.radius = 12;  
    ballSd.restitution = 0.5;  
    ballSd.friction = 1;  
    ballSd.userData = 'player';  
    var ballBd = new b2BodyDef();  
    ballBd.linearDamping = .03;  
    ballBd.allowSleep = false;  
    ballBd.AddShape(ballSd);  
    ballBd.position.Set(20,0);  
    player.object = world.CreateBody(ballBd);  
    */



    var bodyDef = new b2BodyDef;
    var fixDef = new b2FixtureDef; 

    bodyDef.type = b2Body.b2_dynamicBody;
    fixDef.shape = new b2CircleShape(
        12 //radius
    );
    bodyDef.position.x = Math.random() * 10;
    bodyDef.position.y = Math.random() * 10;

    /*
    console.log('fixDef');
    console.log(fixDef);
    */
    player.object = world.CreateBody(bodyDef).CreateFixture(fixDef);

    var debugDraw = new b2DebugDraw();
                        debugDraw.SetSprite(document.getElementById("game").getContext("2d"));
                        debugDraw.SetDrawScale(30.0);
                        debugDraw.SetFillAlpha(0.3);
                        debugDraw.SetLineThickness(1.0);
                        debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit);
                        world.SetDebugDraw(debugDraw);
}  

function step() {  
    var stepping = false;  
    var timeStep = 1.0/60;  
    var iteration = 1;  
    // 1  
    world.Step(timeStep, iteration);  
    // 2  
    ctx.clearRect(0, 0, canvasWidth, canvasHeight);  

    drawWorld(world, ctx);  
    // 3  

    world.DrawDebugData();

    setTimeout('step()', 10);  
}  

When I console.log the poly var before that error, I get

http://pasteboard.co/KrmmMJa.png

Please help, otherwise it might be that I will have to go to shop and bue new mouse :D

Edited by McLaren

1
Contributor
1
Reply
2
Views
4 Years
Discussion Span
Last Post by McLaren
0

found what causes this error:

//case b2Shape.e_polyShape:  
    case b2Shape.e_polygonShape:  

changed to new and no such errror. Thanks to guy who wrote this artivle:

http://www.jeremyhubble.com/box2d.html

it uses newer version, so helped to find the difference.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.