Line
In this example you will draw a simple line on your Android phone display.
-
First of all you have to enable USB debugging on your Android phone. The settings look different in different phones but you should be able to turn USB debugging on if you go to Settings > Developer options > Debugging > USB debugging, or something similar.
-
Connect the phone to your Computer. Make sure your phone says “USB debugging connected.”
-
Open Processing in android mode and write the following code: line
- Click run icon and the program will now be executed on your phone.
size(displayWidth, displayHeight); line(0, 0, displayWidth, displayHeight);
New Commands
displayWidth
: Returns the width of the display you are using.displayHeight
: Returns the height of the display you are using.
The sketch is saved on your phone so you can open it again.
Red Snake
In this example you will run the Red Snake program on your Android phone.
- Open Red Snake step 6
-
Change the size to
size(displayWidth, displayHeight)
- Run the code
As you can see you can still use mouseX
and mouseY
. Instead of returning the mouse coordinates they will return the coordinates of your finger on the display.
Find more information in english about the Processing Android mode here: https://github.com/processing/processing-android/wiki