Hey everyone, I've been having some trouble on this little project I've been working on. I am new to Lua and mobile game designing in general, but that isn't the issue on hand. What I'm trying to accomplish is a waypoint system, the best example I could give would be like a tower defense game. The enemies move on a certain path or to waypoints. I have my arrays.
1 2 | wp_x = { 20, 40, 60, 80, 100 } wp_y = { 100, 80, 60, 40, 20 } |
1 | transition.to(enem, { time = 2500, x=wp_x[2], y=wp_y[2] }) |
if enem.x == wp_x[1] then enem.x = wp_x[2] end
Hi.
i tried something.
perhaps it helps you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | -- waypoint test -- 110318,sidasa --local start_x = 0 --local start_y = 0 -- variables local start_x = display.contentWidth/2 local start_y = display.contentHeight/2 local i = 0 wp_x = { 20, 40, 60, 80, 100 } wp_y = { 100, 80, 60, 40, 20 } -- show image enemy = display.newImage("enemy.png") enemy.x = start_x enemy.y = start_y -- move image to next waypoint local function nextWaypoint () transition.to( enemy, { x=wp_x[i], y=wp_y[i] } ) end local function touched ( event ) print( "i: " .. i ) -- console test output if event.phase == "ended" then i = i+1 nextWaypoint() end end Runtime:addEventListener("touch", touched) |
Ok, this is hilarious, but please take this lightly.
My definition of waypoint way off..
See http://www.youtube.com/watch?v=TZ_AH4Iy-z4
A waypoint is commonly associated with GPS for inclusion of longitude, latitude and altitude.
So when I read the forum titile, then @amf.studios entry "am new to lua" .... and I been working with objects along a bezier path, here I was, oh, cool maybe I get motivated to do my bez example like the video above.
LOL !
I thought it was funny.
C.