开发者

Background Panning in Flash AS3

I am making a river rafti开发者_如何转开发ng game in Flash AS3 for Flash Player 9. In my game my raft is static and river is moving in vertically, game area is 760x620 and background clip is 1800x700, I have 5 background clip and attaching on runtime. And every background having river bank, stones, Strong rapids, fishes etc.

Can you suggest the optimized way to pan these clip without any FPS drop? I have tried scrollRect also.


My first try would be a tweening library such as TweenLite or TweenMax


Split up your background clip in several parts. Considering your background size is not a multiple of the screen size, I would suggest at least 6 parts of 300 pixels width, better yet 12 parts of 150 pixels width each. Add all those once to one empty container Sprite moving from x=0 to x = -container.width, and once more to one container moving from x=container.width to x=0. I would recommend using Tweener.

Check for your container's position on each frame update, set visible = false on all the parts that will not be seen in the screen area. Set visible = true on the other ones.


Connect all the bitmaps in one sprite and move that sprite vertically. You can check for out of bounds bitmaps using a hit test.

I wouldn't recommend any tweener, I think it complicates things needlessly.

Instead create your own function to move the background in set increments every frame, that way you can link it to the speed of the boat much easier.

As far as optimization goes, all the as3 experts advise to get it working first and optimize later. You might find that things work just fine without the added hassle.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