Hot answers tagged box2d
Given a "root" curve, here's how you might generate block vertices. The root curve is in the middle, in black. Its control points are shown with red Xs. In short: I made a Bézier and sampled it (at a configurable rate). I then found the perpendicular vector of the vector from each sample to the next, normalised it, and scaled it to to a (configurable) ...
You have variable centerlineX. If the sprite is to the left of it, accelerate with a 'gravity' vector, e.g. 9.81. And vice versa for the other side. Presumably this should result in the sprite oscillating back and forth for ever, so you will need to add something to the mix to slow it down at a pleasing rate.
I think this may be a bug in box2dweb. If I add this to the body definition, it works: bodyDef.linearVelocity.x = 1; bodyDef.linearVelocity.y = 1; But of course, if you want the body to start motionless, you would do: bodyDef.linearVelocity.x = 0; bodyDef.linearVelocity.y = 0; ... which does not work. Trying to trick it by using a very small value ...
You don't need to search "verlets" or "verlet". For anyone else reading this: verlet is a mostly outdated type of integration in modern physical simulation. This sort of thing can be achieved in two dimensions whith custom (almost gameplay specific) code. The exact details of doing this sort of thing don't have to be very fancy (not that verlet is fancy at ...
TimeUtils.millis() Maybe you mean to do: final long floatyPeriod = 3000; //3 secs long now = TimeUtils.millis(); long delta = lastTime - now; lastTime = now; object.floatyTime += delta; if (object.floatyTime > floatyPeriod ) object.floatyTime -= floatyPeriod; ... float value = (float) ( amplitude * Math.sin( 2 * Math.PI * frequency * ...
You have the time (30fps = 0.5seconds) You have the distance (DesiredPosition - Position).Length() You can calculate your required speed now: Speed = Distance / Time; Then just set this speed as your physic's objects velocity, and in theory it should reach the destination. This does not account for drag, friction, etc..
Only top voted, non community-wiki answers of a minimum length are eligible