We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Thanks for the help so far, I'm just getting the hang of using Eclipse. Powerful stuff.
I cannot figure out why myBlob.move() doesn't have any effect.I did create an extra object in the main public class and it moves, but the other class does not.
I don't have any errors anymore and can't find anything online that helps me understand what's going on.
RotatingBlob.java:
package rotatingBlob;
import processing.core.*;
public class RotatingBlob extends PApplet {
Blob myBlob;
Blob myBlob2;
Blob myBlob3;
float xPos = 0.0f;
public void setup() {
size(1200, 400);
// initialize blob
myBlob = new Blob(this);
myBlob2 = new Blob(this);
myBlob3 = new Blob(this);
}
public void draw() {
frameRate(60);
background(255);
myBlob.display(255, width / 2, height / 2, 1);
myBlob.center();
myBlob.body();
myBlob.move();
myBlob2.display(155, width / 2, height - height / 4, 1);
myBlob2.center();
myBlob2.body();
myBlob2.move();
myBlob3.display(45, width / 2, height / 4, 1);
myBlob3.center();
myBlob3.body();
myBlob3.move();
ellipse(xPos, 200, 40, 40);
xPos = xPos + 1;
}
}
Blob.java:
package rotatingBlob;
import processing.core.PApplet;
public class Blob {
PApplet parent; // rendering selves onto parent PApplet
int c;
float xpos;
float ypos;
float xspeed;
float nVal;
float nVal2;
// initialize parent
Blob(PApplet p) {
parent = p;
}
// must always access processing functions with parent variable
// like this --> parent.method(argument, argument);
public void display(int _C, float _Xpos, float _Ypos, float _Xspeed) {
c = _C; // color(244);
xpos = _Xpos; // width/2;
ypos = _Ypos; // height/2;
xspeed = _Xspeed; // 1;
nVal = parent.random(0.001f,0.1f);
nVal2 = parent.random(0.001f,0.1f);
}
public void center() {
parent.rectMode(parent.CENTER);
parent.fill(c);
parent.rect(xpos, ypos, 5, 2);
}
public void ring(float radian, float w, float h, int grey) {
parent.noFill();
parent.rotate(parent.millis() * 0.001f * (parent.radians(radian)));
parent.stroke(grey);
parent.ellipse(0, 0, w, h);
}
public void body() {
nVal = nVal + .01f;
nVal2 = nVal + .05f;
float n = parent.noise(nVal) * 40;
float n1 = parent.noise(nVal) * 50 * parent.noise(nVal2);
parent.pushMatrix();
parent.translate(xpos, ypos);
parent.ellipseMode(parent.CENTER);
parent.pushMatrix();
ring(-270+n1, 40 + n, 55 + n1, 1533);
parent.popMatrix();
parent.pushMatrix();
ring(120+n1, 50 + n1, 40 + n, 150);
ring(45+n, 45 + n, 50 + n1, 155);
parent.popMatrix();
parent.popMatrix();
}
public void move() {
xpos = xpos + xspeed;
if (xpos > parent.width) {
xpos = 0;
}
}
}
Answers
I don't understand much Java outside Processing's fenced garden! X_X
But I believe the way you set out things above demands a:
starting point method, right? 8-X
Also don't forget invoking
PApplet.main(args);
within that to initialize Processing framework! \m/http://processing.org/tutorials/eclipse/
<edited because I figured out the problem but don't understand why it was a problem>
I turns out that I should have put all of my parameters and arguments in the Blob parent class, not in a function within that class. The code is below - I trimmed out several lines to make it easy to look over the changes.
Wrong - as in not working:
RotatingBlob.java
Blob.java
Right - as in working:
RotatingBlob.java
Blob.java
The thing I don't understand is why, can someone please enlighten me?