开发者

Fast endless scrolling background

开发者 https://www.devze.com 2022-12-19 18:56 出处:网络
I\'m trying to create a endlessly scrolling bitmap background. I want to make it as efficient as possible as there is plenty of other game logic going on too.

I'm trying to create a endlessly scrolling bitmap background. I want to make it as efficient as possible as there is plenty of other game logic going on too.

The idea is to have a repeatable bitmap scroll horizontal开发者_StackOverflowly on an endless loop, which can obviously be achieved by placing two sprites of the same bitmap next to each other and offsetting one when it reaches the far left boundary.

I was wondering if there is perhaps a faster more efficient way to do this, perhaps using scrollRect or copyPixels? If anyone has any idea which method would be fastest, and perhaps some code to show me how it could be achieved I'd be extremely grateful!

Cheers!


Make a seamless looping image ( by cleverly joining the two) then, have a look at this older articles:

  1. Andre Michelle's Tile Mapping
  2. Senocular's Sprite scrolling

There should be some updated examples out there. Make a test with Grant Skinner Performance test and see what's faster for your setup, copyPixels() or scroll()

HTH, George

0

精彩评论

暂无评论...
验证码 换一张
取 消