no updates while dragging a display group

Had a look to see if anyone else was having this issue but haven’t found anything.

Essentially I have a display group with n (say 20-50) number of objects in it that I am trying to drag from one position to another. I am doing this by changing the x and y values of the display group. As an example, something like this;

local displayGroup = display.newGroup()

displayGroup.x = newX
displayGroup.y = newY

This happens during the touch event.phase == “moved” but the issue I am seeing is that the objects (everything in the display group) are not moved until the touch event goes to “ended” or “stationary”. If I keep moving my finger (ie. keep the event in the “moved” state) then everything freezes until i either stop or lift my finger. Putting prints into the different phases shows that “moved” is being called multiple times (presumably per frame).

Is this something anyone has witnessed before? Any idea what I could be doing wrong? Possible bug?

This only happens on device (tested on 3GS thus far)
Corona version 286 (have not tried on any other version)

Best Regards
Hobsie [import]uid: 5883 topic_id: 5645 reply_id: 305645[/import]

post more code. can’t tell what you are doing here without seeing your basic setup and your drag code [import]uid: 6645 topic_id: 5645 reply_id: 19297[/import]

Well basically I have a a touch event function.

local onTouch = function(event)   
 manager:drag(event)  
end  

That in turn moves the display group: (slightly modified from source)

In Manager

function drag(event)   
 if(event.phase=="began") then  
 print("Touch began")  
 displayGroup.touchPosition = {}  
 displayGroup.touchPosition.x = event.x - displayGroup.x  
 displayGroup.touchPosition.y = event.y - displayGroup.y  
 elseif(event.phase=="moved") then  
 print("Touch moved")  
 if not displayGroup.touchPosition then  
 displayGroup.touchPosition = {}  
 displayGroup.touchPosition.x = event.x - displayGroup.x  
 displayGroup.touchPosition.y = event.y - displayGroup.y  
 end  
  
 displayGroup.x = event.x - displayGroup.touchPosition.x  
 displayGroup.y = event.y - displayGroup.touchPosition.y  
  
 print("New Location " .. displayGroup.x .. " " .. displayGroup.y)  
 elseif(event.phase=="ended") then  
 print("Touch ended")  
 end  
end  

Where displayGroup is a display group that contains multiple objects. I know the actual movement is working since the objects in the group do move. It is just that the whole thing seems to seeze up during the move event. I just added an fps counter and that also freezes at the same time.

Works as expected in simulator.

Regards
Hobsie [import]uid: 5883 topic_id: 5645 reply_id: 19310[/import]

I have been investigating this further and have come up with some odd behaviour.

It would seem that the number of sprites on the screen has a very large impact on the touch listener (when event == “moved”). In my test if i reduce the number of sprites on screen then dragging an object or group becomes smoother but still jittery.

In actual fact it also seems as if moving the group or sprite has no bearing on this issue at all. If I remove all movement code from my drag method I still get the same screen freeze issue when touch.event == “moved”. Again, reducing the number of sprites on screen has a direct relationship to how jittery things are.

When the touch event is not in the moved state everything seems to run perfectly smooth with moving and animated sprites but the moment it goes into moved things freeze up. It is almost as if corona’s internal render loop is being blocked/skipped when the touch listener is in the moved state.

Unless I am doing something stupid here it is starting to seem like this could be a bug in the Corona touch listener area.

Again, this only occurs on device (3GS)

Best Regards
Mark H [import]uid: 5883 topic_id: 5645 reply_id: 19537[/import]

+1 for info to this as I am having similar issues. [import]uid: 5833 topic_id: 5645 reply_id: 19756[/import]

Is it a general touch event of a group event? [import]uid: 5712 topic_id: 5645 reply_id: 19792[/import]

For me it is a general event. [import]uid: 5833 topic_id: 5645 reply_id: 19799[/import]

Another update.

So it turns out that I have a specific function call that was causing this problem. It is a sprite culling function that attempts to set inVisible = true for sprites outside of the screen. Since I am using a grid based setup I can quite quickly get the sprites on screen (I set all sprites to be invisible as they are create on load).

Even with this, however I do end up looping some 450 times (150 sprites on screen with 3 layers of them). This does result in a pretty slow method (using the system.getTimer() it takes anything up to 20ms to complete). As I was getting a pretty painful framerate before hand I figured this could be a good trade off (For Corona Dev’s - Automatic Screen space culling pleases!) even if the method does take up half a frame.

What I didn’t expect, however, is that a slow method like this would cause the rendering to stop when used inside the touch.event == “moved”

So I guess this is both a none issue and an issue. I’m running a function that takes to long during a touch event but at the same time should the rendering for that frame stop?

Ironically this wouldn’t be an issue at all if Corona culled sprites outside the viewing area…although I hope you come up with a faster method than mines :stuck_out_tongue:

Regards
Mark H [import]uid: 5883 topic_id: 5645 reply_id: 19800[/import]