使用Transition to + onComplete立即调用函数

时间:2017-05-17 17:49:33

标签: lua corona

彩虹旋转到屏幕上,沿着它出现小方块。但是,这会立即发生,而不是onComplete。我做错了什么?

transition.to( rainbow, { time=10000, rotation=90*rainbowRotationDirection, onComplete=objectsOnRainbow()} )

这在上下文中:

local function objectsOnRainbow()
print("objectsOnRainbow")
NumberOfPoints = 5
Angle90Degree = math.pi/2
AngleStep = Angle90Degree/(NumberOfPoints-1)
Angle = 0

 for i = 0, NumberOfPoints-1, 1 do


   local x = ((rainbow.height)/2)*math.cos(Angle)
   local y = ((rainbow.height)/2)*math.sin(Angle)
      local x2 = ((rainbow.height-140)/2)*math.cos(Angle)
   local y2 = ((rainbow.height-140)/2)*math.sin(Angle)
    Angle = Angle + AngleStep


rectangleonRainbow = display.newRect(x, display.contentHeight-y, 5, 5)
rectangleonRainbow2 = display.newRect(x2, display.contentHeight-y2, 5, 5)

end
end

local function rainbowAppear()
local sceneGroup = scene.view

rainbow = display.newImageRect(objectSheet, 38, 590, 590)
rainbow.y = display.contentHeight


rainbow.x = 0
rainbowRotationDirection = 1

audio.play(harpSound)
    transition.to( rainbow, { time=10000, rotation=90*rainbowRotationDirection, onComplete=objectsOnRainbow()} )
     sceneGroup:insert( rainbow )
end

0 个答案:

没有答案