I’ve tried messing with different code and trying to incorporate it into my own code but nothing has worked. I’ve tried countless examples and I’ve always run into a road block.
Everyone who has tried to help me is appreciated.
BUT I cannot get past 2 annoying problems.
#1. I cannot get the 2 objects (square and circle) to swap.Clicking on a square then clicking on a circle should swap them around.
#2. How can I get 2 or 3 circles to remove themselves if they are touching each other? My circles are individual images all with the same dimensions and physics. Color is the only difference between them.
ANY help would be appreciated.
local squareGfx = { “circle-white-bomb.png”, “circle-red-bomb.png” }
local allsquares = {}
local circleGfx = { “circle-white.png”, “circle-orange.png”, “circle-blue.png”, “circle-red.png”,
“circle-green.png”, “circle-purple.png”, “circle-grey.png” }
local allcircles = {}
local function spawnsquare( )
randImage = squareGfx[math.random( 1, 2 )]
allsquares[#allsquares + 1] = display.newImage( randImage )
local square = allsquares[#allsquares]
square.x = 35 – could be randomised?
square.y = 93 – could be randomised?
physics.addBody( square, { density=0.0, friction=0.0, bounce=0.0, radius = 31 } )
square:addEventListener( “touch”, dragBody )
end
timer.performWithDelay(interval, spawnsquare, 5)
local function spawncircle( )
– audio.play( popSound )
randImage = circleGfx[math.random( 1, 8 )]
allcircles[#allcircles + 1] = display.newImage( randImage )
local circle = allcircles[#allcircles]
circle.x = 50 – could be randomised?
circle.y = 375 – could be randomised?
physics.addBody( circle, { density=-5.0, friction=0.0, bounce=-2.0, radius = 27 } )
circle:addEventListener( “touch”, dragBody )
end
timer.performWithDelay(interval, spawncircle, 25) [import]uid: 127842 topic_id: 22738 reply_id: 322738[/import]