Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

spawn new display.newImage object
Started by joxenford Nov 22 2010 03:33 AM

2 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

joxenford

[GLOBAL: userInfoPane.html]
joxenford
  • Enthusiast

  • 34 posts
  • Corona SDK

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!


uid: 10763 topic_id: 3864 reply_id: 303864


[TOPIC: post.html]
#2

tetu

[GLOBAL: userInfoPane.html]
tetu
  • Contributor

  • 166 posts
  • Corona SDK

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 ...
uid: 6459 topic_id: 3864 reply_id: 11818


[TOPIC: post.html]
#3

joxenford

[GLOBAL: userInfoPane.html]
joxenford
  • Enthusiast

  • 34 posts
  • Corona SDK

tetu, this worked!

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



[topic_controls]
[/topic_controls]