After a few months of feeling a little intimidated by codea, I’ve decided to gather some courage and tackle a little project.
Right now, I’m blocked at a little problem. I’m creating circles upon touches, no problem so far, an example shows exactly that. I’m now trying to do things with these individual circles, but I can’t figure out how to call them.
So here’s my first question: where and how to assign an Id to each individual object, so I can later do stuff with them? Somewhere there: circle = physics.body(CIRCLE, r) ?
If you’re dealing with many circles, toss them circles into a table:
circles = {}
circle = physics.body(CIRCLE, r)
table.insert(circles, circle)
--then to access them you can use a for loop
for i,v in pairs(circles) do
do stuff to circle using v as the circle and i as its index in the circles table
end