Transition.to within a Loop HELP!!! DESPERATE FOR HELP!!!

i do not know what is wrong here im at my whits end. it has taken me a long time to get all this together and i just cannot make it work. please help. modify it and reply it suggest problems. anything laugh at me for doing this in a crap way.

i wanna use the loop to get each item name out of a table, then u want to use transition.to to send the main actor to the item, then continue on to the next one. HELP PLES!!!!!

much appreciated.

HERE IS THE CODE

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
local physics = require("physics")
physics.start()
physics.setGravity( 0, 0)
physics.setDrawMode( "hybrid" )
 
local background = display.newRect(0,0,320,480)
background:setFillColor(255,50,0)
 
 
local Yaxis = display.newLine(160,0,160,480)
local Xaxis = display.newLine(0,240,320,240)
 
-- 4 nodes 1 in each corner type thing
 
--node Top Left
 
local tlNode = display.newRect(60,100,20,20)
 
--node top right
 
local trNode = display.newRect(240,100,20,20)
 
--node bottom Left
 
local blNode = display.newRect(60,400,20,20)
 
--node bottom right
 
local brNode = display.newRect(240,400,20,20)
 
-- new nodes to be used in my dynamic follow the points function
 
local Node1 = display.newRect(60,350,20,20)
local Node2 = display.newRect(110,400,20,20)
 
 
-- create the Seeker
 
local seeker = display.newImage("arrow.png")
 
physics.addBody( seeker, "static")
 
seeker.isSensor = true
 
local seekertail = display.newCircle(60, 20, 10)
 
physics.addBody( seekertail, "dynamic")
 
seekertail.isSensor = true
 
local tail = physics.newJoint( "pivot", seekertail, seeker, seeker.x, seeker.y)
 
 
local loop = 1
local called = 1
local name
local travels = {}
 
table.insert(travels, "tlNode")
table.insert(travels, "trNode")
table.insert(travels, "brNode")
table.insert(travels, "blNode")
 
local function driveThePoints()
while loop <= #travels do
if loop == #travels then
 
name = travels[called]
 
local mover = function()
print("mover number "..called.." called, MOVE TO "..name)
nxtnum = called + 1
name = travels[nxtnum]
called = called + 1
end
timer.performWithDelay(loop * 2000 - 2000, mover, 1)
print("transition.to( seeker, {delay="..loop * 2000 - 2000 ..",time= 2000, x="..travels[loop]..".x, y="..travels[loop]..".y, onComplete=driveThePoints})")
print("will now start again")
 
else
name = travels[called]
 
mover = function()
print("mover number "..called.." called, MOVE TO "..name)
print("transition.to( seeker, {time= 2000, x="..travels[called]..".x, y="..travels[called]..".y})")
transition.to( seeker, {time= 1000, x=travels[called].x, y=travels[called].y})
 
 
nxtnum = called + 1
name = travels[nxtnum]
called = called + 1
end
timer.performWithDelay(loop * 2000 - 2000, mover, 1)
 
print("will travel to : "..travels[loop])
print("transition.to( seeker, {delay="..loop * 2000 - 2000 ..",time= 1000, x="..travels[loop]..".x, y="..travels[loop]..".y})")
print("then travels to ...")
end
loop = loop + 1
end
 
end
 
driveThePoints()

Problem solved guys hahahahaha im an idiot.

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
local physics = require("physics")
physics.start()
physics.setGravity( 0, 0)
physics.setDrawMode( "hybrid" )
 
local background = display.newRect(0,0,320,480)
background:setFillColor(255,50,0)
 
 
local Yaxis = display.newLine(160,0,160,480)
local Xaxis = display.newLine(0,240,320,240)
 
-- 4 nodes 1 in each corner type thing
 
--node Top Left
 
local tlNode = display.newRect(60,100,20,20)
 
--node top right
 
local trNode = display.newRect(240,100,20,20)
 
--node bottom Left
 
local blNode = display.newRect(60,400,20,20)
 
--node bottom right
 
local brNode = display.newRect(240,400,20,20)
 
-- new nodes to be used in my dynamic follow the points function
 
local Node1 = display.newRect(60,350,20,20)
local Node2 = display.newRect(110,400,20,20)
 
 
-- create the Seeker
 
local seeker = display.newImage("arrow.png")
 
physics.addBody( seeker, "static")
 
seeker.isSensor = true
 
 
 
 
local loop = 1
local called = 1
local name
local travelsx = {}
local travelsy = {}
 
 
local again1 = 1
 
 
 
 
travelsx[1] =  tlNode.x
travelsx[2] = trNode.x
travelsx[3] = brNode.x
travelsx[4] = blNode.x
 
travelsy[1] =  tlNode.y
travelsy[2] = trNode.y
travelsy[3] = brNode.y
travelsy[4] = blNode.y
 
local start = 1
 
local function finished()
print("called the function that finishes the loop")
timer.performWithDelay(1,start,1)
end
 
local function driveThePoints()
while loop <= #travelsx + 1 do
if loop == #travelsx + 1 then
 
name = travelsx[called]
 
local mover = function()
print("mover number "..called.." called, MOVE TO ")
 
transition.to( seeker, {time= 2000, x=travelsx[called], y=travelsy[called], onComplete=finished})
 
 
end
timer.performWithDelay(loop * 2000, mover, 1)
print("will now start again")
 
else
name = travelsx[called]
 
mover = function()
print("mover number "..called.." called, MOVE TO "..name)
print("transition.to( seeker, {time= 2000, x="..travelsx[called]..", y="..travelsy[called].."})")
transition.to( seeker, {time= 2000, x=travelsx[called], y=travelsy[called]})
 
 
nxtnum = called + 1
name = travelsx[nxtnum]
called = called + 1
end
timer.performWithDelay(loop * 2000, mover, 1)
 
print("will travel to : "..travelsx[loop])
print("transition.to( seeker, {delay="..loop * 2000 - 2000 ..",time= 1000, x="..travelsx[loop]..", y="..travelsy[loop].."})")
print("then travels to ...")
end
loop = loop + 1
end
 
end
 
driveThePoints()
 
start = function()
print("START CALLED")
loop = 1
called = 1
name = 1
driveThePoints()
print("drive the points called again")
end
 
 
 
 
 
--lets make the seeker move around the screen infinitely
 
--step 1 make it shift to the TL node
--[[
local SKRTL = nil
 
local function seekertoBL()
seeker:rotate( 90 )
transition.to( seeker, {time=1000, x=blNode.x, y=blNode.y, onComplete=SKRTL})
end
 
local function seekertoBR()
seeker:rotate( 90 )
transition.to( seeker, {time=2000, x=brNode.x, y=brNode.y, onComplete=seekertoBL})
end
 
local function seekertoTR()
seeker:rotate( 90 )
transition.to( seeker, {time=1000, x=trNode.x, y=trNode.y, onComplete=seekertoBR})
end
 
local function seekertoTL()
seeker:rotate( 90 )
transition.to( seeker, {time=2000, x=tlNode.x, y=tlNode.y, onComplete=seekertoTR})
end
 
seekertoTL()
 
SKRTL = seekertoTL
 
]]--
 
 
<code>
views:1969 update:2011/9/25 12:40:18
corona forums © 2003-2011