I dont know the code for this task.Can someone help.
Hi @demonic_command. Your question is pretty vague. There are many ways to determine when an object leaves the screen and what those solutions are depends on what your trying to do. Are you using physics? Are you using transitions? A runtime enterFrame listener? We can’t just guess.
If you can post some code showing how you’re creating your ball and how you are moving it, we probably could give you better advice. Please paste your code between these tags: and taking out the space between the first square bracket and the text.
Code
function getMetalSphere®
local ball= display.newImage(“ball.png”,0,0,r)
– ball:setFillColor(0,169,231)
physics.addBody(ball, “dynamic”, {density= 10, radius= r, bounce=0.0, friction= 0.2})
return ball
end
– Add ball
local ball = getMetalSphere(23)
ball.x= 100
ball.y= 400
ball.myName=“ball”
ball.isFixedRotation=true
– Add floor
local floor_bottom = display.newImage( “grass_bottom.png”, true )
physics.addBody( floor_bottom, “static”, { friction=0.5, bounce=0 } )
floor_bottom.x = _W/2; floor_bottom.y = _H-70;
floor_bottom.myName=“floor_bottom”
[/code]
so i want to print out “ball is out of screen” when the ball leaves the screen.
How do i carry this out??
Hi @demonic_command. Your question is pretty vague. There are many ways to determine when an object leaves the screen and what those solutions are depends on what your trying to do. Are you using physics? Are you using transitions? A runtime enterFrame listener? We can’t just guess.
If you can post some code showing how you’re creating your ball and how you are moving it, we probably could give you better advice. Please paste your code between these tags: and taking out the space between the first square bracket and the text.
Code
function getMetalSphere®
local ball= display.newImage(“ball.png”,0,0,r)
– ball:setFillColor(0,169,231)
physics.addBody(ball, “dynamic”, {density= 10, radius= r, bounce=0.0, friction= 0.2})
return ball
end
– Add ball
local ball = getMetalSphere(23)
ball.x= 100
ball.y= 400
ball.myName=“ball”
ball.isFixedRotation=true
– Add floor
local floor_bottom = display.newImage( “grass_bottom.png”, true )
physics.addBody( floor_bottom, “static”, { friction=0.5, bounce=0 } )
floor_bottom.x = _W/2; floor_bottom.y = _H-70;
floor_bottom.myName=“floor_bottom”
[/code]
so i want to print out “ball is out of screen” when the ball leaves the screen.
How do i carry this out??