I have 3 tiled background images sized at 480 x 320 each. Initially the middle image (#1) is loaded into a group.
When the group starts sliding offstage to the right, #0 is added to the group and displayed seamlessly to the left of #1. Conversely, sliding offstage to the left, #2 is added to the group and displayed seamlessly to the right of #1. This part appears to work fine.
Problem starts when you keep going in the same direction. I cannot figure out how to automatically display #0 when #2 start falling off, and #2 when #0 is falling off.
| 0 | 1 | 2 |
Any help would be greatly appreciated.
Here’s what I have so far…
[code]
local grp3 = display.newGroup()
local grp3Img1 = display.newImageRect( grp3, “grp3Img1.png”, 480, 320 )
grp3Img1:setReferencePoint(display.TopLeftReferencePoint);
grp3Img1.x = 0 ; grp3Img1.y = 0
local function wrapping (event)
if grp3.x > 0 then
local grp3Img0 = display.newImageRect(“grp3Img0.png”, 480, 320 )
grp3:insert(grp3Img0)
grp3Img0:setReferencePoint(display.TopLeftReferencePoint);
grp3Img0.x = -480 ; grp3Img0.y = 0
end
if grp3.x < 0 then
local grp3Img2 = display.newImageRect(“grp3Img2.png”, 480, 320 )
grp3:insert(grp3Img2)
grp3Img2:setReferencePoint(display.TopLeftReferencePoint);
grp3Img2.x = 480 ; grp3Img2.y = 0
end
end
Runtime:addEventListener(“enterFrame”, wrapping)
[/code] [import]uid: 12397 topic_id: 7342 reply_id: 307342[/import]