[Resolved] Moowing an array of object one a curve

hello i am tempting to to move an array of objects on a path
the problem is that i what that each object to go from the start of the path til the end
i store values of x, and y coordinates in an array segments={}

in this function i create a n enemy object
function creatNew()

EnemyOb = enemy.newEnemy({type=“Level1”})

EnemyOb.x=segments[1].x
EnemyOb.y=segments[1].y
physics.addBody(EnemyOb,“dynamic”,{bounce = 0,filter=enemyCollisionFilter})
EnemyOb.collision=onCollision

EnemyOb:addEventListener( “collision”, EnemyOb )
for k = 1, level.spawnNoOfEnemys do
enemysTable[k]=EnemyOb

end
for x=1 ,#enemysTable do
__ MOVE each enemysTable[x] on path from 1 to 100

end

end

i am stuck at this part for like 2 days or so … can someone help
thank you [import]uid: 169726 topic_id: 30920 reply_id: 330920[/import]

Take a look at this, shouldn’t be too hard to modify to suit your purpose; http://developer.coronalabs.com/code/move-object-through-path

Peach :slight_smile: [import]uid: 52491 topic_id: 30920 reply_id: 123737[/import]

thanks . it’s working … it is interesting because i found this post on forum
the problem was whit the logic of when i was updating and when i needed to cal the function

so the code is here if someone needs it

function move(obj)

if obj.path then
local pos =1
local temp=obj
local objectPath=obj.path
temp.x=objectPath[pos].x

local function increment()

temp.x=objectPath[pos].x
temp.y=objectPath[pos].y
pos=pos+1
end
moveTIME=timer.performWithDelay( 10, increment, #objectPath )

end
end

function EnemysOnPath()
for k = 1, 1 do
enemysTable[k]=creatNew(object,10)

move(enemysTable[k])
end
end

thank you again…
i am beginning to understand corona …yupeee… [import]uid: 169726 topic_id: 30920 reply_id: 123804[/import]

Try and post code inside < lua > and < /lua > tags without the spaces :wink:

That said - fantastic! Thank you for sharing code :slight_smile: [import]uid: 52491 topic_id: 30920 reply_id: 123854[/import]

ok i will do so when i post my code :smiley:
and yes i am whit that mentality that code sharing is help full a lot :smiley: so i will share in future [import]uid: 169726 topic_id: 30920 reply_id: 123932[/import]

Take a look at this, shouldn’t be too hard to modify to suit your purpose; http://developer.coronalabs.com/code/move-object-through-path

Peach :slight_smile: [import]uid: 52491 topic_id: 30920 reply_id: 123737[/import]

thanks . it’s working … it is interesting because i found this post on forum
the problem was whit the logic of when i was updating and when i needed to cal the function

so the code is here if someone needs it

function move(obj)

if obj.path then
local pos =1
local temp=obj
local objectPath=obj.path
temp.x=objectPath[pos].x

local function increment()

temp.x=objectPath[pos].x
temp.y=objectPath[pos].y
pos=pos+1
end
moveTIME=timer.performWithDelay( 10, increment, #objectPath )

end
end

function EnemysOnPath()
for k = 1, 1 do
enemysTable[k]=creatNew(object,10)

move(enemysTable[k])
end
end

thank you again…
i am beginning to understand corona …yupeee… [import]uid: 169726 topic_id: 30920 reply_id: 123804[/import]

Try and post code inside < lua > and < /lua > tags without the spaces :wink:

That said - fantastic! Thank you for sharing code :slight_smile: [import]uid: 52491 topic_id: 30920 reply_id: 123854[/import]

ok i will do so when i post my code :smiley:
and yes i am whit that mentality that code sharing is help full a lot :smiley: so i will share in future [import]uid: 169726 topic_id: 30920 reply_id: 123932[/import]