java - canvas.drawText() is not showing up in Android -
i'm trying write text screen using new method taking in of arguments needed draw text. text showing text being centered , showing directly in middle.
example:
//create texts writetext(canvas, "money: $" + player.getmoney(), paint.align.center, color.black, 25, (screenwidth / 2), 50); writetext(canvas, "mps: " + player.getmps(), paint.align.center, color.black, 25, (screenwidth / 2), 75); writetext(canvas, "mpc: " + player.getmpc(), paint.align.center, color.black, 25, (screenwidth / 2), 100); writetext(canvas, "cost: $" + player.gethouseupgradecost(), paint.align.right, color.black, 15, 0, (screenheight - buttonheight)); writetext(canvas, "cost: $" + player.getconstructionworkercost(), paint.align.center, color.black, 15, (screenwidth / 2), (screenheight - buttonheight)); writetext(canvas, "cost: $" + player.getbobcost(), paint.align.left, color.black, 15, screenwidth, (screenheight - buttonheight)); writetext(canvas, "cost: $" + player.getworkgroupcost(), paint.align.right, color.black, 15, 0, ((screenheight - (buttonheight * 3)))); writetext(canvas, "cost: $" + player.getbankcost(), paint.align.center, color.black, 15, (screenwidth / 2), ((screenheight - (buttonheight * 3)))); writetext(canvas, "cost: $" + player.getfactorycost(), paint.align.left, color.black, 15, (screenwidth), ((screenheight - (buttonheight * 3)))); writetext(canvas, "cost: $" + player.getsupertappingcost(), paint.align.right, color.black, 15, 0, ((screenheight - (buttonheight * 5)))); writetext(canvas, "cost: $" + player.getunlockstorecost(), paint.align.center, color.black, 15, (screenwidth / 2), ((screenheight - (buttonheight * 5)))); writetext(canvas, "cost: $" + player.getpropertycost(), paint.align.left, color.black, 15, (screenwidth), ((screenheight - (buttonheight * 5)))); } private void writetext(canvas canvas, string text, paint.align align, int color, int textsize, float x, float y) { //sets paint using values paint paint = new paint(); paint.settextalign(align); paint.setcolor(color); paint.settextsize(textsize); canvas.drawtext(text, x, y, paint); }
Comments
Post a Comment