YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Center ViewRect - HTML5 Game Development

Get Embed Code
3 Languages

Showing Revision 6 created 05/25/2016 by Udacity Robot.

  1. >> Now, the first thing we do is actually set the viewRect width and height
  2. equal to the canvas size. This way we know that the viewRect is actually going
  3. to encompass everything that the canvas can actually see. From here, we actually
  4. translate the x and y value of the viewRect by offsetting it by half of the
  5. canvas size. Now, what this is going to do is effectively shift the viewRect,
  6. such the x and y value are at the center. Of the viewRect, meaning that it's at
  7. the center of what the canvas will draw.