Looking For Editor Or Script To Place & Rotate Sprites On Screen, Then Export Data?

I have a bunch of same-sized rectangles which I want to manually place in many positions on the screen, and also rotate them, and then export those x,y coordinates and rotation angles to some data array or such. Is there such a thing?

 

(For what it’s worth, I can get very far by using CorelDraw, exporting the SVG, and then converting the matrix transformation to radians, BUT… there seems to be an issue where using the needed topLeftAlign() will only apply to the visual, but not its physics body.)

 

Thanks!

Not sure if this is what your looking for, but have you checked out Corona SVG Level Builder?  Or are you looking to go in the opposite direction, because you can simply loop through all your objects and output their coordinates to a file, or just send out the entire table as a JSON file.

Thanks, that’s $99 without trial so I’m not sure it is what I need. I’ll also look into the mentioned Inkscape to see if their SVG export has more options (I need center point rotations to not run into other issues).

 

Idit seems to be what I need, but I can’t find a main.lua file to start it – does anyone know more on how to use it?

I now got it working with CorelDraw. Steps in case anyone lands here looking for this:
 

  1. Use CorelDraw to draw rectangles, Set the document properties to your respective Corona project configuration.
  2. Export as SVG. Save the file somewhere in a data folder in your project.
  3. Read in the text file data, split towards the matrix parts.
  4. Convert the matrix to a degrees rotation.
  5. Create respective sprites.
     
    Below is some code from my project (not standalone, but it shows the idea):

 

function self:createMap() local mapNames = { 'Tree', 'Vertigo', 'Chambers', 'Bouncer', 'Road to Portal', 'Tilt Quest', 'Birds' } local mapName = nil; mapNumber = nil local foundGoodMap = false local offsetX = 72; offsetY = 50 foundGoodMap = false while not foundGoodMap do mapName, mapNumber = misc.getRandomEntryAndIndex(mapNames) foundGoodMap = mapName ~= app.lastMapName end app.lastMapName = mapName local bars, bumpers, portals = appGetElementsFromSvg(mapNumber, mapName) for i = 1, #bars do local values = bars[i] local x = values[5]; local y = values[6] local rotation = 360 - ( math.floor( math.deg( math.atan2(values[3], values[4]) ) ) % 360 ) x = x + offsetX; y = y + offsetY app.spritesHandler:createBar( math.floor(x), math.floor(y), rotation ) end for i = 1, #bumpers do app.spritesHandler:createBouncer(bumpers[i].x, bumpers[i].y) end for i = 1, #portals do app.spritesHandler:createPortal(portals[i].x, portals[i].y) end end function appGetElementsFromSvg(mapNumber, mapName) local bars = {}; local bumpers = {}; local portals = {} local mapFileName = string.lower(mapName) mapFileName = string.gsub(mapFileName, ' ', '-') mapFileName = mapNumber .. '-' .. mapFileName .. '.svg' local svg = misc.getFileText('data/' .. mapFileName, system.ResourceDirectory) local lines = misc.split(svg, '\n') local function getPositionFromSVGCircle(dataLine) local x = nil; local y = nil for thisX in string.gmatch( dataLine, ' cx=%"(.-)%"' ) do x = tonumber(thisX) end for thisY in string.gmatch( dataLine, ' cy=%"(.-)%"' ) do y = tonumber(thisY) end return {x = x, y = y} end local indicators = { bar = ' \<rect class="fil', bumper = ' r="33"', portal = ' r="34"' } for i = 1, #lines do local line = lines[i] if string.find(line, indicators.bar, 0, true) ~= nil then for matrix in string.gmatch( line, '%((.-)%)' ) do bars[#bars + 1] = misc.split(matrix, ' ') for valueI = 1, #bars[#bars] do bars[#bars][valueI] = tonumber( bars[#bars][valueI] ) end end elseif string.find(line, indicators.bumper, 0, true) ~= nil then bumpers[#bumpers + 1] = getPositionFromSVGCircle(line) elseif string.find(line, indicators.portal, 0, true) ~= nil then portals[#portals + 1] = getPositionFromSVGCircle(line) end end return bars, bumpers, portals end function self:createBar(x, y, rotation) local function handle(self) if self.y + (self.height / 2 + 1) \<= app.minY then self.gone = true app.spritesHandler:createWaveEffect(self.x, self.y, true) appRestart() end if math.random(0, 10000) \<= 1 then app.spritesHandler:createBling(self.x, self.y, 25) end end local subtype = math.random(1, app.maxBarSubtypes) local width = 126; local height = 19 local self = spriteModule.spriteClass('rectangle', 'bar', subtype, 'bar/' .. subtype, true, x, y, width, height) self.bodyType = 'kinematic' self.doDieOutsideField = false self.alphaChangesWithEnergy = true self.speedY = app.elementsSpeedY self.isFixedRotation = true appAddSprite(self, handle, moduleGroup) self:setReferencePoint(display.TopLeftReferencePoint) self.rotation = rotation local rectContentX, rectContentY = self:localToContent(0, 0) self.rotation = 0 self:setReferencePoint(display.CenterReferencePoint) self.x, self.y = rectContentX, rectContentY self.rotation = rotation return self end

