1

私は Slick2D で小さなゲームに取り組んでいます JavaDoc は次のとおりです: http://slick.ninjacave.com/javadoc/overview-summary.html

このコードのチャンクは私に問題を与えています:

 public void move(){

        this.shape = (Ellipse)this.shape.transform(Transform.createTranslateTransform((float)(speed*Math.sin(angle)),(float)(speed*Math.cos(angle)*-1)));
        this.posx = this.posx+(float)(speed*Math.sin(angle));
        this.posy = this.posy+(float)(speed*Math.cos(angle)*-1);

         updateShape();
    }

これはエラーです:

java.lang.ClassCastException: org.newdawn.slick.geom.Polygon cannot be cast to org.newdawn.slick.geom.Ellipse

What's throwing me off is.. shape.transform() returns an abstract Shape class, which is meant to be casted to a specific shape. I did the same thing with a Polygon in a different class, and it works fine.

If anyone has experience with this, it's much appreciated, google wasn't helping me much

edit* Oh, I'm sorry, I forgot to include how this.shape was created:

Ellipse shape;
...
shape = new Ellipse(diameter/2,diameter/2,posx,posy);
4

1 に答える 1