如何逐渐使对象掉落? LUA

时间:2014-02-02 21:28:50

标签: lua corona

我可以让我的对象递增一次,但在第一次按下按钮后它不会继续下降。每次按下按钮,如何使图像对象下降50像素?

 local homer = display.newImage ("homer.png", 100, 20)

 local button = display.newImage ("button.png",260,460)
 local buttonText = display.newText ("Push ME =)", 260, 370, nil, 20)

 local spikes = display.newImage ("spikes.png",100 , 500)



 function drop ()
homer: removeSelf ()
homer = display.newImage ("homer.png", 100,20)
homer.y = homer.y + 70 -- How to drop homer incrementally continuously

end


button : addEventListener ("tap", drop)

1 个答案:

答案 0 :(得分:1)

只需在处理程序中更改对象的y,其他一切都很好:

function drop ()
    homer.y = homer.y + 70
end