Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

wrong contentBounds ?
Started by pahuchiy Jan 29 2020 11:30 AM

2 replies to this topic

Best Answer pahuchiy , 29 January 2020 - 07:45 PM

I realized. Because the borders are always rectangular

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

pahuchiy

[GLOBAL: userInfoPane.html]
pahuchiy
  • Observer

  • 28 posts
  • Corona SDK

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


c1 = display.newCircle( 100,100,50 )
physics.addBody( c1,{radius=50, friction=1})


r1 = display.newRect(200,300,500,20)
r1.rotation = 10
physics.addBody( r1, "static")

r2 = display.newRect(700,300,500,20)
r2.rotation = -10
physics.addBody( r2, "static")

timer.performWithDelay( 1, function()
  display.remove(visvis)
  visvis = display.newLine(0, c1.contentBounds.yMin, 1000, c1.contentBounds.yMin )
end, 0 )

Why does the line bounce off the circle?



[TOPIC: post.html]
#2

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 403 posts
  • Corona SDK

Hi @pahuchiy,

 

I'm not sure why but using c1.y - c1.path.radius instead of c1.contentBounds.yMin give me better results.

 

Try

local visvis = display.newLine(0, c1.contentBounds.yMin, 1000, c1.contentBounds.yMin )
timer.performWithDelay( 20, function() visvis.y = c1.y - c1.path.radius end, 0 )

I created only one line object. 

 

Have a nice day:)

ldurniat 



[TOPIC: post.html]
#3

pahuchiy

[GLOBAL: userInfoPane.html]
pahuchiy
  • Observer

  • 28 posts
  • Corona SDK

  Best Answer

I realized. Because the borders are always rectangular




[topic_controls]
[/topic_controls]