hi,
This sounds simple, but i can’t seem to figure it out.
I’m trying to switch between 2 shapes every time they are touched. I managed to get it to change from Shape01 to Shape02 when touched, but it wont change back to Shape01 when touched the 2nd time.
This as far as i could get with the code. Any help would be greatly appreciated.
thanks
[code]
local Shape01
local Shape02
Shape01= display.newCircle( 40, 25, 20 )
Shape01:setFillColor( 210, 38, 42 )
Shape01.alpha = 1
Shape01.myName = “Shape01”
local changeShape = function(event)
local phase = event.phase
local t = event.target
if “began” == phase then
if t.myName == “Shape01” then
Shape02= display.newRect( Shape01.x - 20, Shape01.y - 20, 40, 40 )
Shape02:setFillColor( 0, 0, 0 )
Shape02.myName = “Shape02”
Shape01:removeSelf() – destroy object
end
if t.myName == “Shape02” then
Shape01= display.newCircle( Shape02.x + 20, Shape02.y + 20, 20 )
Shape01:setFillColor( 210, 38, 42 )
Shape01.alpha = 1
Shape01.myName = “Shape01”
Shape02:removeSelf() – destroy object
end
end
end
Shape01:addEventListener( “touch”, changeShape )
Shape02:addEventListener( “touch”, changeShape )
[/code] [import]uid: 10542 topic_id: 3661 reply_id: 303661[/import]
