Scrolling map causing a drop of 20fps!!! Someone please help!!!

Hi All ( and Ansca ),

I have a question that relates to tile based maps. We built a demo to try out the new performance improvements and we succeeded in getting a map of 50x50 ( 64x64 px tiles ) tiles and physics per tile, with 70-80 sprites (with physics ) on the map, with full accelerometer control running at 60fps on the sim, and also running at 60fps on device ( iPhone4 ) as well.

This demo was mainly to test how we could apply the technique to the game we are working on. Just to be clear, the tiles are drawn once into an imageGroup, using tile images from an imageSheet. We do not need to animate tiles so this works well for us. I do not cull individual tiles as this performance update should ( as stated ) be doing off screen culling of objects anyway at low level.

This brings us to the game we are working on…

It makes use of Lime and Tiled to get our maps into the game, but as Lime doesnt yet make use of imageGroups, we rolled our own ‘tile drawing into layers’ that Lime would normally do for you with lime:createVisual(), lime:createPhysical(). We also set the map position and clamp it using our code. However to leverage some of lime’s functionality we do set references to our display layers ( imageGroup, displayGroups ) on the corresponding tile layers as Lime sees them ). In making use of an imageGroup for the tiles, we did get performance improvements ( average of 37 fps or less ) but not as we expected. And we noticed something quite interesting…

It should be pointed out that this game is doing player and game object movement, animation, collision ( the landscape has a large physics object attached to it ) and collision response, full headup display, in short, we are doing the usual things in a game loop to make any game playable.

Here is the odd thing… when the map is scrolling ( to keep the player centred on the screen ) we are getting 37fps or worse on device ( iPhone4 ) but when the map can’t be scrolled ( it’s come to map edge, or x, y doesn’t change ), the fps jumps to 60fps. And this is with everything else still running as before. Again, we are not doing any culling of tiles or gfx ourselves, just to be clear.

So what I want to know is why scrolling the map is losing us 20fps?

Does anyone have any idea why this should happen?

All I do to scroll is change the x and y ( and rounding it or you get gfx artifacts! ) of the displayGroup holding all the layers [I do not use Lime to do this] It’s about the simpliest way you can do it.

Does anyone have any explanation or ideas?

Thanks [import]uid: 134650 topic_id: 23761 reply_id: 323761[/import]

have you tried making the display group a kinematic physics object
and scrolling it using setLinearVelocity? that seemed to improve
things in my game… ymmv…

this will also remove the need to round up or down your movement values, which should help things move smoothly.

i also highly highly recommend my’s profiler

http://www.mydevelopersgames.com/site/

it’s so simple to track down what’s causing slowdown in your app,
and at the price it’s a steal. [import]uid: 118333 topic_id: 23761 reply_id: 95616[/import]

boss1,

We tried your suggestion but it didn’t change anything.

We bought your profiler about a month ago and it said that the framerate counter was using up 25% of the processing power. We removed the counter but we are still losing 20fps with the scrolling. The profiler did not identify any issue with the scrolling. Not sure what to do next.

[import]uid: 134650 topic_id: 23761 reply_id: 96130[/import]

not my profiler :slight_smile: mydeveloper’s profiler. i can’t take credit for that…

have you tried spreading the perframe workload around - eg update the HUD on every 3rd frame, bad guys on every 2nd…that kind of thing?

[import]uid: 118333 topic_id: 23761 reply_id: 96133[/import]

Minor shot in the dark, but did you try Lime 3.5 beta yet? I was under the impression that uses the new image sheet stuff? [import]uid: 41884 topic_id: 23761 reply_id: 96135[/import]

Yeah we’ve got Lime beta, and we’ve also made a test build which only displays a scrolling tilemap. Once the scrolling stops, we get 60fps.

I’ve found one of the smaller levels achieves 60 even when scrolling, so I’m thinking maybe it’s down to the number of tiles displayed. I noticed that Lime 3.5 doesn’t do any tile culling any more, so that’s our next step.

I investigated different methods of scrolling (rather than using map.x and map.y directly, map:setPosition etc), even looked at changing the parent displaygroup’s x and y, so that the map’s properties and attached physics don’t change. Still got the same result. [import]uid: 276 topic_id: 23761 reply_id: 96230[/import]