Android Corona SDK:transition.to和transition.moveBy不工作
当我按下按钮时,我需要在我的应用程序中使用transition.moveBy,但当我调用它时,我得到: 尝试调用字段“moveBy”(一个nil值) 我甚至尝试从文档中复制示例代码,该示例代码位于函数randomFunction中:Android Corona SDK:transition.to和transition.moveBy不工作,android,ios,lua,coronasdk,Android,Ios,Lua,Coronasdk,当我按下按钮时,我需要在我的应用程序中使用transition.moveBy,但当我调用它时,我得到: 尝试调用字段“moveBy”(一个nil值) 我甚至尝试从文档中复制示例代码,该示例代码位于函数randomFunction中: local function randomFunction( ... ) square = display.newRect( 0, 0, 100, 100 ) transition.moveBy( square, { x=100, y=100, ti
local function randomFunction( ... )
square = display.newRect( 0, 0, 100, 100 )
transition.moveBy( square, { x=100, y=100, time=2000 } )
end
randomBtn = widget.newButton{
labelColor = { default={255}, over={128} },
width=57, height=55,
onRelease = randomFunction
}
如何修复此问题?尝试以下方法:
local widget = require( "widget" )
local function randomFunction( ... )
local square = display.newRect( 0, 0, 100, 100 )
transition.moveBy( square, { x=100, y=100, time=2000 } ) end
local randomBtn = widget.newButton{
label = "my button",
labelColor = { default={1,0.5,0.5}, over={0,0.5,0.5} },
width=57, height=55,
onRelease = randomFunction }
您没有声明标签文本。所以没有可见的按钮。试着用Lukis的答案。只需在声明方形矩形后添加以下行。因此,您的矩形颜色将为红色,并且也将可见
square:setFillColor(255,0,0)
有一张图片,我刚刚输入了名字:pAnyway,问题是一个过时的corona版本。Thansk的帮助:)顺便说一句,setFillColor参数不再是int 0-255,而是float 0-1