Android Open Source - android_game_engine Text






From Project

Back to project page android_game_engine.

License

The source code is released under:

GNU General Public License

If you think the Android project android_game_engine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.es.engine.hud;
// w  w  w. j  av  a 2s .c  o  m
import android.graphics.Canvas;
import android.graphics.Paint;

import org.es.engine.graphics.utils.DrawTextUtils;
import org.es.engine.graphics.utils.DrawingParam;

/**
 * @author Cyril Leroux
 *         Created 02/03/14.
 */
public abstract class Text extends Control {

    private final DrawTextUtils.HorizontalAlign mHorizontalAlign;
    private final DrawTextUtils.VerticalAlign mVerticalAlign;
    private final Paint mPaint;

    private final String mStaticText;

    public Text(float xCoef, float yCoef, String staticText, DrawTextUtils.HorizontalAlign hAlign, DrawTextUtils.VerticalAlign vAlign, Paint paint) {
        super(xCoef, yCoef);

        mHorizontalAlign = hAlign;
        mVerticalAlign = vAlign;
        mPaint = paint;

        mStaticText = staticText;
    }

    /**
     * Draw the HUD element.
     * @param canvas The canvas on which to draw.
     * @param param Not used for the main HUD. Can not be null for other HUD elements.
     */
    @Override
    public void draw(Canvas canvas, DrawingParam param) {
        setBounds(DrawTextUtils.drawText(mStaticText + getText(), canvas,
                getXCoef() * canvas.getWidth(),
                getYCoef() * canvas.getHeight(),
                mHorizontalAlign, mVerticalAlign, mPaint));
    }

    protected abstract String getText();
}




Java Source Code List

com.google.example.games.basegameutils.BaseGameActivity.java
com.google.example.games.basegameutils.GameHelperUtils.java
com.google.example.games.basegameutils.GameHelper.java
com.google.example.games.basegameutils.ScreenUtils.java
org.es.engine.audio.Sound.java
org.es.engine.game_mechanic.DrawingThread.java
org.es.engine.game_mechanic.DrawingView.java
org.es.engine.graphics.animation.AnimationCallback.java
org.es.engine.graphics.animation.Animation.java
org.es.engine.graphics.animation.BitmapAnimation.java
org.es.engine.graphics.animation.SpriteSheetAnimation.java
org.es.engine.graphics.drawable.DrawableElement.java
org.es.engine.graphics.sprite.GenericSprite.java
org.es.engine.graphics.sprite.SpriteSheet.java
org.es.engine.graphics.sprite.Sprite.java
org.es.engine.graphics.utils.DrawTextUtils.java
org.es.engine.graphics.utils.DrawingParam.java
org.es.engine.hud.Button.java
org.es.engine.hud.Control.java
org.es.engine.hud.HUD.java
org.es.engine.hud.Text.java
org.es.engine.hud.ToggleButton.java
org.es.engine.toolbox.pathfinding.Node.java
org.es.engine.toolbox.pathfinding.ShortestPath.java