English subtitles

← Entities and Physics - HTML5 Game Development

Get Embed Code
4 Languages

Showing Revision 9 created 05/24/2016 by Udacity Robot.

  1. Now, InGrids, we allow any entity definition to have a physics object, that is
  2. an entity doesn't inherit from physics object and isn't required to have one e.
  3. Now from those daring digital souls who want one, they'll need to actually
  4. create a handle to the physics body and keep it around over time so they can
  5. manipulate it. Before they can do that, of course they have to first fill out
  6. the entity definition object and pass that out to the gPhysicsEngine.addBody
  7. which we've coded up previously. Now for grids, every object in the world is in
  8. a box. So our description is pretty easy to generate. First off, we passed the
  9. x and y position values to the class, alongside the halfWidth and halfHeight of
  10. the box representing its size. In addition to that, box 2d expects some
  11. specific surface properties such as dampening, friction, things along those
  12. lines. So we go ahead and set them here as well if we want them.