Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpSyntax › Processing code ---> Wiring

Page Index Toggle Pages: 1
Processing code ---> Wiring (Read 4133 times)
02/21/07 at 00:39:56

roy_pardi   Offline
YaBB Newbies
Boston USA

Posts: 49
*
 
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

 
IP Logged
 
Reply #1 - 02/21/07 at 01:04:18

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
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
 
IP Logged
 
Reply #2 - 02/21/07 at 16:40:11

roy_pardi   Offline
YaBB Newbies
Boston USA

Posts: 49
*
 
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..   Undecided

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



 
IP Logged
 
Page Index Toggle Pages: 1