i want that a lot of balls come off the top of the screen and when i touch one.she disappears, and when i touch other she disappears too (sorry for the bad english,i am from venezuela, i have 13 years old and i am very very noob with corona sdk)
this is my code
[code]
– -- add physics engine, start up the engine, and apply gravity
local physics = require(“physics”)
physics.start()
– Set gravity to act “down” (ie, toward the bottom of the device )
physics.setGravity (-0.4, 9)
–set background image
local background = display.newImage( “background.jpg” )
– A touch listener to remove rocks
local removeBody = function( event )
local t = event.target
local phase = event.phase
if “began” == phase then
t:removeSelf() – destroy object
end
– Stop further propagation of touch event
return true
end
–add floor image and position
local floor = display.newImage(“bar.png”)
floor.y = display.contentHeight/1.03
– turn floor into physics body
physics.addBody(floor,“static”)
–set ball to stage and position
local function spawnBall()
ball =display.newImage(“bead2.png”)
ball.x = math.random ( 320 )
ball.y = -20
– turn bead into physics body
physics.addBody(ball,{bounce = 0.1 } )
end
timer.performWithDelay( 500,spawnBall,50)
ball:addEventListener( “touch”, removeBody ) – assign touch listener to rock
balls[#balls + 1] = ball
end
[import]uid: 179948 topic_id: 31381 reply_id: 331381[/import]