Too late, I used a super-hack based on knowledge of bin sizes and some basic rules.
This is what I came up with (using SSK2of course):
-- ============================================================= -- Copyright Roaming Gamer, LLC. 2008-2017 (All Rights Reserved) -- ============================================================= -- main.lua -- ============================================================= -- ============================================================= io.output():setvbuf("no") display.setStatusBar(display.HiddenStatusBar) -- ============================================================= require "ssk2.loadSSK" \_G.ssk.init() -- ============================================================= -- Localizations -- ============================================================= -- Lua local mRand = math.random -- -- Common SSK Display Object Builders local newCircle = ssk.display.newCircle;local newRect = ssk.display.newRect local newImageRect = ssk.display.newImageRect;local newSprite = ssk.display.newSprite local quickLayers = ssk.display.quickLayers -- ============================================================= -- Find local stories -- ============================================================= local sizes = {} sizes[1] = { w = 425, h = 625 } sizes[2] = { w = 210, h = 310 } local blocks = { { type = mRand(1,2) }, { type = mRand(1,2) }, { type = mRand(1,2) }, { type = mRand(1,2) }, { type = mRand(1,2) }, { type = mRand(1,2) }, { type = mRand(1,2) }, { type = mRand(1,2) }, { type = mRand(1,2) }, { type = mRand(1,2) }, { type = mRand(1,2) }, } local function algo() local curX = 0 local curY = 0 local col = 0 local row = 0 local lastType local bin = display.newGroup() bin.x = left bin.y = top for i = 1, #blocks do local fill = { mRand(), mRand(), mRand() } fill[mRand(1,3)] = 1 if( col == 0 ) then local bType = blocks[i].type local size = table.shallowCopy(sizes[bType]) local obj = newRect( bin, 0, 0, { w = size.w, h = size.h, fill = fill } ) obj.myType = bType obj.x = curX + obj.contentWidth/2 obj.y = curY + obj.contentHeight/2 col = col + 1 curX = obj.x + obj.contentWidth/2 + 5 if( bType == 1 ) then curY = curY else curY = obj.y end elseif( col == 1 ) then local last = bin[bin.numChildren] local bType = 2 local size = table.shallowCopy(sizes[bType]) if( last.myType == 1 ) then local obj = newRect( bin, 0, 0, { w = size.w, h = size.h, fill = fill } ) obj.myType = bType obj.x = curX + size.w/2 obj.y = curY + size.h/2 curY = obj.y + 5 + size.h row = 1 elseif( row == 0 ) then local obj = newRect( bin, 0, 0, { w = size.w, h = size.h, fill = fill } ) obj.myType = bType obj.x = curX + size.w/2 obj.y = curY curY = obj.y curX = obj.x + 5 + size.w/2 col = 2 row = 0 else local obj = newRect( bin, 0, 0, { w = size.w, h = size.h, fill = fill } ) obj.myType = bType obj.x = curX + size.w/2 obj.y = curY curY = obj.y + size.h/2 + 5 curX = 0 col = 0 row = 0 end elseif( col == 2 ) then local bType = 2 local size = table.shallowCopy(sizes[bType]) local obj = newRect( bin, 0, 0, { w = size.w, h = size.h, fill = fill } ) obj.myType = bType obj.x = curX + size.w/2 obj.y = curY curX = 0 curY = obj.y + 5 + size.h/2 col = 0 row = 0 end lastType = blocks[i].type end end algo()