Hi Rob…
I look at the if … you gave mebut I don’t know
where should I put it
all this is inside the create scene
-- fondo bg = display.newImageRect( sceneGroup, "images/bg.jpg", 1500, 900 ) bg.x = display.contentCenterX bg.y = display.contentCenterY obj1 = display.newCircle(0, 0, 30) obj1.x = 100 obj1.y = 100 obj1:setFillColor(1, 0, 1) transition.to(obj1, {time=4000, x=1200}) obj2 = display.newCircle(0, 0, 50) obj2.x = 1200 obj2.y = 100 obj2:setFillColor(1, 0, 0) transition.to(obj2, {time=5000, x=100}) bomb = display.newCircle(0, 0, 30) bomb.x = 700 bomb.y = 600 bomb:setFillColor(0, 1, 0) -- Circle-based collision detection local function hasCollidedCircle( obj1, obj2 ) if ( obj1 == nil ) then -- Make sure the first object exists return false end if ( obj2 == nil ) then -- Make sure the other object exists return false end local dx = obj1.x - obj2.x local dy = obj1.y - obj2.y local distance = math.sqrt( dx\*dx + dy\*dy ) local objectSize = (obj2.contentWidth/2) + (obj1.contentWidth/2) if ( distance \< objectSize ) then return true end return false end hasCollidedCircle( obj1, obj2 ) local function hope() if hasCollidedCircle( obj1, obj2 ) then -- do the stuff when they are touching bomb.xScale = 3 bomb.yScale = 3 else bomb.xScale = 1 bomb.yScale = 1 end end hope()
I put it inside a function and I call both functions
hope( )
hasCollidedCircle( obj1, obj2 )
I put it under – hasCollidedCircle( obj1, obj2 ) function and nothing
I am expecting the little circle “bomb”
to get big as soon as both circles touch
and nothing
Thanks for your time
Victor