Does the PVector.add() - Method not work in the Android Mode?

edited March 20 in Android Mode

Hello Processing community,

when I'm trying to run this code in Android mode, i get a error message:

PVector Vec;
void setup(){
  Vec = new PVector(0, 0);
}

void draw(){
  Vec.add(1, 1);
}

In the Java mode it works just fine. Is is a bug or do i have to redownload Processing? I have already redownloaded the Android mode. I know that i could just use Vec.x += 1; Vec.y += 1;, but I thought I would tell you guys, because the problem isn't listed here: android.processing.org/reference/gone.html

Sorry for my bad English and thanks for the answers

Answers

  • edited March 20

    source is here and add() appears to still be there:

    https://github.com/processing/processing-android/blob/master/core/src/processing/core/PVector.java#L456

    i get a error message

    what does the error message say?

    note that the signature takes floats and you are adding ints.

    Vec.add(1.0, 1.0);
    

    Vec should be vec btw, classes start with uppercase, variables with lowercase

  • It says "The function "add()" expects parameters like: "add(PVector, PVector)" Nothing changes when I write "1.0" istead of "1".

  • Try add(Vec, new PVector(1, 1));

  • edited March 21

    Please check the reference. Basically what the error says is that you are using a form of add that is not recognized.

    There are two ways to add vectors:

    PVector xx=new Pvector(100,100);
    PVector yy=new Pvector(200,200);
    PVector zz=Pvector.add(xx,yy);   //Working from a static function provided by the class PVector
    

    OR you can add directly to one PVector object:

     yy.add(xx);  //Now yy and zz have the same value.
    

    Kf

  • Answer ✓

    That's what I just said.

    Problemhaber said, "It says "The function "add()" expects parameters like: "add(PVector, PVector)" Nothing changes when I write "1.0" istead of "1".".

    This means you're trying to use the PVector.add(PVector, PVector); function. Which means you should be adding a new PVector(1, 1) to your original Vec, giving you PVector.add(Vec, new PVector(1, 1)); this will work for what you are asking.

    The other option is Vec.add(new PVector(1, 1)); if that is easier for you.

  • it's definitely in the source, see the link i posted.

    it was only added in january though so if you're using an older version of processing then it won't be there.

  • the 3 parameter version has been there for a while though. try

    vec.add(1, 1, 0);
    
  • Thanks for your many answers. vec.add(new PVector(1, 1)); and vec.add(1, 1, 0); and vec = PVector.add(vec, new PVector(1, 1)); work for me.

Sign In or Register to comment.