my game is about a lot of balls that are falling and when i touch they exploited. i want put a timer (i don’t now the code to put a timer this way) and when the ball are all exploit and you have time remaining you win
but if you are out of time and still balls in the screen you lose. but i dont now how
sorry for the bad bad english i am from venezuela and i have 13 years old…
i hope you understand the question. and thanks for the help
this is my code
[code]
–set music
local pop_sound = audio.loadSound(“pop.mp3”)
– 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.1)
–set background image
local background = display.newImage( “background.jpg” )
–set wall image and position
local wall= display.newImage(“bara.png”)
wall.x = display.contentWidth/95
–turn wall into physics body
physics.addBody(wall,“static”)
–set wally image and position
local wally = display.newImage(“bara.png”)
wally.x = display.contentWidth/1
–turn wally into physics body
physics.addBody(wally,“static”)
–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”)
local function trackBalls (obj)
obj:removeSelf()
end
–set ball to stage and position
local function spawnBall()
local ball =display.newImage(“bead2.png”)
ball.x = math.random ( 320 )
ball.y = -100
– turn ball into physics body
physics.addBody(ball,{ bounce = 0.2 , friction = 5} )
function ball:touch(e)
if(e.phase == “ended”) then
–Play the popping sound
audio.play(pop_sound);
–remove the balls
trackBalls(self);
end
return true;
end
ball:addEventListener(“touch”, ball) ;
end
timer.performWithDelay( 100,spawnBall,10)
[import]uid: 179948 topic_id: 31602 reply_id: 331602[/import]