Issue sliding way smoothly

Hello, I am developing a game which is like classical race games. I have a character on screen and the way is sliding down infinitely.

http://img195.imageshack.us/img195/7789/way.png

I sliced the way above into 2 from mid and also copied them so I have 4 parts. I put them into an array like that;
Road.lua

 roadGroup.wayList = {};  
 roadGroup.images = {};  
 roadGroup.images[1] = "images/cutWay1.jpg";  
 roadGroup.images[2] = "images/cutWay2.jpg";  
 roadGroup.images[3] = "images/cutWay3.jpg";  
 roadGroup.images[4] = "images/cutWay4.jpg";  
  
 local function loadWay ()  
 for i=1,4 do  
 roadGroup.wayList[i] = display.newImageRect(roadGroup.images[i], \_W, 240);  
 roadGroup.wayList[i]:setReferencePoint(display.CenterReferencePoint);  
 roadGroup.wayList[i].x = \_W/2;  
 roadGroup.wayList[i].y = 360 - (240\*(i-1));  
 roadGroup:insert(roadGroup.wayList[i]);  
 end  
 end  
  
 loadWay();  
  

So the pieces are on screen like this;

http://img803.imageshack.us/img803/3269/ways.png

In game.lua, I use “EnterFrame” for main loop function and in this function I am calling a method of Road.lua which slides these pieces. Also it puts back a piece if its out of screen so it can loop infinitely.

  
 function roadGroup:loop(dt)  
 local constVal = (speed+minSpeed)\*0.0035\*dt;  
 print("constVal "..tostring(constVal));  
  
 roadGroup.wayList[1].y = roadGroup.wayList[1].y + constVal;  
 roadGroup.wayList[2].y = roadGroup.wayList[2].y + constVal ;  
 roadGroup.wayList[3].y = roadGroup.wayList[3].y + constVal;  
 roadGroup.wayList[4].y = roadGroup.wayList[4].y + constVal;  
  
 if (roadGroup.wayList[1].y \>= 600) then  
 roadGroup.wayList[1].y = roadGroup.wayList[1].y -960;  
  
 elseif (roadGroup.wayList[2].y \>= 600) then  
 roadGroup.wayList[2].y = roadGroup.wayList[2].y -960;  
  
 elseif (roadGroup.wayList[3].y \>= 600) then  
 roadGroup.wayList[3].y = roadGroup.wayList[3].y -960;  
  
 elseif (roadGroup.wayList[4].y \>= 600) then  
 roadGroup.wayList[4].y = roadGroup.wayList[4].y -960;  
 end  
 end  
  

And finally my problem is this code and approach doesn’t help me slide the way smoothly even I have 60 fps and using deltaTime which makes it time based. It shatters regularly, where am I doing wrong?

I have tried working it on 30fps, using with larger image pieces, using timer instead EnterFrame, set antialias = true and many more but can’t solve it, any ideas? Thanks in advance… [import]uid: 80068 topic_id: 18801 reply_id: 318801[/import]

You should use translate instead :

 function roadGroup:loop(dt)  
 local constVal = (speed+minSpeed)\*0.0035\*dt;  
 print("constVal "..tostring(constVal));  
  
 roadGroup.wayList[1]:translate(0, constVal)  
 roadGroup.wayList[2]:translate(0, constVal)  
 roadGroup.wayList[3]:translate(0, constVal)  
 roadGroup.wayList[4]:translate(0, constVal)  
   
 if (roadGroup.wayList[1].y \>= 600) then  
 roadGroup.wayList[1]:translate(0, -960)   
   
 elseif (roadGroup.wayList[2].y \>= 600) then  
 roadGroup.wayList[2]:translate(0, -960)   
   
 elseif (roadGroup.wayList[3].y \>= 600) then  
 roadGroup.wayList[3]:translate(0, -960)   
   
 elseif (roadGroup.wayList[4].y \>= 600) then  
 roadGroup.wayList[4]:translate(0, -960)   
 end  
 end  

That should help, can you describe more what you mean by “smoothly” ? Ie describe the issue better? [import]uid: 84637 topic_id: 18801 reply_id: 72524[/import]

I have tried using translate but it didn’t help too. Anyway let me describe the issue better and be sure you’ve checked that picture: http://img803.imageshack.us/img803/3269/ways.png

Once you run the code above you expect to have a sliding background which gives you a feeling that car runs on a way but regularly it makes a flutter even it runs at 60fps.

I thought that maybe it’s because of my code so I commented out everything, just road code was left and run project but it is still fluttering.

When I run the game on my iOS device (3gs) its a lot better than simulator but on android device (Nexus One) it’s a lot worse than simulator. [import]uid: 80068 topic_id: 18801 reply_id: 72650[/import]

When you say flutter you mean its kind of jerky?

If so try on the device, sometimes that happens on the simulator but not on device [import]uid: 84637 topic_id: 18801 reply_id: 72673[/import]

Yes jerky is the right word, I told that its worse on android but better on iPhone. Also I set antialias = true but it didn’t help too. [import]uid: 80068 topic_id: 18801 reply_id: 72674[/import]

Ok, first tip, use png’s they perform better on iDevices (im not sure if the same applies to android)

Second, how large are your images? Do you really need 4? would 2 not suffice ? [import]uid: 84637 topic_id: 18801 reply_id: 72677[/import]

I have tried all formats, png, low jpeg but it didn’t help. 320x240 is the size of one piece and yes I really need 4. I tried less pictures or more smaller pieces, they didn’t work. [import]uid: 80068 topic_id: 18801 reply_id: 72683[/import]