First off, Thanks to Danny for giving me much needed help and examples. They make a difference in understanding things.
Now, enough butt kissing 
Here are my 2 problems:
- I have some code that spawns diamonds. The problem being that they will not spawn without me clicking a button. I would like the spawned images to appear automatically ( I’m assuming a timer.
I’ve tried different timers in different areas but nothing I do works. Any help on this appreciated.
Here is my spawn code:
local function spawndiamond( event )
local phase = event.phase
if "ended" == phase then
audio.play( popSound )
displays number of different images
randImage = diamondGfx[math.random( 1, 4 )]
alldiamonds[#alldiamonds + 1] = display.newImage( randImage )
local diamond = alldiamonds[#alldiamonds]
diamond.x = 60
diamond.y = 50
diamond.xScale = 1.8; diamond.yScale = 0.8
transition.to(diamond, { time = 500, xScale = 1.0, yScale = 1.0, transition = easingx.easeOutElastic })
physics.addBody( diamond, { density=0.0, friction=0.0, radius=20.0, bounce=0.0 } )
diamond.linearDamping = 0.4
diamond.angularDamping = 0.6
local spawndiamond = timer.performWithDelay( 500, diamond, 6 )
local diamondmove = diamond
physics.addBody( diamondmove, { density=1.5, friction=0.6, radius=00.3, bounce=0.3 } )
diamondmove.x=40
diamondmove.y=60
Second question:
The way my code is set up ( Thanks again Danny) is that when I click on a diamond and then click on a different area of the screen, the diamond moves to the new area. That works great.
However, is it possible to click on a diamond and then click on a second diamond and have the original diamond replace the second diamond? Hope it makes sense. Thanks.
[code]
local diamondmove = diamond—MOVE DIAMOND FROM ONE POINT TO ANOTHER
physics.addBody( diamondmove, { density=1.5, friction=0.6, radius=00.3, bounce=0.3 } )
diamondmove.x=40
diamondmove.y=60
local targetToMove = nil
local function setTarget(event)
local target = event.target
targetToMove = target
return true
end
local function movediamondmove(event)
if targetToMove ~= nil then
targetToMove.x = event.x
targetToMove.y = event.y
targetToMove = nil
end
return true
end
diamondmove:addEventListener(“tap”, setTarget) [import]uid: 127842 topic_id: 22444 reply_id: 322444[/import]