how do you keep objects from going off screen?

first off i tried to use the example of the brick breaker game paddle but for some reason the whole thing is mest up the paddle goes off screen when you drag all the way across and and ball wont fly up (bounce around)

i was trying to make a game kinda of like that but way more different instead you would catch the ball when it comes down problem is the ball bounces off obsticles and goes off screen

thats one of the problems

the other one is that the paddle goes off screen [import]uid: 47760 topic_id: 11152 reply_id: 311152[/import]

You can wrap the screen (there’s a tutorial for that on http://Techority.com/) or use the same method to keep objects in bounds. (Wrapping is obviously a bit different but just change 2 numbers and you’re good to go.)

OR you could use static walls just outside the edges; like the buffers in Simple Pool but just outside view.

Peach :slight_smile: [import]uid: 52491 topic_id: 11152 reply_id: 40504[/import]

wow i can’t believe i didn’t think about the pool game … the pool example might work cause i want the walls on screen …thanks for the help peach

[import]uid: 47760 topic_id: 11152 reply_id: 40614[/import]

Create a runtime event listener, and inside that function, check the coordinates of the paddle and modify if they’re offscreen. [import]uid: 58455 topic_id: 11152 reply_id: 40735[/import]

ok runtime event listener

so would i write something like

if
paddle.x = 25
then
paddle.x = 25

just an example (if the paddle was all the way to the left)

something like that or am i totally off?

cause i think the coordinates of the paddle would be based off the center of the paddle it wouldn’t be 0 all the way to the left or 320 all the way to the right (for the coordinates if the paddle was to the right or left of the screen)

correct me if im wrong
[import]uid: 47760 topic_id: 11152 reply_id: 40781[/import]

Heya,

http://techority.com/2010/12/08/how-to-wrap-your-iphone-apps-screen/

That tutorial covers EXACTLY what you want to know :slight_smile:

Also, it would be if x < 25 then x = 25, not if x =25 then x = 25 :wink:

Peach [import]uid: 52491 topic_id: 11152 reply_id: 40788[/import]

Also, keep in mind that if the object has a velocity that isn’t controlled by user input (like the Fishies example), you also have to modify the velocity of the object if you want it to stop or reverse. [import]uid: 58455 topic_id: 11152 reply_id: 40807[/import]

hey peach its working now that paddle works except i think davemikesell might be right about the velocity thing cause when i catch the ball with the paddle well it works like its supposed when the paddle isn’t moving but when i move it the ball stays in the same spot and falls down more as i move the paddle to the left or right

idk if that makes any sense its 3 am right now
if it doesn’t just let me know and i’ll rephrase it in the morning [import]uid: 47760 topic_id: 11152 reply_id: 41012[/import]

Hey,

Indeed - as davemikesell said, you will want to change the velocity. If you’re just wanting the paddle to stop, set it to 0 :slight_smile: [import]uid: 52491 topic_id: 11152 reply_id: 41129[/import]

well i got the paddle to stop at the edge of the screen and to stay within the lower part of the screen and still be able to drag it left and right

so the paddle movement is done just that the ball and the physics might be a little bit out of line

when the ball hits the paddle and it stops in it and you move the paddle over to the right it would just go through it … the ball would go through the paddle…

(the paddle is kinda U shaped like a mechanics wrench, so you can catch the ball)

idk if the physics from gumbo didn’t work right or somethings wrong with the physics of the ball

is there a way i can set it up so that the ball stops moving down or up and just follows the paddle

or at least get the physics working like normal i was thinking of useing the physics editor but i’m not really sure what to do with the files it makes
do i just type in package.seeall after module(…) like this module(…, package.seeall)

am i supposed to to that?

then put require(“name of the lua file”) in the main lua file?
[import]uid: 47760 topic_id: 11152 reply_id: 41160[/import]

i think i might be completely off with that whole require thing… [import]uid: 47760 topic_id: 11152 reply_id: 41228[/import]