issue with image placement

using this code

first run in loop

  the first print statement   –    1                0

  second print statement   –     img 1        0

second time thru loop

  the first print statement   –    2                480

  second print statement   –    img 2         480

loop ends

  the last print statement   –    480            480

cant figure out how the images y value get set to 0 & 480

but then after setting them they both get changed to 480

   local function arrangeImgUsing()       if firstRun == true then          for a = 1, 2 do             if self.dir == "up" then                self.imgUsing[a].anchorX = 0.5                self.imgUsing[a].anchorY = 1                self.imgUsing[a].x = display.contentCenterX                   -- make sure math correct                   print( a,((a-1)\*self.imgUsing[a].height))                self.imgUsing[a].y = ((a-1)\*(self.imgUsing[a].height))                  -- make sure y correct                  print("img "..a,self.imgUsing[a].y)             end          end          firstRun = false       end    end    -- double ck y    print(self.imgUsing[1].y, self.imgUsing[2].y)  

self.imgUsing[1] == self.imgUsing[2] ? Too obvious? :slight_smile:

edit:

Nothing to do with the problem but I imagine you are trying to set one under the other so maybe this will be better when the heights are not the same:

self.imgUsing[a].y = ((a-1)*(self.imgUsing[a - 1] and (self.imgUsing[a - 1].y + self.imgUsing[a - 1].height) or 0))

self.imgUsing[1] == self.imgUsing[2] ? Too obvious? :slight_smile:

edit:

Nothing to do with the problem but I imagine you are trying to set one under the other so maybe this will be better when the heights are not the same:

self.imgUsing[a].y = ((a-1)*(self.imgUsing[a - 1] and (self.imgUsing[a - 1].y + self.imgUsing[a - 1].height) or 0))