Package com.aqpproject.visualisation.gdx

Source Code of com.aqpproject.visualisation.gdx.TextActorGDX

/*
* AQP Project
* http://http://code.google.com/p/aqp-project/
* Alexandre Gomez - Clément Troesch - Fabrice Latterner
*/
package com.aqpproject.visualisation.gdx;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Actor;

/**
*
* @author Clément
*/
public class TextActorGDX extends Actor {

    public TextActorGDX(String name, String text, float size, float posX, float posY) {
        super(name);
        x = posX;
        y = posY;
        m_text = text;
        //Ces deux variable indiquent les fichier à utiliser pour la police / la taille, et la couleur (voir le
        //programme "hiero" que je vais (ou ai déjà) ajouté au repository (data/font -> 9Mo)
        //Voici les sept combinaisons que tu peux tester pour le moment :
        // "ar16ora" / "ar40deg" / "ar12whi" / "ar13whi" (défaut) / "ar14whi" /"ar15whi" / "inf16grey"
        //m_font = new BitmapFont();
        m_font = new BitmapFont(Gdx.files.internal("data/font/ar13whi.fnt"), Gdx.files.internal("data/font/ar13whi.png"), false); //TODO: change the font/size
        //m_font.scale(size);
    }

    public TextActorGDX(String name, String text, float size, float posX, float posY, String font) {
        super(name);
        x = posX;
        y = posY;
        m_text = text;

        if (font == null) {
            m_path = "ar13whi";
        } else {
            m_path = font;
        }

        m_font = new BitmapFont(Gdx.files.internal("data/font/" + font + ".fnt"), Gdx.files.internal("data/font/" + font + ".png"), false); //TODO: change the font/size
        //m_font.scale(size);
    }

    @Override
    public void draw(SpriteBatch sb, float f) {
        m_font.drawMultiLine(sb, m_text, x, y);
    }

    @Override
    public Actor hit(float f, float f1) {
        return x > 0 && x < width && y > 0 && y < height ? this : null;
    }

    public void setText(String text) {
        m_text = text;
    }

    public String getText() {
        return m_text;
    }

    public void setTextFont(String font) {
        m_path = font;
    }

    public void setAlpha(float alpha) {
        m_font.setColor(1, 1, 1, alpha);
    }
    protected String m_text;
    private String m_path;
    protected BitmapFont m_font;
}
TOP

Related Classes of com.aqpproject.visualisation.gdx.TextActorGDX

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.