box2dweb

Node.js Box2dWeb error caused by require()

試著忘記壹切 提交于 2020-01-05 02:16:47
问题 I'm trying to make a server using Node.js and Box2dWeb engine. But trying to "import" the "box2d.js" throws me a random error which doesn't seem to be related with what I'm doing. Here's the code that's causing the error: var Box2D = require('./box2d.js'); Here's the error: console.js:55 this._stdout.write(util.format.apply(this, arguments) + '\n'); ^ TypeError: Cannot read property 'write' of undefined at Console.log (console.js:55:15) at TCPServer.<anonymous> (C:\Users\conne_000\Documents

Node.js Box2dWeb error caused by require()

情到浓时终转凉″ 提交于 2020-01-05 02:16:22
问题 I'm trying to make a server using Node.js and Box2dWeb engine. But trying to "import" the "box2d.js" throws me a random error which doesn't seem to be related with what I'm doing. Here's the code that's causing the error: var Box2D = require('./box2d.js'); Here's the error: console.js:55 this._stdout.write(util.format.apply(this, arguments) + '\n'); ^ TypeError: Cannot read property 'write' of undefined at Console.log (console.js:55:15) at TCPServer.<anonymous> (C:\Users\conne_000\Documents

How do I remove a body in Box2dWeb after a collision

岁酱吖の 提交于 2020-01-01 10:15:15
问题 Inside of the Update function, if 2 bodies collide I want to remove them (or mark them as needing to be removed, and remove them at the end of the time step). How would I accomplish this? In the Update function I try var bodyA = this.m_fixtureA.m_body; ... bodyA.m_world.DestroyBody(bodyA); However, they don't get deleted. It seems that when I am trying to delete them, this.IsLocked() is set to true. 回答1: The world will not remove bodies if the world.IsLocked() function returns true. And world

How to include liquidfun physics engine with nodejs

陌路散爱 提交于 2019-12-23 11:41:10
问题 I have been making a game with box2dweb and node.js. Everything has been working fine until I decided to switch to Google's LiquidFun engine, which is also based on Box2d. In box2dweb I could export the modules I needed by adding the following to the bottom of the box2d.js file. module.exports = { b2Vec2: Box2D.Common.Math.b2Vec2, b2BodyDef: Box2D.Dynamics.b2BodyDef, b2Body: Box2D.Dynamics.b2Body }; LiquidFun doesn't use the same namespacing in its compiled file so I tried: module.exports = {

Using transformation matrix in KineticJS

房东的猫 提交于 2019-12-22 09:20:06
问题 I have a body simulated with Box2Dweb and an image attached to the body. I want to take the body transformation matrix and apply the transformation to the image (draw the image with the transformation), so that its position and orientation (relative) on the screen matches that of the body. I can't find a function for using with a transformation matrix in KineticJS. There are separate functions for moving and rotating, and there's a Kinetic.Transform class which holds some 'matrix' inside, but

javascript games ThreeJS and Box2D conflicts?

本小妞迷上赌 提交于 2019-12-13 02:31:03
问题 I've been trying to experiment with box2d and threejs. So box2d has a series of js iterations, I've been successful at using them so far in projects as well as threejs in others, but I'm finding when including the latest instance of threejs and box2dweb, threejs seems to be mis-performing when just close to box2dweb but maybe I'm missing something really simple, like a better way to load them in together, or section them off from one another? I've tried a few iterations of the box2d js code

When creating a joint during runtime, object teleports

蹲街弑〆低调 提交于 2019-12-12 01:06:54
问题 I have two objects and when the distance between them is less than 10, I create a joint: var joint_def = new box2d.b2RevoluteJointDef(); joint_def.bodyA = body1; joint_def.bodyB = body2; joint_def.localAnchorA = new box2d.b2Vec2(0, 0); joint_def.localAnchorB = new box2d.b2Vec2(0, 0); world.CreateJoint(joint_def); The problem is, however, that one object teleports/jumps on top of the other. The intended behavior would be that one object slowly moves on top of the other. Any idea? Thanks. 回答1:

Using transformation matrix in KineticJS

旧时模样 提交于 2019-12-05 18:10:20
I have a body simulated with Box2Dweb and an image attached to the body. I want to take the body transformation matrix and apply the transformation to the image (draw the image with the transformation), so that its position and orientation (relative) on the screen matches that of the body. I can't find a function for using with a transformation matrix in KineticJS. There are separate functions for moving and rotating, and there's a Kinetic.Transform class which holds some 'matrix' inside, but I have no idea what to do with it then. There's also a _setTransform function somewhere, but again, no