Spawning objects on X and Y.

Hi all,  newbie question.

So I’m having some issues trying to find a tutorial that helps with basic spawning on X and Y coords. I’d like to use the “Tap or Touch” function and have it spawn an object on the coordinates I “Tap or Touch” on.

Does anyone know any good tutorials, or know some basic code to put me in the right direction? I just need to get the gist of it.

Thanks loads.

You probably won’t find anything like that except maybe in a book (try Dr Burton’s Books).

However, here is some code doing what you described (spawning circles in this example)

local mRand = math.random local function onTouch( event ) if( event.phase == "ended" ) then local tmp = display.newCircle( event.x, event.y, 20 ) tmp:setFillColor( mRand(), mRand(), mRand() ) end return true end Runtime:addEventListener( "touch", onTouch )

I suspect you’re having trouble because you are thinking in specific high level terminology like “spawn”, instead of starting at the bottom and learning about these ideas:

  • touches
  • listeners
  • creation - Circles, rectangles, images, image rectangles 

Note: This is not an admonition, but rather encouragement not to leap too fast without first learning the principles of working with Corona.

Here are some great resources to be aware of right here on the site:

Thank you very much Roaming, for the great responses. That’s just what I was looking for.

You probably won’t find anything like that except maybe in a book (try Dr Burton’s Books).

However, here is some code doing what you described (spawning circles in this example)

local mRand = math.random local function onTouch( event ) if( event.phase == "ended" ) then local tmp = display.newCircle( event.x, event.y, 20 ) tmp:setFillColor( mRand(), mRand(), mRand() ) end return true end Runtime:addEventListener( "touch", onTouch )

I suspect you’re having trouble because you are thinking in specific high level terminology like “spawn”, instead of starting at the bottom and learning about these ideas:

  • touches
  • listeners
  • creation - Circles, rectangles, images, image rectangles 

Note: This is not an admonition, but rather encouragement not to leap too fast without first learning the principles of working with Corona.

Here are some great resources to be aware of right here on the site:

Thank you very much Roaming, for the great responses. That’s just what I was looking for.