Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Collision with a polyline object with a physics object
Started by IndieEnthusiast Nov 02 2018 04:34 AM

1 reply to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

IndieEnthusiast

[GLOBAL: userInfoPane.html]
IndieEnthusiast
  • Contributor

  • 147 posts
  • Corona SDK

Hi,

 

I added a polyline object, an outline of a mountain. I added the following properties to the object layer :

https://drive.google.com/file/d/1cOGE8YByIrT1Hj0OXbD1VpzzSlKL9ZHd/view

 

The full main.lua file is :

 

-- Hide status bar
display.setStatusBar(display.HiddenStatusBar)

-- Use berry to load .json map
local berry = require( 'berry.berry' )
local map   = berry.new( 'Maps/Level-1.json', 'background')

-- Adjusting map width, height and position so that it looks perfect
map.width = display.actualContentWidth + 50
map.height = display.actualContentHeight - 200
map.x = -85 ; map.y = 0

------------------------------------------------------------------------
-- Designing the strength bar
------------------------------------------------------------------------
local bar = display.newImageRect( "Assets/bar/bar.png", 400, 100 )
bar.x = 200 ; bar.y = 700

local scroller = display.newImageRect( "Assets/button/scroller2.png", 100, 100 )
scroller.x = 400 ; scroller.y = 720
scroller.rotation = 90

-- Followed tutorial in https://www.youtube.com/watch?v=cyRqIkIgCq0

local function doScrollTouch(event)

  local touchedObject = event.target

  if (event.phase=="began") then
    touchedObject.previousX = touchedObject.x

  elseif (event.phase == "moved") then
    touchedObject.x = (event.x - event.xStart) + touchedObject.previousX

  end

end
scroller:addEventListener("touch", doScrollTouch)

--------------------------------------------------------------------------------------
local physics = require( "physics" )
-- Start the physics engine
physics.start()


local myCircle = display.newCircle( 100, 100, 30 )
myCircle:setFillColor( 0.5 )

physics.addBody( myCircle, { density=0.1, friction=0.1, bounce=0.4 } )

 
The issue I am facing is the circle just goes through the line and does not bounce off.
 
Some more information :
- Tile map editor 1.2
- Berry map engine
 
Can anyone help me please? 
 
 
 
 
 
 
 
 

 



[TOPIC: post.html]
#2

IndieEnthusiast

[GLOBAL: userInfoPane.html]
IndieEnthusiast
  • Contributor

  • 147 posts
  • Corona SDK

@Idurniat any idea with this?




[topic_controls]
[/topic_controls]