Package com.aqpproject.visualisation.gdx

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

/*
* 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.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;

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

    public LineActorGDX(String name, float x1, float y1, float x2, float y2, Stage s) {
        super(name);
        x = x1;
        y = y1;
        m_x2 = x2;
        m_y2 = y2;
        m_stage = s;
    }

    @Override
    public void draw(SpriteBatch sb, float f) {
        ShapeRenderer shapeRenderer = new ShapeRenderer();
        sb.end();
        shapeRenderer.setProjectionMatrix(m_stage.getCamera().combined);
        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
        shapeRenderer.setColor(1, 1, 1, 1);
        shapeRenderer.line(x, y, m_x2, m_y2);
        shapeRenderer.end();
        sb.begin();

    }

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

    void setLine(float x1, float y1, float x2, float y2) {
        x = x1;
        y = y1;
        m_x2 = x2;
        m_y2 = y2;
    }
    private float m_x2;
    private float m_y2;
    private Stage m_stage;
}
TOP

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

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.