How ?

I have a question for my app. When I launch it my ball bounces right off of the screen . How do I make it so that this doesn’t happen . BTW i’m using the galaxy S 5 format .

You need to put some invisible walls around the edge of the screen.  Some display.newRects() a few pixels wide, say 10 or so will do the trick, just put them just off screen.  Make the static physics bodies and that should take care of it.

Rob

What is the exact code I don’t know what to put

Try our Getting Started docs.  Here is a good place to start.

Easy as Corona SDK is, it’ll take a little while to learn how it all works.

I ask for code and you give me this I don’t know where to look at what the code is . BRUH!

What is the exact code

What is the exact code

There is no exact code.  The code depends on how your game works.  

We aren’t here to do your homework for you.  If you want to build games with Corona SDK, you’ll have to learn how to use it.  Learning how to be polite when asking for help wouldn’t hurt either.

Actually answering the question wouldn’t hurt either instead of pointing me somewhere and not telling me where to find the info I’m looking for .

Also there is a specific line of code to display invisible walls . you cant just say :

–display hamburger
Local dang = ( “onions” )

And then poof invisible walls

There is no specific line of code to create an invisible wall.

In multiple lines you can:

  • Make a rectangle,
  • add a static body to the rectangle,
  • move it to the edge of the screen,
  • set the visible flag
  • done… repeat three more times with slightly different code.

Here is some code (33 lines and not exact since the walls are just ‘on-screen’ so you can see them.

local w = display.contentWidth local h = display.contentHeight local centerX = display.contentCenterX local centerY = display.contentCenterY local fullw = display.actualContentWidth local fullh = display.actualContentHeight local unusedWidth = fullw - w local unusedHeight = fullh - h local left = 0 - unusedWidth/2 local top = 0 - unusedHeight/2 local right = w + unusedWidth/2 local bottom = h + unusedHeight/2 require "physics" physics.start() --physics.setDrawMode( "hybrid" ) local leftWall = display.newRect( left + 10, centerY, 20, fullh ) leftWall:setFillColor(1,0,0) physics.addBody( leftWall, "static" ) local rightWall = display.newRect( right - 10, centerY, 20, fullh ) rightWall:setFillColor(0,1,0) physics.addBody( rightWall, "static" ) local topWall = display.newRect( centerX, top+10, fullw, 20 ) topWall:setFillColor(0,0,1) physics.addBody( topWall, "static" ) local bottomWall = display.newRect( centerX, bottom-10, fullw, 20 ) bottomWall:setFillColor(1,1,0) physics.addBody( bottomWall, "static" )

As you can see, this is not a quick thing to answer, and I guarantee you’ll need to make even more changes to this code to make it work for you.  Having no context into your situation, it is hard to give a complete answer.

Note: I suggest folks ask questions with this thought in mind, “Spend more time asking your question than the person helping you will spend answering the question and you are doing the right thing.” 

I just spent 30 minutes answering this question which at the rate I charge means I spent ~$38 of my time answering.  I’m not asking for money here, I just want you to realize for many of us, time is really money.

We (staff like Perry & Rob as well as community members like myself) really want to help and want you to be successful here.  The thing is, general questions are hard to answer with an exact answer.  

Often it is better for us to point you in a direction where you can examine samples and docs.

Like the old saying says, “Give a man a fish and he eats for a day.  Teach a man to fish and he eats for a lifetime.”

Finally, one of the best sources for sample code (besides the ones already presented) is the API docs page: 

https://docs.coronalabs.com/daily/api/

You need to put some invisible walls around the edge of the screen.  Some display.newRects() a few pixels wide, say 10 or so will do the trick, just put them just off screen.  Make the static physics bodies and that should take care of it.

Rob

What is the exact code I don’t know what to put

Try our Getting Started docs.  Here is a good place to start.

Easy as Corona SDK is, it’ll take a little while to learn how it all works.

I ask for code and you give me this I don’t know where to look at what the code is . BRUH!

What is the exact code

What is the exact code

There is no exact code.  The code depends on how your game works.  

We aren’t here to do your homework for you.  If you want to build games with Corona SDK, you’ll have to learn how to use it.  Learning how to be polite when asking for help wouldn’t hurt either.

Actually answering the question wouldn’t hurt either instead of pointing me somewhere and not telling me where to find the info I’m looking for .

Also there is a specific line of code to display invisible walls . you cant just say :

–display hamburger
Local dang = ( “onions” )

And then poof invisible walls