Created
May 16, 2013 20:25
-
-
Save AtkinsSJ/5594800 to your computer and use it in GitHub Desktop.
For some reason, the Java code I'm working on crashes, as a class tries to find itself. Line 43 of AIDriver.java defines a RayCastCallback, and this for some reason causes a class loader to search for "uk.co.samatkins.racing.drivers.AIDriver$MoveCalculator$1", which I think is the RayCastCallback itself. Any ideas?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package uk.co.samatkins.racing.drivers; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.math.Vector2; | |
import com.badlogic.gdx.physics.box2d.Fixture; | |
import com.badlogic.gdx.physics.box2d.RayCastCallback; | |
import com.badlogic.gdx.physics.box2d.World; | |
import uk.co.samatkins.racing.Car; | |
import uk.co.samatkins.racing.Move; | |
public class AIDriver extends AbstractDriver { | |
@Override | |
public void calculateMove() { | |
this.ready = false; | |
// Start a thread for calculating the next move | |
// Thread aiThread = new Thread(new MoveCalculator(this), "AI Thread"); | |
// aiThread.start(); | |
MoveCalculator mc = new MoveCalculator(this); | |
mc.run(); | |
} | |
/** | |
* Class that calculates the next move for the AI. | |
* @author Sam | |
*/ | |
public class MoveCalculator implements Runnable { | |
private AIDriver aiDriver; | |
public MoveCalculator(AIDriver aiDriver) { | |
this.aiDriver = aiDriver; | |
} | |
@Override | |
public void run() { | |
// Cast a ray forwards from the car | |
Car car = this.aiDriver.car; | |
World world = car.getWorld(); | |
RayCastCallback cb = new RayCastCallback() { | |
@Override | |
public float reportRayFixture(Fixture fixture, Vector2 point, | |
Vector2 normal, float fraction) { | |
Gdx.app.debug("RAYCAST", "fixture: " + fixture + " point: " + point + " normal: " + normal + " fraction: " + fraction); | |
return 0; | |
} | |
}; | |
Vector2 pos = car.getPosition().cpy(); | |
Vector2 pos2 = pos.cpy().add(car.getVelocity()); | |
world.rayCast(cb, pos, pos2); | |
this.aiDriver.currentMove = new Move(0,1.0f,0); | |
this.aiDriver.ready = true; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread [LWJGL Application] (Suspended) | |
owns: Launcher$ExtClassLoader (id=50) | |
owns: Launcher$AppClassLoader (id=51) | |
owns: LwjglInput (id=30) | |
ClassNotFoundException(Throwable).<init>(String, Throwable) line: 217 | |
ClassNotFoundException(Exception).<init>(String, Throwable) line: not available | |
ClassNotFoundException.<init>(String) line: not available | |
URLClassLoader$1.run() line: not available [local variables unavailable] | |
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method] | |
Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available | |
Launcher$ExtClassLoader.findClass(String) line: not available | |
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available | |
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available | |
Launcher$AppClassLoader.loadClass(String, boolean) line: not available | |
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available | |
AIDriver$MoveCalculator.run() line: 43 | |
AIDriver.calculateMove() line: 23 | |
PlayScene.startControl() line: 281 | |
PlayScene.show() line: 151 | |
Game(Game).setScreen(Screen) line: 62 | |
MenuScene$1.clicked(InputEvent, float, float) line: 33 | |
MenuScene$1(ClickListener).touchUp(InputEvent, float, float, int, int) line: 78 | |
MenuScene$1(InputListener).handle(Event) line: 43 | |
MenuScene(Stage).touchUp(int, int, int, int) line: 309 | |
InputMultiplexer.touchUp(int, int, int, int) line: 94 | |
LwjglInput.processEvents() line: 297 | |
LwjglApplication.mainLoop() line: 183 | |
LwjglApplication$1.run() line: 110 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment