Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

Create new object based on timer
Started by Appletreeman Jul 27 2010 04:04 AM

- - - - -
1 reply to this topic
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Contributor

  • 451 posts
  • Corona SDK

Hi, I'm a complete noob with Coroner and I'm still trying to get my head around the language so apologies if this seems like a stupid question.
What I have is an object (small circle) that appears from one side of the screen at a random point and moves across to the other side and is removed once it has disappeared off the side (or if it is tapped). What I would like to do is a have a timer that creates a new object every x seconds. I'm just not entirely sure how to go about it.
Any help at all would be appreciated. Thanks.
uid: 7841 topic_id: 1514 reply_id: 301514

[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Contributor

  • 433 posts
  • Corona SDK

Hi Appletreeman

I am also a noob so don't' consider this the perfect answer especially as I am typing this on a PC and have not tested the code. But from the API here is what it appears you need to try:

local createNewObject = {}
function createNewObject:timer( event )
     -- Put your code here to create the new object

timer.performWithDelay(1000, createNewObject, 0)

Here is the syntax:

timer.performWithDelay( delay, listener [, iterations] )

An optional parameter iterations specifies the number of times listener is invoked. By default, it is 1; pass 0 if you want it to loop forever.

Hope that helps

uid: 7863 topic_id: 1514 reply_id: 4469