Screen Limits

I have this code to the walls , or the full screenshot limits for my application but does not work , someone can help me figure out the error ??

-- Limites do ecrã local borderTop = display.newRect( 0, 0, 707, 1 ) borderTop:setFillColor( 0, 0, 0, 0) -- Invisivel physics.addBody( borderTop, "static", borderBodyElement ) sceneGroup:insert(borderTop) local borderBottom = display.newRect( 0, 1000, 707, 1 ) borderBottom:setFillColor( 0, 0, 0, 0) -- Invisivel physics.addBody( borderBottom, "static", borderBodyElement ) sceneGroup:insert(borderBottom) local borderLeft = display.newRect( 0, 1, 1, 1000 ) borderLeft:setFillColor( 0, 0, 0, 0) -- Invisivel physics.addBody( borderLeft, "static", borderBodyElement ) sceneGroup:insert(borderLeft) local borderRight = display.newRect( 707, 1, 1, 1000 ) borderRight:setFillColor( 0, 0, 0, 0) -- Invisivel physics.addBody( borderRight, "static", borderBodyElement ) sceneGroup:insert(borderRight)

To get the limit of your screen you have to do that

xminscreen=display.contentCenterX-0.5\*display.actualContentWidth yminscreen=display.contentCenterY-0.5\*display.actualContentHeight xmaxscreen=0.5\*display.actualContentWidth+display.contentCenterX ymaxscreen=display.actualContentHeight+(yminscreen)

Because all screen are not of the same size and 0 don’t always mean a border because of config.lua file.

Thanks, but I apply this code and then to create the limits newRect , this code will work where?

I would make your rectangles at least 10 px wide, if not larger. Physics doesn’t work well with 1px objects. It’s not thick enough to stop fast moving items.

Rob

Still does not work , the code has a specific affixing the code sheet ? For example , at the beginning , the end or before we want to cover with limits ?

:frowning:

To get the limit of your screen you have to do that

xminscreen=display.contentCenterX-0.5\*display.actualContentWidth yminscreen=display.contentCenterY-0.5\*display.actualContentHeight xmaxscreen=0.5\*display.actualContentWidth+display.contentCenterX ymaxscreen=display.actualContentHeight+(yminscreen)

Because all screen are not of the same size and 0 don’t always mean a border because of config.lua file.

Thanks, but I apply this code and then to create the limits newRect , this code will work where?

I would make your rectangles at least 10 px wide, if not larger. Physics doesn’t work well with 1px objects. It’s not thick enough to stop fast moving items.

Rob

Still does not work , the code has a specific affixing the code sheet ? For example , at the beginning , the end or before we want to cover with limits ?

:frowning: