Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Exception in "AWT-EventQueue-0" Thread Error
    text
    copied!<p>i know this question has been asked like a million times but i have looked on a lot of the answers and they in no way help me. i have no idea what i am doing wrong.</p> <p>I believe the reason i am getting the error is due to this code here:</p> <pre><code> RollerBall roller = new RollerBall(game); roller.setPosition(new Vec2(-50,-120)); </code></pre> <p>I am using the above code to call a class which code is shown below:</p> <pre><code>package game; import city.soi.platform.*; import fsm.FSM; public class RollerBall extends Body implements StepListener { public static final float RANGE = 150; private Game game; private FSM&lt;RollerBall&gt; fsm; public RollerBall(Game game) { super(game.getWorld()); game = game; fsm = new FSM&lt;RollerBall&gt;(this); fsm.start(new StandStillState()); getWorld().addStepListener(this); } public boolean inRangeLeft() { Player p = game.getPlayer(); float gap = getPosition().x - p.getPosition().x; return gap &lt; RANGE &amp;&amp; gap &gt; 0; } public boolean inRangeRight() { Player p = game.getPlayer(); float gap = getPosition().x - p.getPosition().x; return gap &gt; -RANGE &amp;&amp; gap &lt; 0; } public boolean inRange() { return inRangeLeft() || inRangeRight(); } public void preStep(StepEvent e) { fsm.update(); } public void postStep(StepEvent e) {} } </code></pre> <p>Finally, when trying to do this i am getting the following error:</p> <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at game.RollerBall.inRangeLeft(RollerBall.java:23) at game.StandStillState.update(StandStillState.java:10) at fsm.FSM.update(FSM.java:47) at game.RollerBall.preStep(RollerBall.java:39) at city.soi.platform.World.preStep(World.java:495) at city.soi.platform.World.step(World.java:328) at city.soi.platform.World$1.actionPerformed(World.java:206) at javax.swing.Timer.fireActionPerformed(Timer.java:312) at javax.swing.Timer$DoPostEvent.run(Timer.java:244) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:682) at java.awt.EventQueue$3.run(EventQueue.java:680) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:691) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139) at java.awt.EventDispatchThread.run(EventDispatchThread.java:97) </code></pre> <p>Thanks in advance for your help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload