Flash performance for game dev: native render VS BitmapData framebuffer

前端 未结 5 2119
感动是毒
感动是毒 2021-01-30 23:19

I develop a 2D shooter game with lots of objects and aggressive scrolling.

QUESTION: which way is better?

CHOICE 1 - use nativ

5条回答
  •  情深已故
    2021-01-31 00:01

    I found the custom (bitmap rendered) version to be much faster, and would have expected that.

    Flash's DisplayList is designed to account for a huge number of variances in the DisplayObjects and as a result will not be the most efficient route to go (unless you end up accounting for all those variances yourself in AS3, in which case you'll lose to the native code).

    For example, for tile rendering (where you're doing copyPixels for tiles), a custom bitmap renderer will be far faster than have hundreds of DisplayObjects on the DisplayList. You can also likely use a specialized clipper to toss out tiles, whereas Flash ends up doing very generic bounding-box calculations and tests.

    In re: variances, for example, in your custom version the "building" sprite wobbles as the character moves around, probably due to a float-to-int conversion or round-up instead of round-down in your code.

提交回复
热议问题