away168 Posted March 2, 2014 Share Posted March 2, 2014 Hey guys, I have used createPattern from Canvas for tiling sprites but I realized it's very expensive to use. Do you guys know any tips/other methods to do it that is faster than that? Thanks. Quote Link to comment Share on other sites More sharing options...
Gio Posted March 2, 2014 Share Posted March 2, 2014 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. Quote Link to comment Share on other sites More sharing options...
away168 Posted March 2, 2014 Author Share Posted March 2, 2014 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? Quote Link to comment Share on other sites More sharing options...
Gio Posted March 3, 2014 Share Posted March 3, 2014 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). Dread Knight 1 Quote Link to comment Share on other sites More sharing options...
away168 Posted March 4, 2014 Author Share Posted March 4, 2014 That's a nice out-of-the-box idea Gio, thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.