Hello everyone,
I’m hoping to get some help. I’m trying to get a number of objects to orbit themselves (they a part of the same array). I’ve programmed this before in Canvas and java and it always works. But for some reason in Corona the objects fly away in a perfect 45 degree angle. This even happens if I have the v.g (pulling value) as a random value. They fly away just the same.
now if I set this line in the code they orbit around 300x 300y just fine.
v3.xd = (v2.x-v3.x); ---\> to v3.xd = (300-v3.x);
v3.yd = (v2.y-v3.y); ---\> to v3.yd = (300-v3.y);
Full orbit code below
[code]
–add an any array in called object
local function Object_Functions ()
for i,v2 in ipairs(object) do
for i,v3 in ipairs(object) do
v3.x=(v3.x+v3.xv);
v3.y=(v3.y+v3.yv);
v3.xd = (v2.x-v3.x);
v3.yd = (v2.y-v3.y);
v3.d2 = (v3.xd * v3.xd)+(v3.yd * v3.yd);
v3.xf = (v3.xd/v3.d2);
v3.yf = (v3.yd/v3.d2);
v3.xv = (v3.xv+v3.xf*(v.g));
v3.yv = (v3.yv+v3.yf*(v.g));
end
end
end
[/code] [import]uid: 80591 topic_id: 13771 reply_id: 313771[/import]