public void draw(SpriteBatch sb) { sb.drawSprite( mAnimation.getFrame(), mPhysics.getX() + mDrawOffsetX, mPhysics.getY() + mDrawOffsetY, mDrawWidth, mDrawHeight); }
// --Draw Text--// // D: draw text at the specified x,y position // A: text - the string to draw // x, y - the x,y position to draw text at (bottom left of text; including descent) // R: [none] public void draw(String text, float x, float y) { float chrHeight = cellHeight * scaleY; // Calculate Scaled Character Height float chrWidth = cellWidth * scaleX; // Calculate Scaled Character Width int len = text.length(); // Get String Length x += (chrWidth / 2.0f) - (fontPadX * scaleX); // Adjust Start X y += (chrHeight / 2.0f) - (fontPadY * scaleY); // Adjust Start Y for (int i = 0; i < len; i++) { // FOR Each Character in String int c = (int) text.charAt(i) - CHAR_START; // Calculate Character Index (Offset by First Char in Font) if (c < 0 || c >= CHAR_CNT) // IF Character Not In Font c = CHAR_UNKNOWN; // Set to Unknown Character Index batch.drawSprite(x, y, chrWidth, chrHeight, charRgn[c]); // Draw the Character x += (charWidths[c] + spaceX) * scaleX; // Advance X Position by Scaled Character Width } }
// --Draw Font Texture--// // D: draw the entire font texture (NOTE: for testing purposes only) // A: width, height - the width and height of the area to draw to. this is used // to draw the texture to the top-left corner. public void drawTexture(int width, int height) { batch.beginBatch(textureId); // Begin Batch (Bind Texture) batch.drawSprite( textureSize / 2, height - (textureSize / 2), textureSize, textureSize, textureRgn); // Draw batch.endBatch(); // End Batch }