I don’t think I’m cutting the layer…?
I’m using composer (probably not very well) and here’s the file in which I’d like to reference the position of an object from Tiled to use as a positioning reference for the game character:
[lua]
local composer = require( “composer” )
local scene = composer.newScene()
local mydata = require( “mydata” )
local physics = require( “physics” )
physics.start( )
local gameStarted = false
display.setStatusBar(display.HiddenStatusBar)
local textureFilter = “nearest”
display.setDefault(“minTextureFilter”, textureFilter)
display.setDefault(“magTextureFilter”, textureFilter)
local topY = display.screenOriginY
local rightX = display.contentWidth - display.screenOriginX
local bottomY = display.contentHeight - display.screenOriginY
local leftX = display.screenOriginX
local dusk = require(“Dusk.Dusk”)
require(“Plugins.mapcutter”)
local map = dusk.buildMapFromLayers(“level.lua”, {3,3})
map.x = display.contentCenterX - (display.actualContentWidth/2)
map.width = display.actualContentWidth * 3
map.y = display.contentCenterY - (display.actualContentHeight/2)
map.height = 265
map:scale(1, 1)
map.updateView()
map.setTrackingLevel(0.3)
local sheetData = { width=40, height=40, numFrames=12, sheetContentWidth=480, sheetContentHeight=40 }
local mySheet = graphics.newImageSheet( “character.png”, sheetData )
local sequenceData = {
{ name=“characterrun”, start=1, count=12, time=1000, loopCount = 0 },
}
local character = display.newSprite( mySheet, sequenceData )
character.myName = “character”
character.x = -30;
character.y = 165
character.xScale= 3.5
character.yScale= 3.5
character:setSequence( “characterrun” )
character:play()
transition.to( character, { time=6000, alpha=1, x = 500 })
return scene
[/lua]
In line 49 I’d like to replace ‘x = 500’ with ‘x = x position of object made in Tiled’
What would you type there to reference that?
I realise I’m not identifying a layer as per your previous post - I couldn’t get that to work. I kept getting nil value errors however I tried… perhaps you could give an example?
The layer in Tiled with the objects is called ‘markers’ and the object within that layer I’d like to reference is called ‘startmarker’.
Thanks for your help, it’s really appreciated - I’m not a programmer so it’s not obvious to me how to implement this but I’m sure once I’ve got this I’ll be able to apply it elsewhere in the project…
Many thanks