Frame drop issue with Tilesheet

Hi,

I’m using Tilesheet to draw my tilemap.
At first, there is no frame drop at all.
But when I move the scene (which makes to redraw the tiles) more than 30 seconds, the frame is dropped to 40(or less when I move longer).

My code looks like this:

public function update(elapsed:Float) {
	tileData = [];
	
	~~ //update tileData(concat array : tileData = tileData.concat([transform.position.x, transform.position.y, tile.type]);)
	
	tilesheet.drawTiles(tileLayer.graphics, tileData);
}

Where is the wrong part? I don’t have any idea.

Ah, and one more question.
When I put tileLayer.graphics.clear() before drawTiles, whole screen goes white. why is that?

Thanks.

Are you continuously growing your array?
It could be the source as you’d have more and more to do as time pass, taking longer and longer each time.

The array initialized in the very first line of update loop(it isn’t?).
And I got no frame drop when I launch app and do nothing.

“which makes to redraw the tiles” normally you are always redrawing. You need to call clear, if you don’t the calls will stack. The tilesheet draw is not like the bitmap.draw it works more like graphics draw rectangle, the final draw won’t be cache. Graphics just calls each call each frame to create the final resul.

Well, that’s my second question
When I call clear just before drawTiles, cleared sprite is drawn.

Yes you should call clear before drawing, but you also need to draw all the info again, recreate the entire array. Make sure that your array is not empty before you draw.

Oh! Once it draw, array goes blank…

I was recreating the array in special condition.
Problem solved, but average frame rate reaches under 40 still.
Are 240 tiles too many?

Is your project.xml set to 60 fps? Is your machine too old? or your tiles too big? which target? flash dosen’t use GPU you need to use a lib for that.

I set the fps yes.
I’m targeting android and testing with Optimus G(3 years old).
My tile size is 100x100.

Sorry for my rambling and the lack of information.

Well the size of the tiles are big, you are drawing 2,400,000 pixels thats more than double the resolution of 1280x720 = 1,048,576 pixels try using the bunny frome the BunnyMark as the texture. Whithout seeing your code, thats all I can asumme.

Using bunny occured no change.
And I found using Scout that Garbage Collection takes 45% of time.

Problem solved!!
Reusing array was a solution. Thank you!

Your welcome! yes you have to be careful with new calls in an update, by rule I always avoid them even if its just a simple point.