Hi guys,
First of all i want to thank you all for your amazing work your doing here. Besides the fact that Starling framework its awesome, it's really refreshing to see there is a strong and active community around it.
Let me describe the problem i'm facing. I'm trying to create a side scrolling game, very similar to Tiny Wings for iPhone. I want to dynamic generate those hills, and apply a texture to them.
I was following this tutorial from Emanuele Feronato http://www.emanueleferonato.com/2011/10/04/create-a-terrain-like-the-one-in-tiny-wings-with-flash-and-box2d-%E2%80%93-adding-more-bumps/ to create the hills. Thats using box2d. And then i tried to port that code to Starling. Here is what im actually tring to do:
1. For each hill i'm creating a new flash.display.Sprite and drawing there the hill using bitmap fill.
2. After that i create a bitmap data from this sprite like this
var bd:BitmapData = new BitmapData(hill.width, 480, true, 0xffffff);
bd.draw(hill);
3. Then i create an image like this img = new Image(Texture.fromBitmapData(bd));
4. Then i add this image to a starling.display.Sprite
The problem: Whenever is time to add a new hill, there are some visible performance hiccups. While scrolling, the animation hangs for a few miliseconds, while adding that image to the starling sprite.
How do i fix that? Or maybe there is another way to do what i want to achieve?
You can see the full code here: http://pastebin.com/k0qHqBn8
You can see the demo working here: http://scrumster.com/starling_test/StarlingTest.html
Use left and right arrows to scroll the world. The performance hiccups are more visible when running in debug mode, in flash builder.
Really appreciated,
Marius Bratu.