Can I use the G4P library (GUI) in Android mode? And if so could you help?

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.

Tagged:

Comments

This discussion has been closed.