Jump to content

Best way to create repeating sprites using Canvas?


away168
 Share

Recommended Posts

Surely it can't be more expensive than drawing the same sprites many times with several drawImage() calls?

 

Anyway, you could do this once and draw to an off-screen canvas, then you can draw your off-screen canvas onto your main canvas.

Link to comment
Share on other sites

Yeah multiple drawImage calls is more expensive for sure... Guess I have no choice.

 

 

Anyway, you could do this once and draw to an off-screen canvas, then you can draw your off-screen canvas onto your main canvas.

 

I'm sorry I'm not clear yet, is that a parallax background example?

Link to comment
Share on other sites

No, I meant... if the thing that your are drawing doesn't change, instead of drawing it every frame with createPattern, you could draw it with createPattern just once and cache it (draw it to a canvas object that isn't part of your DOM). Then for every frame draw this canvas object onto the canvas that is actually visible with drawImage (without having to use createPattern again).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...