如何在corona sdk中移动物体透明度时如何更改物体透明度?

问题描述:

我正在尝试创建一个可拖曳的正方形,它将透明度更改为更接近屏幕中心(从侧面不可见到中央完全可见,如下图所示)如何在corona sdk中移动物体透明度时如何更改物体透明度?

enter image description here

enter image description here

enter image description here

+0

那你至今呢?用于显示对象的不透明度['alpha'](https://docs.coronalabs.com/api/type/DisplayObject/alpha.html)属性。 – ldurniat

可以使用alphatransition实现这一尝试下面的代码,它应该工作..下面的代码改变平方超过1.5秒的一段时间0至100% uare透明度,同时移动

display.setDefault("background", 80/255) 
local square = display.newRect( 0, display.contentHeight/2, 100, 100) 
square.anchorChildren = true 
square:setFillColor(255,255,0) 
square.alpha = 0 

local w,h = display.contentWidth, display.contentHeight 


transition.moveTo(square, { x = w/2, y = h/2, time=1500 , alpha = 1.0})