We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I wanted to make a life counter for a trading card game, I got it to work on my computer, but as soon as I load it onto my phone (Android Razr, running Android version 4.1.2), it crashes and a window pops up on the the phone that says that it stopped. Here's my code:
import g4p_controls.*;
GImageButton pOnePlusOne, pOnePlusFive, pOneMinusOne, pOneMinusFive, pTwoPlusOne, pTwoPlusFive, pTwoMinusOne, pTwoMinusFive; String[] files; float h, w; PFont font; int pO, pT;
void setup(){ //size(displayWidth, displayHeight); //orientation(LANDSCAPE); textAlign(CENTER, CENTER); font = loadFont("FlemishScriptBT-Regular-90.vlw"); textFont(font); pO = 20; pT = 20; w = width; h = height;
files = new String[]{ "minusFive.png", "minusFive.png", "minusFiveC.png" }; pOneMinusFive = new GImageButton(this, w * .25, h / 1.5, .25 * w, h / 3, files); pTwoMinusFive = new GImageButton(this, w * .75, h / 1.5, .25 * w, h / 3, files);
files = new String[]{ "minusOne.png", "minusOne.png", "minusOneC.png" }; pOneMinusOne = new GImageButton(this, 0, h / 1.5, .25 * w, h / 3, files); pTwoMinusOne = new GImageButton(this, .5 * w, h / 1.5, .25 * w, h / 3, files);
files = new String[]{ "plusFive.png", "plusFive.png", "plusFiveC.png" }; pOnePlusFive = new GImageButton(this, .25 * w, 0, .25 * w, h / 3, files); pTwoPlusFive = new GImageButton(this, .75 * w, 0, .25 * w, h / 3, files);
files = new String[]{ "plusOne.png", "plusOne.png", "plusOneC.png" }; pOnePlusOne = new GImageButton(this, 0, 0, w * .25, h / 3, files); pTwoPlusOne = new GImageButton(this, .5 * w, 0, w * .25, h / 3, files); }
void draw(){ background(#9D2C2C); strokeWeight(3); line(w/2, 0, w/2, h); text("Player 1\n" + pO, w/4,h/2 + 5); text("Player 2\n" + pT, w * .75, h/2 + 5); }
void handleButtonEvents(GImageButton button, GEvent event){ if(button == pOneMinusFive){ pO = pO - 5; } else if(button == pOneMinusOne){ pO = pO - 1; } else if(button == pOnePlusFive){ pO = pO + 5; } else if(button == pOnePlusOne){ pO = pO + 1; } else if(button == pTwoMinusFive){ pT = pT - 5; } else if(button == pTwoMinusOne){ pT = pT - 1; } else if(button == pTwoPlusFive){ pT = pT + 5; } else if(button == pTwoPlusOne){ pT = pT + 1; } }
thank you. And I'm pretty sure it's not my JDK or anything, I can get simple programs to run on it.
Comments
G4P is not compatible with Android mode
Alright, thank you.
for android gui you can use the apwidgets library
thank you akenaton
I just recently got around to trying to find the apwidgets library, and I can't seem to find it in the libraries page of processing, how should I go about getting it?
@sparkyjohn This question has been answered if you have questions about another library please start a new discussion. This one is now closed.