Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tiled issue: No physics using Berry or PonyTiled
Started by koutzen Aug 08 2019 10:55 AM

No replies to this topic
tiled berry ponytiled
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

koutzen

[GLOBAL: userInfoPane.html]
koutzen
  • Observer

  • 2 posts
  • Corona SDK

I'm doing my first tiled based map using Tiled and I've played around with both Berry and PonyTiled and managed to get both to load the map. However none of them are applying physics to any of my tiles.
 
I'll write what I'm doing for both Berry and PonyTiled here: 
 
In Tiled v. 1.2.4: 
  • Create a new map using CSV as the Tile Layer Format. 
  • Open a new tile set 'based on tileset image'.
  • Check the 'embed in map' option. 
  • In Tile Collision Editor I outline the collision box 
  • I add the following custom properties to both the tile itself and the collision box: hasBody = true (used for Berry), bodyType = static, bounce = 0.3, friction = 1. 
  • I export the map as .json for Berry and .lua for PonyTiled.   
  • I put the exported map along with my spritesheet in the root folder of my project. 
 
In Corona, for Berry: 
local physics = require( 'physics' )
berry = require( 'pl.ldurniat.berry' )
local json = require( "json" )

local sceneGroup = self.view

physics.start()
physics.setDrawMode("hybrid")

local map = berry.loadMap( 'testmap_embed.json' )
local visual = berry.createVisual( map )
berry.buildPhysical( map )
	
Ball = display.newCircle( display.contentCenterX, 40, 20)
Ball:setFillColor( 0.25, 0.5, 0.25  )

physics.addBody(Ball, 'dynamic', { friction = 0.5, bounce = 0.2, radius = 20 } )

visual:insert( Ball )
sceneGroup:insert( visual )
In Corona for PonyTiled
local physics = require( 'physics' )
local tiled = require( "com.ponywolf.ponytiled" )
	
local sceneGroup = self.view

physics.start()
physics.setDrawMode("hybrid")
	
local mapData = require "testmap" 
local map = tiled.new(mapData) 
	
Ball = display.newCircle( display.contentCenterX, 40, 20)
Ball:setFillColor( 0.25, 0.5, 0.25  )

physics.addBody(Ball, 'dynamic', { friction = 0.5, bounce = 0.2, radius = 20 } )
Doing this I manage to get the map displayed for both Berry and PonyTiled but none of them apply physics to the tiles with the custom properties.
 
Another issue is that it displays these weird red lines as you can see in the attached screenshot. 
 
Any help is greatly appreciated.

Attached Files




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: tiled, berry, ponytiled