Wiring Forum
http://wiring.org.co/cgi-bin/yabb/YaBB.pl
Programming Questions & Help >> Syntax >> Processing code ---> Wiring
http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1172018397

Message started by roy_pardi on 02/21/07 at 00:39:56

Title: Processing code ---> Wiring
Post by roy_pardi on 02/21/07 at 00:39:56
Hi,

I have a light sculpture I am running through Wiring but am trying to work out the pattern programming in Processing since I thought it would be a decent workflow.

I've read up on the differences (arrays etc.) between Processing + Wiring but have a couple of questions - basically the use of classes and storing instances in an array.

In Processing I have a class named PSprite; I declare an array to store my instances in:

     PSprite[] sArray = new PSprite[2];

and then in setUp() init some instances (showing just 1 here):

    PSprite s1 = new PSprite(6, 350.0, 350.0, 300.0, 1, "s1");
   sArray[0] = s1;

My class is working in Processing so I won't clutter this up with that code.

So back to my 2 questions: defining and initing classes: how do I do that in Wiring? Along with storing instances of them. In my array declaration above Wiring gives me the error the "PSprite does not name a type". - so it doesn't recognize my class.

Little help?

Thanks!  

--Roy


Title: Re: Processing code ---> Wiring
Post by barragan on 02/21/07 at 01:04:18
hi Roy, this is very similar to create a new library for Wiring, it will create a new data type as the PSprite you are creating. The syntax in wiring and Processing is quite different, this is because Processing is written in Java and Wiring is written in C++, so the way of creating new classes in Wiring will resemble the C++ syntax. There is a thread in the forum about creating a library, and Nicholas posted an example called a Hello World library here http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1144744422 so you can examine the code etc. Let me know.

There is also the Sprite library, I am not sure if that is what you're looking for as well, it is already here: http://wiring.org.co/reference/libraries/Sprite/index.html
You can check the Sprite library (class) source code browsing here: http://wiring.org.co/source

Title: Re: Processing code ---> Wiring
Post by roy_pardi on 02/21/07 at 16:40:11
thanks for the reply! I have been tinkering with the Test.cpp library this morning and am slowly making my Processing class into a lib. Feels like the deep end of the pool!

This question may be beyond the scope of Wiring help: my Processing class has a method called 'update' and when it's called, it does some business and then calls a global function: setSegmentState(int i, array a), passing an int & an array as args.

In Wiring/C++, if I want my class instances to call a function defined in my Wiring program then I guess I have to use #include and provide a definition- is that correct? (slight panic setting in..   :-/

I guess I could have the instance return some values to the 'update' call and then call 'setSegmentState' from within my Wiring program.




Wiring Forum » Powered by YaBB 2.5 AE!
YaBB Forum Software © 2000-2010. All Rights Reserved.