spawn new display.newImage object

Hey Everyone,

I’m a new user and I’m building an app targeted for the toddler crowd that let’s them decorate a Christmas tree.

I’m getting stuck on spawning new objects.

I use the following function to spawn a red ball

createRedXmasBall = function ()  
 local red\_Ball = display.newImage ( "red\_Ball.png", 20, 440)  
 red\_Ball:addEventListener("touch", startDrag)  
end  
createRedXmasBall ()  

then, at the end of my drag event handler I can use

createRedXmasBall ()  

to spawn the another ball and it works great.

My big problem is that I also have blue and yellow balls.

How can I pragmatically determine the color of the ball that has been dragged and spawn another of the same type?

Thank you!

[import]uid: 10763 topic_id: 3864 reply_id: 303864[/import]

red\_Ball.color="red"

you can assign any variable or method to the red_Ball object

and in the startDrag function check for the color of the object being dragged, using

if event.target.color=="red" then ...

tetu, this worked!

Thank you very much for the newbie help!
[import]uid: 10763 topic_id: 3864 reply_id: 11906[/import]