Lag with display.capture()

I have a game I’m building that relies on a moving object, controlled by physics. This object “deposits” trails behind it that currently I have as simple vector lines. Think of a pencil moving around the screen drawing a line. The trails works great, but at certain points I need to run display.capture() to capture the bkgd and current trails - and then behind this new capture, remove the old base and all the trails objects. This frees up memory and allows me to have nearly an unlimited # of trails on the screen - all thanks to being able to take a snapshot of a display group using display.capture().

All seems to be working well, but when display.capture happens, there’s a lag where literally everything stops - including animations. If this happens at the wrong time, placement of physics-powered objects now become off-place and some even try to run their animation again (looks really weird).

Now… with that said, I do understand that I am taking a snapshot of a complex display group and also immediately after, trying to remove lots of display objects (maybe a few hundred). All of this “works”, but there’s a performance hit…

I’ve tried to being animations to a stall so I can time this at the right point, but there’s no callback or ability to see if that display.capture() has completed. Also that the old group/objects removal completed too.

Does anyone have any suggestions on how to wait for a display.capture() to finish? Kinda like an onComplete() for a display.capture()…

Thanks! [import]uid: 131038 topic_id: 24803 reply_id: 324803[/import]

Would setting the activity indicator to show prior to the capture and stopping it right after work as far as an indicator goes, or is that not what you are looking to do? (Sorry, long day and I might be misunderstanding this.)

In any case, it may be worth reporting this if you can include a sample we can run demonstrating the issue, if you wouldn’t mind. [import]uid: 52491 topic_id: 24803 reply_id: 100769[/import]

Hey there Peach - thanks for the help! I’d love to post a sample but it’s spread out over tons of lines of code over a few lua files… I think I have found a workaround for now that mimics what you were suggesting. Ultimately I think it’s the nature of what I’m trying to do that is just plain processor intensive. Creating a snapshot out of a large bkgd image and a few hundred colored, vector lines. It’s working great, but I had to implement the workaround. Looking forward to showing you all this game soon :wink:

Nate [import]uid: 131038 topic_id: 24803 reply_id: 101264[/import]

Sounds good Nate, I’ll look forward to that.

Glad to hear that your workaround seems to be doing the trick for now - unfortunately yes, if things get too intensive there may be a little unavoidable lag in some cases. [import]uid: 52491 topic_id: 24803 reply_id: 101481[/import]