From: CL <clc...@gm...> - 2009-02-06 09:05:11
|
You can simply assign the sphere object to a variable and reference it later. e.g.: from visual import * ball=[] for i in [0,1]: s=sphere(pos=(0,i,0), radius=0.1) ball.append(s) while True: if scene.mouse.events: m = scene.mouse.getevent() if m.pick is ball[0]: ball[0].color = color.red if m.pick is ball[1]: ball[1].color = color.blue > Message: 9 > Date: Fri, 06 Feb 2009 18:37:38 +1000 > From: Mr Gerard Kelly <s40...@st...> > Subject: [Visualpython-users] 'sphere' object is unindexable > To: "vis...@li..." > <vis...@li...> > Cc: "tu...@py..." <tu...@py...> > Message-ID: <d40...@uq...> > Content-Type: text/plain; charset=us-ascii > > 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. > > > > ------------------------------ > > ------------------------------------------------------------------------------ > Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) > software. With Adobe AIR, Ajax developers can use existing skills and code to > build responsive, highly engaging applications that combine the power of local > resources and data with the reach of the web. Download the Adobe AIR SDK and > Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com > > ------------------------------ > > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > > > End of Visualpython-users Digest, Vol 33, Issue 2 > ************************************************* > |