hello everyone 
i am almost done the bigger part of my gameplay, but i have some small problems that I left to other time because i did not know how to solve this, now i need some help to finish this small problems of my gameplay:
1Âș first problemâŠresolved
thanks ng and info642
2Âș problem⊠on the if statement, i create a block, that have limit to 3, and when i create a object, it is counting #block, create and he add + 1, now i cant make when i remove the object i need to #block -1, remove a object from the counting
see the bigger comment on code
on this code have 2 more things to correct:
1Âș run the code you will see it:
- if you create a block and after click on the ball and after create another ball, will see it, the object that you create before the ball, you can drag it, and the block that you create after you can drag, and i need to stop all draggable objects
the second error:
if i click on the ball i should cant create more block, and i can 
that is all problems that remaining on my test code, i really need to finish it without errors because i need to go to final code, and cant resolve this problems because i dont know how i can make it
--variables
local physics = require "physics"
physics.start( true )
physics.setDrawMode( "normal" )
physics.setGravity( 0,0 )
--\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
-- Game
--\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
local game = function()
local block1 = {}
local active = 0
print(active)
local ball1 = display.newCircle( 80, 120, 20 )
ball1:setFillColor( 0, 255, 0 )
physics.addBody(ball1,"kinematic", { density=2, bounce=0.3, radius=25});
ball1.x = 250; ball1.y = 200
local spawner = display.newRect( 50, 300, 40, 40 )
spawner:setFillColor(150, 0, 0)
physics.addBody(spawner, "static", {isSensor = true})
spawner:addEventListener("collision", spawner)
local function touch(event)
if event.phase == "ended" then
active = active + 1
physics.setGravity( 0,9.8 )
ball1.bodyType="dynamic"
print(active)
end
end
ball1:addEventListener( "touch", touch )
--Objects and Drag
local function spawnMyObject (event)
if event.phase == "began" then
--remove function
function spawner:collision (event)
event.other:removeSelf()
end
--objects and physics
if #block1 \< 3 then
block1[#block1+1] = display.newRect( 50, 200, 50, 50 )
block1[#block1]:setFillColor( 255, 255, 255, 100 )
physics.addBody(block1[#block1], "kinematic", { density=2, friction=0, bounce=0, shape=barril })
block1[#block1].isFixedRotation = true
local function startDrag( event )
local t = event.target
local phase = event.phase
if "began" == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true
-- Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y
-- Stop current motion, if any
event.target:setLinearVelocity( 0, 0 )
event.target.angularVelocity = 0
elseif t.isFocus then
if "moved" == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0
event.target.bodyType = "dynamic"
elseif "ended" == phase or "cancelled" == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
-- Switch body type to kinematic, to avoid gravity
if ( not event.target.isPlatform ) then
event.target.bodyType = "kinematic"
end -- last if
end-- 2Âș if "move" end
end --if begin
--return true
end -- startdrag end
if active == 0 then
block1[#block1]:addEventListener("touch", startDrag)
else
block1[#block1]:removeEventListener("touch", startDrag)
end
end -- if #block end
end -- 1Âș if "begin" end
end --spawnMyObject end
if active == 0 then
spawner:addEventListener("touch", spawnMyObject)
elseif active == 1 then
spawner:addEventListener("touch", spawnMyObject)
end
end--startgame
game()
⊠and have one more problem, that i will post on another day 
Thanks very much people 
[import]uid: 26056 topic_id: 15959 reply_id: 315959[/import]