How to stop delay when automatically creating objects

I have an object that is automatically created using the following code:

cratesEaten = 0  
crateCounter = 1  
crateCount = 7  
  
local function onFrame(event)  
  
 -- If Statement for the generation of the crates  
 -- from top of the screen to the bottom  
 crateCounter = crateCounter + 1  
  
 if(crateCounter % 40 == 0 and crateCount \> 0) then   
 crateCount = crateCount - 1  
  
 local crate1 = display.newImage("crate.png")  
 -- crate1.x = math.random(0, 310)  
 crate1.x = 30  
 crate1.y = -100  
 -- crate1.rotation = math.random(0, 360)  
 --physics.addBody(crate1, {density = 2.0, friction = 1.5, bounce=0.01})  
 physics.addBody(crate1, {density = 2.0, friction = 1.5, bounce=0.01})  
 crate1.myName = "crate"  
 end  
  
end  
  

Just need to know how to stop the delay of when the objects are created. Even when I have crate one spawn off screen there is a delay. [import]uid: 23642 topic_id: 36602 reply_id: 336602[/import]

need [import]uid: 23642 topic_id: 36602 reply_id: 144893[/import]

There is always a delay when creating objects, there’s just no way around that. It looks by the naming of your function that you might be doing it on each frame. Is that so? I would definitely stop doing that.

If you need to create a lot of physics objects but don’t want the overhead, you could create them all off screen at the start, disable their body using isBodyActive=false and bring them in when needed. [import]uid: 8271 topic_id: 36602 reply_id: 144900[/import]

I got the code about automatically creating the objects from an example. Is there a better way. All I need is the object to replicate itself so it appears that one object is directly behind the other. [import]uid: 23642 topic_id: 36602 reply_id: 144921[/import]

For that you just need to create two of the object and position them at almost the same x,y location. What is it you want to do in general with that effect? Are you trying to create a shadow? What code do you have calling the onFrame function? [import]uid: 8271 topic_id: 36602 reply_id: 144947[/import]

need [import]uid: 23642 topic_id: 36602 reply_id: 144893[/import]

There is always a delay when creating objects, there’s just no way around that. It looks by the naming of your function that you might be doing it on each frame. Is that so? I would definitely stop doing that.

If you need to create a lot of physics objects but don’t want the overhead, you could create them all off screen at the start, disable their body using isBodyActive=false and bring them in when needed. [import]uid: 8271 topic_id: 36602 reply_id: 144900[/import]

I got the code about automatically creating the objects from an example. Is there a better way. All I need is the object to replicate itself so it appears that one object is directly behind the other. [import]uid: 23642 topic_id: 36602 reply_id: 144921[/import]

For that you just need to create two of the object and position them at almost the same x,y location. What is it you want to do in general with that effect? Are you trying to create a shadow? What code do you have calling the onFrame function? [import]uid: 8271 topic_id: 36602 reply_id: 144947[/import]

need [import]uid: 23642 topic_id: 36602 reply_id: 144893[/import]

There is always a delay when creating objects, there’s just no way around that. It looks by the naming of your function that you might be doing it on each frame. Is that so? I would definitely stop doing that.

If you need to create a lot of physics objects but don’t want the overhead, you could create them all off screen at the start, disable their body using isBodyActive=false and bring them in when needed. [import]uid: 8271 topic_id: 36602 reply_id: 144900[/import]

I got the code about automatically creating the objects from an example. Is there a better way. All I need is the object to replicate itself so it appears that one object is directly behind the other. [import]uid: 23642 topic_id: 36602 reply_id: 144921[/import]

For that you just need to create two of the object and position them at almost the same x,y location. What is it you want to do in general with that effect? Are you trying to create a shadow? What code do you have calling the onFrame function? [import]uid: 8271 topic_id: 36602 reply_id: 144947[/import]

need [import]uid: 23642 topic_id: 36602 reply_id: 144893[/import]

There is always a delay when creating objects, there’s just no way around that. It looks by the naming of your function that you might be doing it on each frame. Is that so? I would definitely stop doing that.

If you need to create a lot of physics objects but don’t want the overhead, you could create them all off screen at the start, disable their body using isBodyActive=false and bring them in when needed. [import]uid: 8271 topic_id: 36602 reply_id: 144900[/import]

I got the code about automatically creating the objects from an example. Is there a better way. All I need is the object to replicate itself so it appears that one object is directly behind the other. [import]uid: 23642 topic_id: 36602 reply_id: 144921[/import]

For that you just need to create two of the object and position them at almost the same x,y location. What is it you want to do in general with that effect? Are you trying to create a shadow? What code do you have calling the onFrame function? [import]uid: 8271 topic_id: 36602 reply_id: 144947[/import]