我的widget.newScrollView組件後面有一個背景圖像。 我想以我的newScrollView速度的一半移動我的背景圖像。 這工作正常,當我拖動我的滾動視圖,但當我釋放鼠標滾動視圖保持滑動,但我的背景停止移動。請告訴我如何捕捉滑動事件。 非常感謝Lua Corona - 如何在滑動過程中偵聽widget.newScrollView偵聽器
下面是我的一些代碼:
local function scrollListener(event)
local phase = event.phase
if (phase == "began") then print("Scroll view was touched")
elseif (phase == "moved") then print("Scroll view was moved")
nebulaeBgnd.x = event.x/2;
elseif (phase == "ended") then print("Scroll view was released")
end
end
local a1 = display.newImage("planetHexs/001.png", _topLeft_x, _topLeft_y);
local scrollView = widget.newScrollView(
{
top = 0,
left = 0,
width = display.actualContentWidth,
height = display.actualContentHeight,
scrollWidth = 0,
scrollHeight = 0,
listener = scrollListener,
backgroundColor = { 0, 0, 0},
verticalScrollDisabled=true;
}
scrollView:insert(a1)
感謝巴西利奧,那太好了 –
不客氣! –