Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

permanent images in android studio

$
0
0

Hi everybody! I have started using android studio. When i try to run sketches there, if i put a rect in draw() for example it remains forever in that position even if i change it's coordinates. Do you have any idea what i am missing? I have followed steps described in tutorial "Developing with Android Studio". Here is a code example:

public class Sketch2 extends PApplet {

 ball MainBall;//= new ball();

public void settings() {
    size(600, 600,P2D);
    //fullScreen();

}

public void setup() {
    background(150,50,50);
   // MainBall= new ball();
    //MainBall.display();

w10 = width/10; System.out.println("K: "+k); }

int k,w10,rh=10;
public void draw() {

    if(MainBall!=null){
        MainBall.display();
        MainBall.fingerForce();
    }

    fill(30,60,k);
    rect(random(0,width),rh,80,30);

//HERE THERE WLL APPEAR ONE RECT FOR EACH LOOP //sphere(30);

/*    if(mousePressed){ rh+=40;
        rect(random(0,width),random(0,height),random(0,40),random(0,40));
        System.out.println("MPPPPPPPP");
    }*/

    if((k+=10) < 255)
    k+=10;
    else k=0;
}

@Override
public void mouseClicked() {
    super.mouseClicked();
    System.out.println("mouseClicked");
    println("println");
}

class ball {
    private int R;
    PVector coord;
    PVector fingerVector;

    ball(){
        R=30;
        this.coord= new PVector (130, 50);
        fingerVector =new PVector(2,2);

    }
    ball(int R){
        this.R = R;
        this.coord= new PVector (width/2, height/4);
        fingerVector =new PVector(0,0);
    }
    void fingerForce(){
        if(mousePressed){
            fingerVector.add(mouseX-pmouseX,mouseY-pmouseY,0);
            coord.x +=2;
            coord.y+=1;
        }
       // coord.add(fingerVector);
    }

    void display(){
        //pushMatrix();
       // translate(this.coord.x,this.coord.y);
        sphere(this.R);
        //rect(100,20,80,80);

       // popMatrix();

        rect(this.coord.x+20,this.coord.y+20,10,10);
    }



}

}

Additional info: same thing happens when using P3D or using none of them. here something from gradle if matters anything
minSdkVersion 15 targetSdkVersion 23 maxSdkVersion 25


Viewing all articles
Browse latest Browse all 941

Trending Articles