Hello - newb here learning programming as I go.
I have 12 objects spawning at random locations and then each moving off in a random direction.
I want to be able to tap one and my player object will move to it’s location.
I’ve been able to do it with other objects, but I get errors if its one of my 12 identical objects.
I also tried to make sense of this blog post but I wasn’t able to follow it: http://blog.anscamobile.com/2011/09/how-to-spawn-objects-—-the-right-way/
Here’s the offending code:
[lua]–screen bootstrap
display.setStatusBar(display.HiddenStatusBar)
local whiteBg = display.newRect(0,0,display.contentWidth,display.contentHeight)
local player = display.newImage(“images/player.png”)
player.x = 512
player.y = 384
–Function to spawn enemies and set them moving
local function spawn()
local enemy1 = display.newImage(“images/enemy2.png”)
enemy1.x = math.random(30,994)
enemy1.y = math.random(30,738)
local function moveEnemy1()
transition.to(enemy1, {time=math.random(3000,7000), x=math.random(30,1024), y=math.random(20,768), onComplete=moveEnemy1})
end
moveEnemy1()
return enemy1
end
–Create a table to hold our spawns
local spawnTable = {}
–Spawn 8 enemies
for i = 1, 12 do
spawnTable[i] = spawn()
end[/lua]
[import]uid: 121833 topic_id: 26028 reply_id: 326028[/import]

[import]uid: 52491 topic_id: 26028 reply_id: 105384[/import]