Hi,
I am using a technique to avoid the addition of many “enterFrame” listeners for efficiency issues. But I don’t actually know if I’m saving any processing resources or even the opposite.
The “solution” is the following:
local rect1=display.newRect(300,300,50,50)
rect1.vx=0.5
rect1.vy=0.5
local rect2=display.newRect(400,400,50,50)
rect2.vx=0.1
rect2.vy=0.6
local rect3=display.newRect(500,500,50,50)
rect3.vx=0.3
rect3.vy=0.2
function rect1:frame()
self:translate(self.vx, self.vy)
end
Runtime:addEventListener("frame", rect1)
function rect2:frame()
self:translate(self.vx, self.vy)
end
Runtime:addEventListener("frame", rect2)
function rect3:frame()
self:translate(self.vx, self.vy)
end
Runtime:addEventListener("frame", rect3)
Runtime:addEventListener("enterFrame", function()
Runtime:dispatchEvent{name="frame"}
end)
Does someone know if this is better than:
local rect1=display.newRect(300,300,50,50)
rect1.vx=0.5
rect1.vy=0.5
local rect2=display.newRect(400,400,50,50)
rect2.vx=0.1
rect2.vy=0.6
local rect3=display.newRect(500,500,50,50)
rect3.vx=0.3
rect3.vy=0.2
function rect1:enterFrame()
self:translate(self.vx, self.vy)
end
Runtime:addEventListener("enterFrame", rect1)
function rect2:enterFrame()
self:translate(self.vx, self.vy)
end
Runtime:addEventListener("enterFrame", rect2)
function rect3:enterFrame()
self:translate(self.vx, self.vy)
end
Runtime:addEventListener("enterFrame", rect3)
and also, it is said that transitions ocurr at frame time. Does this mean they are like a preconfigured “enterFrame” event? So the same efficiency?
Thanks!
Ernest [import]uid: 76413 topic_id: 23940 reply_id: 323940[/import]