Questions tagged [box2dweb]

Box2dWeb is port of box2dFlash port to javascript.

Box2dWeb is a physics engine and it's basically a port of Box2DFlash library to JavaScript.

95 questions
0
votes
0 answers

Box2dWeb: Object Rotation - GetWorldCenter not found

I'm trying to make a function for a skydiving game that'll make a sprite rotate left/right and then move that way depending on how angled it is, at least i would be if the object's get world centre parameter was recognised, code is as…
0
votes
0 answers

Get all particles in particle group liquidfun javascript

I am using liquidfun.js and I wanted to set the color of the water, but I am using spawnParticles to spawn the water, and I don't know how to get all the particles in a particle group. Current code: let particles = spawnParticles(1, 0, 5)
Yaumama
  • 17
  • 6
0
votes
1 answer

How to find if top of rectangle collided or not in box2d

I have rectangular player in top down game. I want to find which side(to be specific top of rectangle ) of rectangle is hit by other game objects.
JustStarted
  • 130
  • 5
0
votes
0 answers

Finding collision point outside of contact listener in Box2D

So, I have a scenario in a Box2D project where a sensor "eye" (basically a line) collides with one or more objects, and I want to find the one that's closest to the bottom of the eye. This means that for each fixture colliding with the eye, I'd like…
mostsquares
  • 834
  • 8
  • 27
0
votes
0 answers

collision two sprite dynamic and static and stop moving

i have two sprite var enemy1 = game.add.sprite(200 + 1*200,180,'enemy'); game.physics.box2d.enable(enemy1); enemy1.body.static = true; m_ship = game.add.sprite(150 + i * 125, 300, 'ship'); m_ship.scale.set(2); m_ship.smoothed =…
user836080
  • 55
  • 1
  • 9
0
votes
1 answer

How to use ApplyForce with box2DWeb

I have a Box2DWeb sketch working ok but I am unable to figure out how to use the ApplyForce method with a body. I have attached the working codepen. On line 85, I have commented out the line that I thought would work but everything disappears when I…
steven
  • 11
  • 3
0
votes
1 answer

Box2dWeb bodies not colliding

I've implemented Box2dWeb into a Node.js server and everything works fine apart from collisions. When there are 2 players connected their bodies don't collide - just go through each other. Here's the player body creation code: //World creation var…
coNNecTT
  • 85
  • 2
  • 7
0
votes
0 answers

Trying to move a dynamic body in box2dweb on keypress

I have created a dynamic_body and I want to move that body using an EventListener. But, I can't access the body and there is an issue with ApplyImpulse() or the ApplyForce() function in my code. But I can't see it. What am I missing? function init()…
0
votes
1 answer

How can I get the canvas context to follow a body in Box2dWeb?

I am uing Box2D.Dynamics.b2DebugDraw to render my Box2dWeb world. How can I get the canvas to remain centered on a moving body? var debugDraw = new…
sennett
  • 8,014
  • 9
  • 46
  • 69
0
votes
1 answer

Is there a way to achieve change in gravitational pull using box2d?

I am trying to create a scene where first half has gravity from the top and second half has gravity at the bottom. How do I achieve this in Box2D as I can only define gravity for the whole world. Do I need to split screen into two worlds ?
Amogh Talpallikar
  • 12,084
  • 13
  • 79
  • 135
0
votes
0 answers

context is not defined, javascript

function moveCamera() { var canvas_holder = document.getElementById("game"); var context = canvas_holder.getContext("2d"); // camera code // START // Viewport height var eye = $("#container").height(); // canvas height var…
user3676606
  • 13
  • 1
  • 6
0
votes
1 answer

Why is this file not running the javascript that is in example5.js?

I found this code on the internet. I pasted into my notepad++ and then changed these two files to match the ones that I created on my desktop.
Doug Hauf
  • 3,025
  • 8
  • 46
  • 70
0
votes
1 answer

In box2dweb how to destroy created body

I create bodies at mouse click with this pretty standard way in box2dweb: *stage.onMouseDown = function(){ var fixDef = new box2d.b2FixtureDef; fixDef.density = 1; fixDef.friction = 0.5; fixDef.restitution = 0.7; var bodyDef…
0
votes
1 answer

Box2d bodies unstable and does not come to rest

I was trying to experiment with box2d as a PoC for a game project, well i managed to create the world and bodies and default DebugDraw in place. Have been playing with restitution, density and friction but could not get the desired behavior and the…
0
votes
1 answer

how does this code in box2dweb simulating the universal gravitation and why does it use a if statement?

b2GravityController.prototype.Step = function (step) { var i = null; var body1 = null; var p1 = null; var mass1 = 0; var j = null; var body2 = null; var p2 = null; var dx = 0; var dy = 0; var r2 = 0; var f = null; if…
zeng.js
  • 1
  • 1