STARTING SEARCH IN /home/tapio/Gauntlet/Gauntlet/resources
Searching in path complete. Starting to parse files
Reading file /home/tapio/Gauntlet/Gauntlet/resources/pothead.yaml
Reading file
Adding animation PotheadWalkDown
Type class loading.AnimationInfo
Adding animation PotheadWalkUp
Type class loading.AnimationInfo
Adding animation PotheadWalkLeft
Type class loading.AnimationInfo
Adding animation PotheadWalkRight
Type class loading.AnimationInfo
com.esotericsoftware.yamlbeans.YamlReader$YamlReaderException: Line 40, column 9: Error creating object.
at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:270)
at com.esotericsoftware.yamlbeans.YamlReader.readValue(YamlReader.java:156)
at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:299)
at com.esotericsoftware.yamlbeans.YamlReader.readValue(YamlReader.java:156)
at com.esotericsoftware.yamlbeans.YamlReader.read(YamlReader.java:106)
at com.esotericsoftware.yamlbeans.YamlReader.read(YamlReader.java:91)
at com.esotericsoftware.yamlbeans.YamlReader.read(YamlReader.java:83)
at resources.Loader.loadFromFolder(Loader.java:65)
at game.Game.init(Game.java:62)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
at game.Game.main(Game.java:36)
Caused by: java.lang.reflect.InvocationTargetException: Unable to find a no-arg constructor for class: [F
at com.esotericsoftware.yamlbeans.Beans.createObject(Beans.java:113)
at com.esotericsoftware.yamlbeans.YamlReader.createObject(YamlReader.java:368)
at com.esotericsoftware.yamlbeans.YamlReader.readValueInternal(YamlReader.java:268)
... 11 more
I got this weird problem that shouldn't (I think) exist. I have 3 similar classes: AnimationInfo, EntityInfo and StateInfo.
They all have similar no-arg constructors but it refuses to work. AnimationInfo deserializes just fine, but EntityInfo doesn't.
Here's the classes as they are now
package loading;
import org.newdawn.slick.Color;
public class AnimationInfo{
public AnimationInfo() {
super();
this.name = null;
this.filename = null;
this.frames = null;
this.durations = null;
this.spriteW = 0;
this.spriteH = 0;
this.transparentcolor = null;
}
public AnimationInfo(String name, String filename, String row,
int[] frames, int[] durations, int spriteW, int spriteH) {
super();
this.name = name;
this.filename = filename;
this.frames = frames;
this.durations = durations;
this.spriteW = spriteW;
this.spriteH = spriteH;
}
public String name; //Name/Id of the animation
public String filename; //Where to load the spritesheet
public int[] frames; //How many frames that animation has
public int[] durations; //Duration of each frame in msecs
public int spriteW; //Width
public int spriteH; //Height of each frame
public int[] transparentcolor;
}
package loading;
import java.util.HashMap;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.geom.Vector2f;
import core.Entity;
import core.KeyCharacterController;
public class EntityInfo {
public EntityInfo(){
EntityID = null;
hitbox = null;
height = 0;
zValue = 0;
states = null;
}
public EntityInfo(String entityID, float[] hitbox, float height, float zValue, StateInfo[] states) {
super();
EntityID = entityID;
this.hitbox = hitbox;
this.height = height;
this.zValue = zValue;
this.states = states;
}
public String EntityID;
public float[] hitbox; //Length is 4
public float height;
public float zValue = 0;
public StateInfo[] states;
/**
* It'll looks like this in yaml
* states:
* - !loading.StateInfo
* - UpdateComponents
* - Data
* - RenderComponents
* - Data
*/
public static HashMap<String, EntityInfo> store = new HashMap<String,EntityInfo>();
}
And here's the .yaml-file
!loading.AnimationInfo
name: PotheadWalkDown
filename: "sprites/pothead.png"
spriteW: 16
spriteH: 21
frames: [0,0,0,1,0,2,0,1]
durations: [200,200,200,200]
transparentcolor: [255,255,255]
---
!loading.AnimationInfo
name: PotheadWalkUp
filename: "sprites/pothead.png"
spriteW: 16
spriteH: 21
frames: [3,0,3,1,3,2,3,1]
durations: [200,200,200,200]
transparentcolor: [255,255,255]
---
!loading.AnimationInfo
name: PotheadWalkLeft
filename: "sprites/pothead.png"
spriteW: 16
spriteH: 21
frames: [1,0,1,1,1,2,1,1]
durations: [200,200,200,200]
transparentcolor: [255,255,255]
---
!loading.AnimationInfo
name: PotheadWalkRight
filename: "sprites/pothead.png"
spriteW: 16
spriteH: 21
frames: [2,0,2,1,2,2,2,1]
durations: [200,200,200,200]
transparentcolor: [255,255,255]
---
!loading.EntityInfo
EntityID: Pothead
hitbox: {-10,-10,20,20}
height: 30.0
zValue: 0
states:
- !loading.StateInfo
stateName: "moving"
updateComponents:
- "core.states.BehaviorMoving"
updateArgs:
- ["20"]
renderComponents:
- "core.states.RendererMoving"
renderArgs:
- ["PotheadWalk","PotheadRight","PotheadLeft","PotheadRight"]
---
Yes it is a huge wall of text. I just couldn't describe it with less space.