Not sure if this is what your looking for, but have you checked out Corona SVG Level Builder?  Or are you looking to go in the opposite direction, because you can simply loop through all your objects and output their coordinates to a file, or just send out the entire table as a JSON file.

Thanks, that’s $99 without trial so I’m not sure it is what I need. I’ll also look into the mentioned Inkscape to see if their SVG export has more options (I need center point rotations to not run into other issues).

 

Idit seems to be what I need, but I can’t find a main.lua file to start it – does anyone know more on how to use it?

I now got it working with CorelDraw. Steps in case anyone lands here looking for this:
 

  1. Use CorelDraw to draw rectangles, Set the document properties to your respective Corona project configuration.
  2. Export as SVG. Save the file somewhere in a data folder in your project.
  3. Read in the text file data, split towards the matrix parts.
  4. Convert the matrix to a degrees rotation.
  5. Create respective sprites.
     
    Below is some code from my project (not standalone, but it shows the idea):

 

function self:createMap() local mapNames = { 'Tree', 'Vertigo', 'Chambers', 'Bouncer', 'Road to Portal', 'Tilt Quest', 'Birds' } local mapName = nil; mapNumber = nil local foundGoodMap = false local offsetX = 72; offsetY = 50 foundGoodMap = false while not foundGoodMap do mapName, mapNumber = misc.getRandomEntryAndIndex(mapNames) foundGoodMap = mapName ~= app.lastMapName end app.lastMapName = mapName local bars, bumpers, portals = appGetElementsFromSvg(mapNumber, mapName) for i = 1, #bars do local values = bars[i] local x = values[5]; local y = values[6] local rotation = 360 - ( math.floor( math.deg( math.atan2(values[3], values[4]) ) ) % 360 ) x = x + offsetX; y = y + offsetY app.spritesHandler:createBar( math.floor(x), math.floor(y), rotation ) end for i = 1, #bumpers do app.spritesHandler:createBouncer(bumpers[i].x, bumpers[i].y) end for i = 1, #portals do app.spritesHandler:createPortal(portals[i].x, portals[i].y) end end function appGetElementsFromSvg(mapNumber, mapName) local bars = {}; local bumpers = {}; local portals = {} local mapFileName = string.lower(mapName) mapFileName = string.gsub(mapFileName, ' ', '-') mapFileName = mapNumber .. '-' .. mapFileName .. '.svg' local svg = misc.getFileText('data/' .. mapFileName, system.ResourceDirectory) local lines = misc.split(svg, '\n') local function getPositionFromSVGCircle(dataLine) local x = nil; local y = nil for thisX in string.gmatch( dataLine, ' cx=%"(.-)%"' ) do x = tonumber(thisX) end for thisY in string.gmatch( dataLine, ' cy=%"(.-)%"' ) do y = tonumber(thisY) end return {x = x, y = y} end local indicators = { bar = ' \<rect class="fil', bumper = ' r="33"', portal = ' r="34"' } for i = 1, #lines do local line = lines[i] if string.find(line, indicators.bar, 0, true) ~= nil then for matrix in string.gmatch( line, '%((.-)%)' ) do bars[#bars + 1] = misc.split(matrix, ' ') for valueI = 1, #bars[#bars] do bars[#bars][valueI] = tonumber( bars[#bars][valueI] ) end end elseif string.find(line, indicators.bumper, 0, true) ~= nil then bumpers[#bumpers + 1] = getPositionFromSVGCircle(line) elseif string.find(line, indicators.portal, 0, true) ~= nil then portals[#portals + 1] = getPositionFromSVGCircle(line) end end return bars, bumpers, portals end function self:createBar(x, y, rotation) local function handle(self) if self.y + (self.height / 2 + 1) \<= app.minY then self.gone = true app.spritesHandler:createWaveEffect(self.x, self.y, true) appRestart() end if math.random(0, 10000) \<= 1 then app.spritesHandler:createBling(self.x, self.y, 25) end end local subtype = math.random(1, app.maxBarSubtypes) local width = 126; local height = 19 local self = spriteModule.spriteClass('rectangle', 'bar', subtype, 'bar/' .. subtype, true, x, y, width, height) self.bodyType = 'kinematic' self.doDieOutsideField = false self.alphaChangesWithEnergy = true self.speedY = app.elementsSpeedY self.isFixedRotation = true appAddSprite(self, handle, moduleGroup) self:setReferencePoint(display.TopLeftReferencePoint) self.rotation = rotation local rectContentX, rectContentY = self:localToContent(0, 0) self.rotation = 0 self:setReferencePoint(display.CenterReferencePoint) self.x, self.y = rectContentX, rectContentY self.rotation = rotation return self end