我是LibGDX初学者。这是我的代码:
@Override
public void create() {
batch = new SpriteBatch();
bf = new BitmapFont();
particle = new ParticleEffect();
particle.load(Gdx.files.internal("particle.p"), Gdx.files.internal("particle.png"));
}
我收到了以下错误:
java.lang.RuntimeException: Error parsing emitter: Untitled at com.badlogic.gdx.graphics.g2d.ParticleEmitter.load(ParticleEmitter.java:970) at com.badlogic.gdx.graphics.g2d.ParticleEmitter.<init>(ParticleEmitter.java:94) at com.badlogic.gdx.graphics.g2d.ParticleEffect.newEmitter(ParticleEffect.java:206) at com.badlogic.gdx.graphics.g2d.ParticleEffect.loadEmitters(ParticleEffect.java:157) at com.badlogic.gdx.graphics.g2d.ParticleEffect.load(ParticleEffect.java:137) at com.mygdx.game.MyGame.create(MyGame.java:35) at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:275) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240) Caused by: java.lang.NumberFormatException: Invalid int: "false" at java.lang.Integer.invalidInt(Integer.java:137) at java.lang.Integer.parse(Integer.java:374) at java.lang.Integer.parseInt(Integer.java:365) at java.lang.Integer.parseInt(Integer.java:331) at com.badlogic.gdx.graphics.g2d.ParticleEmitter.readInt(ParticleEmitter.java:993) at com.badlogic.gdx.graphics.g2d.ParticleEmitter$GradientColorValue.load(ParticleEmitter.java:1332) at com.badlogic.gdx.graphics.g2d.ParticleEmitter.load(ParticleEmitter.java:951) at com.badlogic.gdx.graphics.g2d.ParticleEmitter.<init>(ParticleEmitter.java:94) at com.badlogic.gdx.graphics.g2d.ParticleEffect.newEmitter(ParticleEffect.java:206) at com.badlogic.gdx.graphics.g2d.ParticleEffect.loadEmitters(ParticleEffect.java:157) at com.badlogic.gdx.graphics.g2d.ParticleEffect.load(ParticleEffect.java:137) at com.mygdx.game.MyGame.create(MyGame.java:35) at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:275) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
文件&#34; Particle.p&#34; content:Untitled - Delay - active:false - Duration - lowMin:3000.0 lowMax:3000.0 - Count - min:0 max:200 - Emission - lowMin:0.0 lowMax:0.0 highMin:250.0 highMax:250.0 relative:false scalingCount:1 scaling0: 1.0 timelineCount:1 timeline0:0.0 - Life - lowMin:0.0 lowMax:0.0 highMin:500.0 highMax:1000.0 relative:false scalingCount:3 scaling0:1.0 scaling1:1.0 scaling2:0.3 timelineCount:3 timeline0:0.0 timeline1:0.66 timeline2:1.0 - Life Offset - 活动:false - X偏移 - 活动:false - Y偏移 - 活动:false - Spawn形状 - 形状:点 - Spawn宽度 - lowMin:0.0 lowMax:0.0 highMin:0.0 highMax:0.0 relative:false scalingCount:1 scaling0 :1.0 timelineCount:1 timeline0:0.0 - Spawn Height - lowMin:0.0 lowMax:0.0 highMin:0.0 highMax:0.0 relative:false scalingCount:1 scaling0:1.0 timelineCount:1 timeline0:0.0 - X Scale - lowMin:0.0 lowMax:0.0 highMin :32.0 highMax:32.0 relative:false scalingCount:1 scaling0:1.0 timelineCount:1 timeline0:0。 0 - Y Scale - 活动:false - Velocity - 活动:true lowMin:0.0 lowMax:0.0 highMin:30.0 highMax:300.0 relative:false scalingCount:1 scaling0:1.0 timelineCount:1 timeline0:0.0 - Angle - active:true lowMin:90.0 lowMax:90.0 highMin:45.0 highMax:135.0 relative:false scalingCount:3 scaling0:1.0 scaling1:0.0 scaling2:0.0 timelineCount:3 timeline0:0.0 timeline1:0.5 timeline2:1.0 - Rotation - active:false - Wind - active:false - Gravity - active:false - Tint - colorsCount:3 colors0:1.0 colors1:0.12156863 colors2:0.047058824 timelineCount:1 timeline0:0.0 - Transparency - lowMin:0.0 lowMax:0.0 highMin:1.0 highMax:1.0 relative:false scalingCount:4 scaling0:0.0 scaling1 :1.0 scaling2:0.75 scaling3:0.0 timelineCount:4 timeline0:0.0 timeline1:0.2 timeline2:0.8 timeline3:1.0 - Options - attach:false continuous:false aligned:false additive:true behind:false premultipliedAlpha:false - Image Path - particle。 PNG
Untitled - Delay - active:false - 持续时间 - lowMin:3000.0 lowMax:3000.0 - Count - min:0 max:200 - Emission - lowMin:0.0 lowMax:0.0 highMin:250.0 highMax:250.0 relative:false scalingCount:1 scaling0 :1.0 timelineCount:1 timeline0:0.0 - Life - lowMin:0.0 lowMax:0.0 highMin:500.0 highMax:1000.0 relative:false scalingCount:3 scaling0:1.0 scaling1:1.0 scaling2:0.3 timelineCount:3 timeline0:0.0 timeline1:0.66 timeline2:1.0 - 生命偏移 - 活动:假 - X偏移 - 活动:假 - Y偏移 - 活动:假 - 生成形状 - 形状:点 - 生成宽度 - 低精度:0.0 lowMax:0.0 highMin:0.0 highMax:0.0 relative:false scalingCount:1 scaling0:1.0 timelineCount:1 timeline0:0.0 - Spawn Height - lowMin:0.0 lowMax:0.0 highMin:0.0 highMax:0.0 relative:false scalingCount:1 scaling0:1.0 timelineCount:1 timeline0:0.0 - X Scale - lowMin:0.0 lowMax:0.0 highMin:32.0 highMax:32.0 relative:false scalingCount:1 scaling0:1.0 timelineCount:1 timeline0:0.0 - YS cale - active:false - Velocity - active:true lowMin:0.0 lowMax:0.0 highMin:30.0 highMax:300.0 relative:false scalingCount:1 scaling0:1.0 timelineCount:1 timeline0:0.0 - Angle - active:true lowMin:90.0 lowMax:90.0 highMin:45.0 highMax:135.0 relative:false scalingCount:3 scaling0:1.0 scaling1:0.0 scaling2:0.0 timelineCount:3 timeline0:0.0 timeline1:0.5 timeline2:1.0 - Rotation - active:false - Wind - active:false - Gravity - active: false - Tint - colorsCount:3 colors0:1.0 colors1:0.12156863 colors2:0.047058824 timelineCount:1 timeline0:0.0 - Transparency - lowMin:0.0 lowMax:0.0 highMin:1.0 highMax:1.0 relative:false scalingCount:4 scaling0:0.0 scaling1:1.0 scaling2 :0.75 scaling3:0.0 timelineCount:4 timeline0:0.0 timeline1:0.2 timeline2:0.8 timeline3:1.0 - Options - attach:false continuous:false aligned:false additive:true behind:false premultipliedAlpha:false - Image Path - particle.png`< / p>
此文件&#34; particle.p&#34;是使用粒子生成器生成的,我不知道什么是错的,有人可以帮助我吗?
答案 0 :(得分:0)
我想我找到了问题的原因,我使用的是粒子生成器和LibGDX不适合。粒子生成器有一个Scale和一个Scale X标签和一个Scale Y标签,但LibGDX文本解析器只解析一个Scale标签,导致解析错误,导致问题
答案 1 :(得分:0)
我不确定您是否已经解决了问题但只是让您知道将LibGDX更新为1.9.7-SNAPSHOT将有助于解决问题。
如果您使用Android Studio(就像我一样,不确定其他IDE)。您可以通过build.gradle进行更新。
只需更改行
即可gdxVersion='YOUR_CURRENT_VERSION'
到
gdxVersion = '1.9.7-SNAPSHOT'