move background image according accelerometer

hi
i want move background image infinite time depends on “accelerometer”…please help me

right now, background image moveing infinite time on “Runtime”
code here…
[lua]local bg1 = display.newImage(“background02.jpg”)
bg1:setReferencePoint(display.CenterLeftReferencePoint)
bg1.x = 0
bg1.y = 400
localGroup:insert(bg1)
local bg2 = display.newImage(“background02.jpg”)
bg2:setReferencePoint(display.CenterLeftReferencePoint)
bg2.x = 1020
bg2.y = 400
localGroup:insert(bg2)
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time
local yOffset = ( 0.15 * tDelta )

bg1.x = bg1.x + yOffset
bg2.x = bg2.x + yOffset

if bg1.x > 1020 then
bg1:translate( bg1.x, 0)
end
if bg2.x > 1020 then
bg2:translate( bg1.x, 0)
end
end
Runtime:addEventListener( “enterFrame”, move )[/lua] [import]uid: 87661 topic_id: 25869 reply_id: 325869[/import]

You should read up on using the accelerometer and moving objects with it - Techority has an example of this and so does the Tilt Monster sample code.

Learn to move an object from that code then apply it to your background image :slight_smile: [import]uid: 52491 topic_id: 25869 reply_id: 104621[/import]

thanks to replay peach. i know, how to do “accelerometer” but i want scroll background image on x-axis as well as background image should take x-position from accelerometer, here i am stacking…

both (scroll background image and accelerometer), i can do separately but i want “scroll background image with accelerometer”…please help me

[import]uid: 87661 topic_id: 25869 reply_id: 104635[/import]

Oh with accelerometer - so the tilt changes the speed?

If so you’d change the 0.15 in;
[lua]local yOffset = ( 0.15 * tDelta )[/lua]
To be affected by the tilt. [import]uid: 52491 topic_id: 25869 reply_id: 104812[/import]