Hi Guys,
I’ve been playing with Tiled, Lime and PhysicsEditor and come across a rather annoying little error that I can’t seem to workaround.
I created a basic platformer-style level in Tiled and then used PhysicsEditor to construct the physics-related data (as per the tutorial/example).
This is what I’m seeing in hybrid drawing mode:
The code I’m using is as follows:
[lua]function scene:createScene( event )
local group = self.view
local map = lime.loadMap(“levelone.tmx”)
local visual = lime.createVisual(map)
group:insert(visual)
local physicsData = {}
local file = io.open( system.pathForFile(“levelone.json”, system.ResourceDirectory) )
if file then
local input = file:read( “*a” )
physicsData = json.decode(input)
io.close( file )
end
physics.addBody(map.world, “static”, unpack(physicsData[“levelone”]))
map.world.id = “map”
local sprite = display.newImage(“sprite.png”)
sprite.x = 50
sprite.y = 80
sprite.id = “sprite”
physics.addBody(sprite, “dynamic”, unpack(physicsData[“sprite”]))
group:insert(sprite)
end[/lua]
The static/platform image and physics is fine. It’s just the ‘sprite’ that causes issues.
What’s odd, is that if I replace the physics data with the direct values minus the ‘shape’ parameters from PhysicsEditor (on line 23), the reference point and alignment are correct.
Physics Data:
[text]
{
“levelone”: [
{
“density”: 2, “friction”: 0, “bounce”: 0,
“filter”: { “categoryBits”: 1, “maskBits”: 65535 },
“shape”: [0, 257 , 2, 256 , 217, 256 , 224, 261 , 224, 320 , 0, 320]
}
]
,
“sprite”: [
{
“density”: 2, “friction”: 0, “bounce”: 0,
“filter”: { “categoryBits”: 1, “maskBits”: 65535 },
“shape”: [0, 40 , 0, 0 , 25, 0 , 25, 40]
}
]
}
[/text]
Does anybody have the simple answer that’s been eluding me? Guessing it’s related to handling the setReferencePoint or similar, but I’ve had no success so far.
[Edit] Moved to TexturePacker forum, in case those familiar with PhysicsEditor and Corona can offer some guidance in what I’m doing wrong. [import]uid: 122384 topic_id: 24769 reply_id: 324769[/import]