Object falling off screen

I have an object that moves across a “floor” when the object falls off the “floor” and goes off the screen I want buttons to pop up Restart, Menu, etc… Are their any tutorials for that sort of thing floating around? I looked pretty thoroughly but couldn’t find anything that specifically shows the outcome I’m looking for. Any examples would be greatly appreciated.

Thanks,
Andrew [import]uid: 72845 topic_id: 12340 reply_id: 312340[/import]

Use a periodic timer that checks the position of the objects. When an object position is out of the limits of the screen destroy it and show de popup.

Hope this helps

Isidro [import]uid: 53514 topic_id: 12340 reply_id: 44941[/import]

You can use a sensor rounding the screen to detect that too.

Isidro [import]uid: 53514 topic_id: 12340 reply_id: 44942[/import]

hi, take a look at my particle explosion snippet for an example on how to remove objects that are out of bound

http://developer.anscamobile.com/code/simple-particle-explosion#comment-42115

-finefin

[import]uid: 70635 topic_id: 12340 reply_id: 44952[/import]

Hmmm still a bit lost are their any examples of say…something falling off the bottom or side of the screen and having something pop up like Game over or something? Still figuring out the code functions and what not and being that I just started last week its been an uphill battle. Any examples would be greatly appreciated.

Thanks again,
Andrew [import]uid: 72845 topic_id: 12340 reply_id: 45368[/import]

Hello
You probably want to simplify and clean your code, so you need to make files like “main.lua” and “menu.lua” for your game and interface

put this to your main.lua:
[lua]local menu = require(“menu”) – We call our menu.lua file
local physics = require(“physics”) – We call physics to use in this file
physics.start() --Start gravity
physics.setGravity(0,10) – Set X and Y of gravity force
_W = display.contentWidth – Declare variable to store display.contentWidth
_H = display.contentHeight – Same

local ball = display.newCircle(0,0,30) – We create ball with radius 30
ball.x = _W/2; ball.y = -50 – Allight it to X and Y
physics.addBody(ball, “dynamic”) – Make it respont to physics

local function show_menu() – We make function, that will fire upon given circumstances
if ball.y >= _H then – if ball.y fall of screen bounds then
print(“off”) – this for debug
ball:removeSelf() – Ball will remove itself
menu.show_menu() – We call menu.lua with menu. and then write what function we want
end
end

timer.performWithDelay(1000, show_menu, 0) – Set a system timer that will monitor
– our show_menu every second, 0 is infinity times[/lua]

and this to menu.lua:
[lua]module(…, package.seeall)
_W = display.contentWidth
_H = display.contentHeight
local group = display.newGroup() – We create a group that will store our Rect and Button
group.alpha = 0 – this will make group invisible, but its still present on screen
group.x = _W/2 - 100
group.y = _H + 100

local menu = display.newRect(0,0,150,200) – Rect for our menu, its simply white
group:insert(menu) – We insert menu into the group

local button = display.newText(“BUTTON”, 30, 70, native.systemFont,20) – Make some button into menu
button:setTextColor(255,0,0) – make it red
group:insert(button)

local function touch_button(event) – We create touch event, you can call it everything you want
if event.phase == “ended” then – if event ended than what will fire?
print(“button touched”) – for debug, you can make it everything you need
end
end

button:addEventListener(“touch”, touch_button) – We added listener to button, so we can use it now

function show_menu() – Make function to show menu
transition.to(group, {time=2000, x = _W/2-100, y = _H/2, alpha = 1}) – This will transit group to given coordinates
–and make it visible with alpha=0, time=2000 is 2 seconds
print(“menu show”)
end[/lua]
this will give you example of physics, functions and transitions
good luck [import]uid: 16142 topic_id: 12340 reply_id: 45634[/import]

Darkconsoles, I would buy you a drink right now if I could. Thank you so much! [import]uid: 72845 topic_id: 12340 reply_id: 45641[/import]

you are welcome, its good practice for me anyway)
[import]uid: 16142 topic_id: 12340 reply_id: 45642[/import]

I have a shape:

local rect = display.newRect( 50, 50, 100, 100 )  
rect:setFillColor( 255, 255, 255, 100 )  
rect.isVisible = true -- optional  
rect.x = 364  
rect.y = 630  

and my sprite:

local data = require("sprites").getSpriteSheetData();  
local sheet = sprite.newSpriteSheetFromData(""sprite.png",data);  
local set = sprite.newSpriteSet(sheet, 1, 16);  

The sprite will eventually run into the shape. How can I make the button pop up from the bottom once the sprite hits the shape? Been messing around with it for a while now, and I’m still a bit confused : /

EDIT:
Here’s the rest of my sprite code if this helps:

[code]
local instance = sprite.newSprite(set);

instance.x = display.contentWidth/70
physics.addBody(instance, {bounce = 0.2, friction = .1, radius = 30})
instance.name = “sprite”

instance:play();
transition.to( instance, { time=15000, x = 1100 } )

playbutton:addEventListener( “touch”, buttonTouched )

playbutton:addEventListener(‘tap’, playbutton)
[/code] [import]uid: 72845 topic_id: 12340 reply_id: 46121[/import]

Any ideas? [import]uid: 72845 topic_id: 12340 reply_id: 46915[/import]