私は正しく知らないこのコードを試してみてください、しかしそれはうまくいきます:
local myRectangle = display.newRect(100, 100, 150, 50)
myRectangle.strokeWidth = 3
myRectangle:setFillColor(140, 140, 140)
myRectangle:setStrokeColor(180, 180, 180)
local button = display.newRect(100, 200, 50, 50)
button.strokeWidth = 3
button:setFillColor(140, 140, 140)
button:setStrokeColor(180, 180, 180)
local buttonfun=function(event)
if event.phase=="ended" then
print("fade")
if myRectangle.alpha ==1.0 then
transition.to( myRectangle, { delay=1, time=1000, alpha=1.0, alpha=0.0} )
myRectangle.alpha=0.0
print("alpha"..myRectangle.alpha)
else
transition.to( myRectangle, { delay=1, time=1000, alpha=0.0, alpha=1.0} )
myRectangle.alpha=1.0
print(myRectangle.alpha)
end
end
return true
end
button:addEventListener("touch", buttonfun)