local W = application:getLogicalWidth()
local H = application:getLogicalHeight()
local xD, yD, speed = 1, 1, 10
local img = newImage("myImage2.png", 0, 0)
local wd, ht = img:getWidth(), img:getHeight()
function onEnterFrame(event)
local xP, yP = img:getPosition()
xP = xP + xD*speed yP = yP + yD*speed
if xP >= W-wd or xP == 0 then
xD = −xD
end
if yP >= H-ht or yP == 0 then
yD = −yD
end
img:setPosition(xP, yP)
end
img:addEventListener(Event.ENTER_FRAME, onEnterFrame)
I have above piece of code and my question is why Event.ENTER_FRAME
here? All this code does is move the ball across screen, we are not changing any frame,then why do I need this? What is the difference if I use it without Event.ENTER_FRAME
?