Controlling moving sprites

I’m trying to convert a Flash game to Corona.

Basic setup is: A number of animated fish are generated randomly, and speed, angle, direction are different for each fish. Ther move around in a certain way and react to other objects
The Flash version just creates a EnterFrame listener for each fish, but in Corona you can’t setup an Enterframe listener for an object. Only Runtime.

So if i want to control every fish (moving and reacting to other fishes) , what type of Listener do I use?

If I use Enterframe listener, I have to do a do - loop through all the fishes and control them that way?

Wouldn’t that be overkill? Or maybe a timer?

[import]uid: 50459 topic_id: 35565 reply_id: 335565[/import]

I am not expert on that, but I would do a for loop in the enterFrame to control all the fishes.

Renato
Red Beach Games
Try our new game Puzzle You for free here!
[import]uid: 181011 topic_id: 35565 reply_id: 141357[/import]

I’d attach a timer to each fish and let each fish basically take care of itself.

function doFishStuff(event)

end

fish[#fish+1] = display.newImage(“fish.png”)
fish.tmr = timer.performWithDelay(100, doFishStuff, 0)

Now the doFishStuff function is called 10 times per second and you can send that fish in another direction, have him eat food, etc.

When the fish gets eaten by a shark or caught by a fisherman, just remember to cancel the timer using the handle stored in the fish[x].tmr property.

Jay
[import]uid: 9440 topic_id: 35565 reply_id: 141388[/import]

Thanks Jay, I’ll give the timer a try! [import]uid: 50459 topic_id: 35565 reply_id: 141423[/import]

I am not expert on that, but I would do a for loop in the enterFrame to control all the fishes.

Renato
Red Beach Games
Try our new game Puzzle You for free here!
[import]uid: 181011 topic_id: 35565 reply_id: 141357[/import]

I’d attach a timer to each fish and let each fish basically take care of itself.

function doFishStuff(event)

end

fish[#fish+1] = display.newImage(“fish.png”)
fish.tmr = timer.performWithDelay(100, doFishStuff, 0)

Now the doFishStuff function is called 10 times per second and you can send that fish in another direction, have him eat food, etc.

When the fish gets eaten by a shark or caught by a fisherman, just remember to cancel the timer using the handle stored in the fish[x].tmr property.

Jay
[import]uid: 9440 topic_id: 35565 reply_id: 141388[/import]

Thanks Jay, I’ll give the timer a try! [import]uid: 50459 topic_id: 35565 reply_id: 141423[/import]