for loop vs. listeners

which is faster for Corona?

create an array of the tile pieces that animate and execute a for loop in a single function

or

attach an enterFrame listener to the tiles that animate

I am developing a test game that utilizes isometric, animated tiles. Only a handful of the tiles cycle graphics at a recurring frequency. Think water in a pond cycling. the matrix of images is, say 20 tiles by 20 tiles. 20 of the tiles animate.

Are you asking, “Should I write a function (called once per frame) that  a loops to handle all the animated tiles as a group, or should I use enter frame and call the event listener for each piece every frame?”

If you can easily track the objects you want to handle in a table, then calling a single looping function that iterates over the objects once per frame is much faster than having the event listener for each object trigger every frame.

The more objects you have to deal with the more this will become obvious as you cut out the event triggering overhead.

You might want to look into the Million Tile Engine which will soon support isometric tiles…

http://forums.coronalabs.com/topic/33119-million-tile-engine-beta-release/

This is literally what I am creating! Thanks for the link!

Yep, that’s what I thought. Thanks for confirming. It is always a delicate balance between using what is in place vs. developing your own code. I appreciate the feedback.

Are you asking, “Should I write a function (called once per frame) that  a loops to handle all the animated tiles as a group, or should I use enter frame and call the event listener for each piece every frame?”

If you can easily track the objects you want to handle in a table, then calling a single looping function that iterates over the objects once per frame is much faster than having the event listener for each object trigger every frame.

The more objects you have to deal with the more this will become obvious as you cut out the event triggering overhead.

You might want to look into the Million Tile Engine which will soon support isometric tiles…

http://forums.coronalabs.com/topic/33119-million-tile-engine-beta-release/

This is literally what I am creating! Thanks for the link!

Yep, that’s what I thought. Thanks for confirming. It is always a delicate balance between using what is in place vs. developing your own code. I appreciate the feedback.