Please see the code below.
My function to spawn multiple enemies works fine, they span and move to the desired location from random positions of the screen.
I capture their starting points in the homeX, and homeY properties.
My issue is that when the transition.to - completes and the sendEnemyHome home fires. I receive the following error.
Error ->> attempt to index local ‘group’ (a nil value)
If i just try to print anything out for the event i get a ‘nil’
anyone know why the onComplete does not act like other events and sends the object it completed on?
If I am doing something wrong could someone please point it out.
thanks in advance Larry
[code]
local sendEnemyHome = function(event)
local group = event.target
transition.to(group, {time = group.velocity, x = group.homeX, y = group.homeY }) --move back to where we came from
end
local function spawnEnemies( event )
local x,y, velocity, iDirection;
local group = display.newGroup()
local enemyMouse
x,y, velocity, iDirection = getRandomXY()
enemyMouse = display.newImage( mouseimage … iDirection … “.png” )
group:insert( enemyMouse, true ) – accessed in buttonListener as group[1]
group:translate( x,y ) --put it on the screen in the starting randome position
group.homeX = x; group.homeY = y; group.velocity = velocity; group.iDirection =iDirection --Store the home positions to return to
transition.to(group, {time = velocity, x = oCheese.x, y = oCheese.y, delay=100, onComplete=sendEnemyHome }) --start moving the enemy to the cheese
end
[/code] [import]uid: 11860 topic_id: 21018 reply_id: 321018[/import]
[import]uid: 8444 topic_id: 21018 reply_id: 83005[/import]