Hey,
I have some code which would take a number of images and place them into a display group one underneath the other, essentially creating a parallax scrolling background which I could then scroll around in the game. The existing V1 code made a use of x/yReferences and setReferencePoint to effectively position the images inside the group. Since migrating to G2.0 I can’t seem to get the images to be placed below one another. I have tried using “anchorChildren=true” when declaring the group as well - all I am getting is one image being placed over the other, no matter how many images that I have.
The existing G1.0 code is as follows:
[lua]
–level class constructor
return function(parent)
local self = display.newGroup()
self.anchorChildren = true
parent:insert(self)
for index, image in images(“levelFiles/grassland.%d.png”) do
self:insert(image)
image:setReferencePoint(display.BottomCenterReferencePoint)
image.x, image.y = self.xReference, self.yReference
self:setReferencePoint(display.TopCenterReferencePoint)
end
self:setReferencePoint(display.BottomCenterReferencePoint)
return self
end
[/lua]
The G2.0 attempt:
[lua]
return function(parent)
local self = display.newGroup()
self.anchorChildren = true
parent:insert(self)
for index, image in images(“levelFiles/grassland.%d.png”) do
self:insert(image)
image.anchorX, image.anchorY = 0.5, 1
--image.x, image.y = self.xReference, self.yReference
– 1. have tried replacing above references with the height/width of image - no luck
– 2. can’t use anchors here as I need a pixel value - no luck
self.anchorX, self.anchorY = 0.5, 0
end
self.anchorX, self.anchorY = 0.5, 1
return self
end
[/lua]
Any help would be much appreciated.
Cheers,
Rich