Merge branch 'master' of github.com:EsotericSoftware/spine-runtimes into Trompo-JS-AtlasAttachmentLoader

This commit is contained in:
Dario Segura 2014-12-01 14:58:55 -05:00
commit 145aed328e
3 changed files with 28 additions and 14 deletions

View File

@ -211,7 +211,7 @@ public class Box2DExample extends ApplicationAdapter {
// Next we create the 50 box bodies using the PolygonShape we just
// defined. This process is similar to the one we used for the ground
// body. Note that we reuse the polygon for each body fixture.
for (int i = 0; i < 20; i++) {
for (int i = 0; i < 45; i++) {
// Create the BodyDef, set a random position above the
// ground and create a new body
BodyDef boxBodyDef = new BodyDef();

View File

@ -58,6 +58,8 @@ public class SkeletonRendererDebug {
private boolean drawMeshHull = true, drawMeshTriangles = true;
private final SkeletonBounds bounds = new SkeletonBounds();
private float scale = 1;
private float boneWidth = 2;
private boolean premultipliedAlpha;
public SkeletonRendererDebug () {
shapes = new ShapeRenderer();
@ -72,21 +74,27 @@ public class SkeletonRendererDebug {
float skeletonY = skeleton.getY();
Gdx.gl.glEnable(GL20.GL_BLEND);
int srcFunc = premultipliedAlpha ? GL20.GL_ONE : GL20.GL_SRC_ALPHA;
Gdx.gl.glBlendFunc(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA);
ShapeRenderer shapes = this.shapes;
shapes.begin(ShapeType.Line);
Array<Bone> bones = skeleton.getBones();
if (drawBones) {
shapes.setColor(boneLineColor);
shapes.begin(ShapeType.Filled);
for (int i = 0, n = bones.size; i < n; i++) {
Bone bone = bones.get(i);
if (bone.parent == null) continue;
float x = skeletonX + bone.data.length * bone.m00 + bone.worldX;
float y = skeletonY + bone.data.length * bone.m10 + bone.worldY;
shapes.line(skeletonX + bone.worldX, skeletonY + bone.worldY, x, y);
shapes.rectLine(skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, boneWidth * scale);
}
shapes.end();
shapes.begin(ShapeType.Line);
shapes.x(skeletonX, skeletonY, 4 * scale);
}
} else
shapes.begin(ShapeType.Line);
if (drawRegionAttachments) {
shapes.setColor(attachmentLineColor);
@ -207,4 +215,8 @@ public class SkeletonRendererDebug {
public void setMeshTriangles (boolean meshTriangles) {
this.drawMeshTriangles = meshTriangles;
}
public void setPremultipliedAlpha (boolean premultipliedAlpha) {
this.premultipliedAlpha = premultipliedAlpha;
}
}

View File

@ -232,16 +232,18 @@ public class SkeletonViewer extends ApplicationAdapter {
ui.stage.draw();
// Draw indicator for timeline position.
ShapeRenderer shapes = debugRenderer.getShapeRenderer();
TrackEntry entry = state.getCurrent(0);
if (entry != null) {
float percent = entry.getTime() / entry.getEndTime();
if (entry.getLoop()) percent %= 1;
float x = ui.window.getRight() + (Gdx.graphics.getWidth() - ui.window.getRight()) * percent;
shapes.setColor(Color.CYAN);
shapes.begin(ShapeType.Line);
shapes.line(x, 0, x, 20);
shapes.end();
if (state != null) {
ShapeRenderer shapes = debugRenderer.getShapeRenderer();
TrackEntry entry = state.getCurrent(0);
if (entry != null) {
float percent = entry.getTime() / entry.getEndTime();
if (entry.getLoop()) percent %= 1;
float x = ui.window.getRight() + (Gdx.graphics.getWidth() - ui.window.getRight()) * percent;
shapes.setColor(Color.CYAN);
shapes.begin(ShapeType.Line);
shapes.line(x, 0, x, 20);
shapes.end();
}
}
}