Tag Info

Hot answers tagged

2

Try this: var speed = Math.sqrt(Math.pow(heroVelX, 2) + Math.pow(heroVelY, 2)); The case is that the ^ operator is the bitwise XOR operator. You should use Math.pow(base, exponent). Here is a an example: link.


1

LET THIS BE A CAUTIONARY TALE ABOUT BOX2D! Haha! Here's the solution I came up with The problem I amrunning into is due to the fact that Box2D uses meters instead of pixels for the scale, in my game a screen that is 1920x1080 would be 1920 meters wide and if I am using sprites a small sprite will be only as many meters wide as it is in pixels. The reason ...


1

The setLinearVelocity method literally sets the Box2D body's x- and y-velocities to the given values. That means if the parameter for x is set, the character will begin moving horizontally. However, if the parameter for y is zero, the character will stop moving vertically. To fix this, you could either pass the character's current y-velocity in the ...



Only top voted, non community-wiki answers of a minimum length are eligible