Slight jitter on movement of all objects in opposite direction

Hi, Im getting to the mid point of my game.

Most the engine is in place and im currently optimising the game code to try and reduce what looks like a form of lag yet lags the wrong way.

Whats confusing me is the there is an intermittent jitter as all my objects scroll down the screen, as the objects move down they all slightly jitter in the opposite direction by 1-2 px upwards then continue as normal.

I have checked all the code by printing out x, and y updates and none of them go in that direction, updates are correct. These objects just sit within a static parent group. There are maybe 10-15 at the most, all with optimised artwork.

Has any one else suffered with this issue to help give me peace of mind and also if they can maybe share how they dealt with it.

Food for thought: How does corona deal with floating point numbers with x & y updates, could this cause issues?

Help, Thanks.
[import]uid: 118379 topic_id: 22619 reply_id: 322619[/import]

Are you using object:translate(x, y)

or object.x = object.x + 1

?

The first way is the fastest [import]uid: 84637 topic_id: 22619 reply_id: 90315[/import]

I have ben using method one but localising the x and y pos of objects.

I will try translate but when using profiler script I get results that suggest object.x = x was faster which made me stop using it. Maybe the profiler is wrong.

Could you enlighten me on why its faster if you know? I like to know why I do something.

Should I use when moving any objects 24/7?

My current project only uses physics for collision detection, wanted to make sure I got good at trigonometry so theres a lot of position updates.

Thanks for help :slight_smile: [import]uid: 118379 topic_id: 22619 reply_id: 90522[/import]

Also runs much better on XCode as a tip for anyone else. :wink: [import]uid: 118379 topic_id: 22619 reply_id: 90523[/import]

Ive been a bit of a noob and thought that it were the same as object.x = x but it adds it to the objects position instead. So like you say its object.x = object.x + 1.

Nonetheless ive been doing tests and cant see how translate is faster, e.g heres 2 examples one with translate and one without taken from a basic class:

--without ,the last line takes up 49% of the function time according to profiler  
local obstacleY = y  
  
function obstacle:move(yOffset)  
 obstacleY = obstacleY + yOffset  
 if obstacleY \> 540 then  
 obstacle:removeEventListener("collision", obstacle)  
 obstacle:removeSelf()  
 obstacle = nil   
 return  
 end  
 obstacle.y = obstacleY  
 end  
  
-- vs, which takes up 58% of function time according to profiler.  
 local obstacleY = y  
 function obstacle:move(yOffset)  
 obstacleY = obstacleY + yOffset  
 if obstacleY \> 540 then  
 obstacle:removeEventListener("collision", obstacle)  
 obstacle:removeSelf()  
 obstacle = nil   
 return  
 end  
 obstacle:translate(0,yOffset)  
 end  

Is profiler wrong or am i saving resources by using localised variables within my class [import]uid: 118379 topic_id: 22619 reply_id: 90528[/import]