We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Is there an equivalent of the universal array
Page Index Toggle Pages: 1
Is there an equivalent of the universal array (Read 407 times)
Is there an equivalent of the universal array
Nov 27th, 2007, 12:29am
 
I am very much used to programming in Lua and even more so on the PSP. In processing i am trying to recreate a snow fall effect which I had gotten perfect on the PSP. Basically im looking for a way to create a universal array which can hold functions, ints, floats, and even text. Classes won't work for me since I used to create an array to hold a bunch of nameless arrays which I referenced to and accessed with an index number and they acted like classes (access with the . operator). Im not too great with classes... =\ Please help.
Re: Is there an equivalent of the universal array
Reply #1 - Nov 27th, 2007, 12:51am
 
An ArrayList can hold any type of object. However a function is not an object, so you can't store just a function.

And it could be difficult working out what exactly you're getting from an ArrayList, since it re-orders itself if you remove something from the middle.

I think that TBH, it might be better for you to not try to directly port your PSP code in, as it doesn't really fit the Java model. There's much better ways of doing it in Processing/Java, and you might be better off learning them for future use, rather than having to use some less clean ways of gettign around it.
Re: Is there an equivalent of the universal array
Reply #2 - Nov 27th, 2007, 2:37am
 
Well I found my original and I had converted it to near Java standards. My biggest problem is getting specific variables from the array. Like before I used uni[count].x to get the x value of the current snowflake (count) int the universe (uni). Im thinking of taking a crack at spontaneously creating classes and see how far I get. I can just create array places like the [0] = .x [1] = .y but that's not as fun.

A question about the ArrayList though. Can I assign specific vars in it like I would Lua. Like the example above. would i be able to access them with a . operator or something similar?
Page Index Toggle Pages: 1