What I’m missing?
Here is a code that randomly spawns balls and if tapped, they are removed from the screen. Everything works fine, but I have feeling that sometimes tap isn’t registered:
[lua]local function piirraball()
local ball = display.newCircle( 100, 100, 30 )
ball:setFillColor(128,128,128)
ball.x = math.random(10,300)
ball.y = 0
ball.y = math.random(10,480)
function ball:tap(event)
ball.x=-1000
end
ball:addEventListener( “tap”, ball )
end
timer.performWithDelay(500,piirraball,10)[/lua]
Now - if I add some physics to balls, I’m certain that simulator misses clicks. Sometimes I have to click a ball about 10 times, before “tap” is registered. Here is the code:
[lua]local physics = require “physics”
physics.start()
physics.setGravity(0,1)
physics.setScale( 30 )
physics.setDrawMode( “hybrid” )
local function drawBall()
local ball = display.newCircle( 100, 100, 30 )
ball:setFillColor(128,128,128)
physics.addBody(ball, “dynamic”,{density = 1, friction = 0.1, bounce = 0.1, radius = 30})
ball.x = math.random(10,300)
ball.y = 0
function ball:tap(event)
ball.x=-1000
end
ball:addEventListener( “tap”, ball )
end
timer.performWithDelay(500,drawBall,10)[/lua]
What I’m doing wrong?
