[Tutor] 'sphere' object is unindexable

Mr Gerard Kelly s4027340 at student.uq.edu.au
Fri Feb 6 09:37:38 CET 2009


I am trying to get around the problem of sphere object being unindexable.

I need to make spheres appear, positioned according to some list, for
example:

for i in [0,1]:
  sphere(pos=(0,i,0), radius=0.1)
  

Is there any way of making these different spheres behave differently
without using indexing?

For example, I would like to be able to make the lower sphere go red
when it is clicked on, using this fragment of code:

while True:
  if scene.mouse.events:
    m = scene.mouse.getevent()
    if m.pick is ball[0]:
      ball[0].color = color.red

But obviously it won't work because I haven't named it ball[0]. I can't
figure out a way to name the objects based on their position without
using indexing. Is there any way to do this?

Thank you.


More information about the Tutor mailing list