package com.ef.smallstar.unitmap.widget;
import android.content.res.Resources;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.ef.smallstar.EFApplication;
import com.ef.smallstar.R;
/**
* Created by ext.danny.jiang on 17/4/17.
*
* A Widget currently used in the UnitMap, shown as a CIRCLE shape
* if text not null, there would be a text drawn in the center of the circle
*/
public class CircleActor extends Actor {
private float centerX;
private float centerY;
private String text;
private float radius;
private ShapeRenderer sr;
private BitmapFont bitmapFont;
public CircleActor(float x, float y, float radius) {
this(x, y, radius, null);
}
public CircleActor(float x, float y, float radius, String text) {
this.centerX = x;
this.centerY = y;
this.radius = radius;
this.text = text;
sr = new ShapeRenderer();
}
@Override
public void act(float delta) {
super.act(delta);
}
@Override
public void draw(Batch batch, float parentAlpha) {
...
batch.end();
sr.setProjectionMatrix(batch.getProjectionMatrix());
sr.setTransformMatrix(batch.getTransformMatrix());
sr.begin(ShapeRenderer.ShapeType.Filled);
sr.circle(centerX, centerY, radius);
sr.end();
batch.begin();
...
}
Stage stage = new Stage();
CircleActor ca = new CircleActor(100, 100, 50, "Hello World");
ca.addListener(new ClickListener(){
public void click(){
Gdx.app.log("TAG", "ca is clicked");
}
})
stage.add(ca);
sr.setProjectionMatrix(batch.getProjectionMatrix()); sr.setTransformMatrix(batch.getTransformMatrix());
public EfCircle(float x, float y, float radius, String text) {
this.centerX = x;
this.centerY = y;
this.radius = radius;
this.text = text;
//解决ShapeRenderer无法获取Touch事件
setPosition(centerX - radius, centerY - radius);
setSize(radius * 2, radius * 2);
sr = new ShapeRenderer();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有