We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone. I am pretty new to processing, and i want to know if it is possible to translate a class to wherever mouseX is? I have tried using the translate command but it says "unexpected token: 200" on line 12. If someone could link me somewhere or answer this that would be great! Thank you! :D
void setup()
{
size(1500,1000);
ellipseMode(CENTER);
stroke(0);
}
void draw()
{
public class robot
{
ellipse(200,300,400,500);
noFill();
bezier(800, 20, 800, 20, 800, 340, 400, 340);
bezier(800, 20, 800, 20, 800, 340, 400, 300);
line(800, 20, 900, 30);
line(800, 20, 800, 0);
line(800, 20, 700, 10);
ellipse(130,150,100,100);
ellipse(270,150,100,100);
}
robot translate(mouseX,mouseX);
}
Answers
This syntax doesn't really make sense, and it doesn't make sense to "translate a class".
Why are you declaring a class inside a function? Why do you have function calls (rather than function definitions) inside that class?
What exactly are you trying to do?
I want to move the entire shape formed in the robot class over to where mouseX is
The best way to do this is to parameterize what you're drawing. Use variables whose values you can change instead of hard-coded numbers like you're using now. I wrote a tutorial on this here: http://staticvoidgames.com/tutorials/basicConcepts/Variables.jsp
You just need correct syntax and order of call:
Note: I replaced your second mouseX with a mouseY...