Lamellama

  • 13 ноя 2014
  • Регистрация: 2 фев 2013

    ok I solved my problem

    		vertices[idx++] = x1;
    		vertices[idx++] = y1;
    		vertices[idx++] = color;
    		vertices[idx++] = u;
    		vertices[idx++] = v;
    
    	vertices[idx++] = x2;
    	vertices[idx++] = y2;
    	vertices[idx++] = color;
    	vertices[idx++] = u;
    	vertices[idx++] = v2;
    
    	vertices[idx++] = x3;
    	vertices[idx++] = y3;
    	vertices[idx++] = color;
    	vertices[idx++] = u2;
    	vertices[idx++] = v2;
    
    	vertices[idx++] = x4;
    	vertices[idx++] = y4;
    	vertices[idx++] = color;
    	vertices[idx++] = u2;
    	vertices[idx++] = v;

    I would start by labelling the 'head' part, then in your code you can find the head slot

    Slot slot = skeleton.findSlot("head");
    		   Attachment attachment = slot.getAttachment();
    		   if (attachment == null) continue;
    		   if (!(attachment instanceof RegionAttachment)) continue;
    		   RegionAttachment imageRegion = (RegionAttachment)attachment;
    		   imageRegion.updateVertices(slot);
    		   
    TextureRegion tex = imageRegion.getRegion();

    maybe you can turn the textureRegion into a physics object.

    I don't know how to remove the head though.

    • Изменено

    I am using this code to check for collisions

    if(new Polygon(imageRegion.getVertices()).contains(x, (-y + Globals.VIRTUAL_HEIGHT))){
    				collided = true;

    But I've discovered the vertice array has some null values and I don't understand the way they are stored in RegionAttachment class. How can I get a consecutive array of vertices for the imageRegion?

    Sorry I should have put this in the libGDX section.

    • Изменено

    I ran into a problem using Spine with Photoshop's export to layers script. The script adds numbers to the file-names which can change when you add any layers to your model which means Spline can't find them. Rather than rename each individual layer I discovered you can easily edit the "export to layers to files" script to not add the extra stuff to the file-name.

    http://graphicdesign.stackexchange.com/questions/10669/cs5-export-layers-as-files-no-number-sequence

    You have to use unique names for each of your layers else they will get overwritten.

    Thanks you are right. Github does not work as I expected and the source files were out of date.

    Sorry for wasting your time.

    I have updated to the latest nightlies and I am compiling the spine-libgdx from the github source but still having the problem

    • Изменено

    I have updated everything I can think of but I am getting this error.

    Exception in thread "LWJGL Application" java.lang.ClassCastException: com.badlogic.gdx.utils.JsonValue cannot be cast to com.badlogic.gdx.utils.OrderedMap
    at com.esotericsoftware.spine.SkeletonJson.readSkeletonData(SkeletonJson.java:88)

    I've made no change to the code, just updated the json

    Doh, thanks.

    I hadn't updated the gdx-backend-lwjgl jars

    So drawDebug draws with the bones

    • Изменено

    Hi, I am having a problem loading my animation into libgdx.

    When I run as a Java application I receive an error relating to the line:
    skeleton.drawDebug(renderer);
    If I comment this line out, the animation loads. What does drawDebug do? and why is it failing?

    Error:
    Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoSuchFieldError: Filled
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
    Caused by: java.lang.NoSuchFieldError: Filled
    at com.esotericsoftware.spine.Skeleton.drawDebug(Skeleton.java:142)
    at book.Game.render(Game.java:71)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:187)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)

    Source:

    package book;
    
    import com.esotericsoftware.spine.Animation;
    import com.esotericsoftware.spine.Bone;
    import com.esotericsoftware.spine.Skeleton;
    import com.esotericsoftware.spine.SkeletonData;
    import com.esotericsoftware.spine.SkeletonJson;
    
    import com.badlogic.gdx.ApplicationListener;
    import com.badlogic.gdx.Gdx;
    
    import com.badlogic.gdx.graphics.GL10;
    import com.badlogic.gdx.graphics.g2d.SpriteBatch;
    import com.badlogic.gdx.graphics.g2d.TextureAtlas;
    import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
    
    public class Game implements ApplicationListener {
    	SpriteBatch batch;
    	ShapeRenderer renderer;
    
    TextureAtlas atlas;
    Skeleton skeleton;
    Animation animation;
    float time;
    Bone root;
    
    @Override
    public void create() {
    	batch = new SpriteBatch();
    	renderer = new ShapeRenderer();
    
    	atlas = new TextureAtlas(Gdx.files.internal("frog/frog.atlas"));
    	SkeletonJson json = new SkeletonJson(atlas);
    	SkeletonData skeletonData = json.readSkeletonData(Gdx.files.internal("frog/skeleton.json"));
    	//animation = json.readAnimation(Gdx.files.internal("spineboy/spineboy-walk.json"), skeletonData);
    	animation = skeletonData.findAnimation("breathing");
    	skeleton = new Skeleton(skeletonData);
    
    	root = skeleton.getRootBone();
    	root.setX(10);
    	root.setY(20);
    
    	skeleton.updateWorldTransform();
    	
    }
    
    @Override
    public void resize(int width, int height) {
    	batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
    	renderer.setProjectionMatrix(batch.getProjectionMatrix());
    	
    }
    
    float totalTime = 0f;
    @Override
    public void render() {
    	
    	float delta = Gdx.graphics.getDeltaTime() / 3;
    	time += delta;
    
    	Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    	batch.begin();
    
    	animation.apply(skeleton, time, true);
    	root.setX(root.getX() + 230 * delta);
    	skeleton.updateWorldTransform();
    	skeleton.draw(batch);
    
    	batch.end();
    
    	skeleton.drawDebug(renderer);
    	
    }
    
    @Override
    public void pause() {
    	// TODO Auto-generated method stub
    	
    }
    
    @Override
    public void resume() {
    	// TODO Auto-generated method stub
    	
    }
    
    @Override
    public void dispose() {
    	atlas.dispose();
    	
    }
    
    }