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.
– 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)[/lua]
in my example, the enemy moved to the next waypoint, when you touch the display. [import]uid: 42078 topic_id: 7941 reply_id: 28433[/import]
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.
[import]uid: 24 topic_id: 7941 reply_id: 28680[/import]