0

Can anyone help or give ideas on how to use HTML5 canvas translate to make a scrolling camera to follow an object?

Adam Ralph
  • 29,453
  • 4
  • 60
  • 67
kreal
  • 3
  • 1
  • 3

1 Answers1

2

You want to use ctx.translate(x, y) to move the canvas context while you draw your objects normally.

For more detail and suggestions see my answer here: 2D side scrolling camera view in html5

The accepted answer for that question is another valid way of doing things but is much worse performance-wise.

Community
  • 1
  • 1
Simon Sarris
  • 62,212
  • 13
  • 141
  • 171