I\'m trying to make a game in HTML5 canvas, but instead of uploading a ton of images I want to just upload one image that has all of the tiles on it. The problem is, I don\'t kn
You can use the slicing parameters of drawImage
drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight)
sx
, sy
: left and top offset of the part to be slicedsWidth
, sHeight
: dimensions of the part to be sliceddx
, dy
: left and top offset for the image on the canvas to be rendered atdWidth
, dHeight
: image dimensions on the canvasMore info at: Using images - Slicing (MDC)