We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I had tried using the sample/tutorial given by Jer Thorp and had tried implementing it on Eclipse ADT. I had imported the android-core.jar from the processing 2.0 into the Eclipse Libs folder. However when I copied the sample codes into Eclipse ADT, it highlights the "background(mouseY * (255.0/800), 100, 0);" in the "draw method as below and state that "The method background(int, float) in the type PApplet is not applicable for the arguments (double, int, int)".
public void draw() {
//Set the background colour, which gets more red as we move our finger
//down the screen.
background(mouseY * (255.0/800), 100, 0);
//Chane our box rotation depending on how our finger has moved right-to-left
boxRotation += (float) (pmouseX - mouseX)/100;
//Draw the ball-and-stick
line(width/2, height/2, mouseX, mouseY);
ellipse(mouseX, mouseY, 40, 40);
//Draw the box
pushMatrix();
translate(width/2, height/2);
rotate(boxRotation);
rect(0,0, 150, 150);
popMatrix();
};
And if I change the code from"255.0" to "255" such as "background(mouseY * (255/800), 100, 0);", the emulator can execute the application successfully using Eclipse ADT, however the colouring functionality when I hover around will be lost. Could anyone please help me or teach me how to fix this ?
Thanking you in anticipation.
Answers
I followed the tutorial from this link http://blog.blprnt.com/blog/blprnt/processing-android-mobile-app-development-made-very-easy
Moved to the Android category.
In Processing PDE, all numbers like 255.0 are float numbers. In classical Java, thus in Eclipse, these are double numbers. Hence the error message you got. Just cast the first parameter to an int.
I have tried casting the first parameter to an int as in background(mouseY * (int)(255.0/800), 100, 0);
however this had cause it to lose its functionality when I tested in the emulartor
You must cast the entire value to an
int,
not just part of it. In other words, you must move the cast to outside a set of parentheses, e.g:Or, perhaps more simply, you can declare
255.0
to be afloat
by adding an "f" to the end:YAY! it worked , Thank you! :)