0

I'm having an odd issue with my animation that is happening only on OSX, and not on windows. On my windows computer, the animation occurs full screen in a JFrame, as it is supposed to - however on my mac the animations are only drawn in the lower left corner:

Windows: Windows Version

OSX: OSX Version

Here is the code that I use to create the window, and draw the frame (Same on both computers):

public class AnimationMain extends JFrame implements Runnable{

BufferStrategy bs;
/**
 * Initializes the properties of the JFrame that we are drawing on
 */
public void init(){
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setTitle("Final Project V2");
    this.setSize(7*128, 5*128);
    this.setResizable(false);
    this.setVisible(true);

    createBufferStrategy(3);
    bs = getBufferStrategy();
}
/**
 * Calls out to a drawing method, which simply draws everything on the screen
 * @param g
 */
public void draw(Graphics2D g){
    if (GMI.gameState.equals(GameState.PLAYING) && GMI.gameReady){
        AnimationManagement.MainGameDisplay.drawMainGame(this, g);
    }

}


/**
 * Calls the init method, and then repaints the frame
 */
public void run() {
    init();
    while (true){
          Graphics2D g = (Graphics2D) bs.getDrawGraphics();
          draw(g);
          g.dispose();
          bs.show();
        try{Thread.sleep(AppInfo.frameTime);}catch(Exception e){e.printStackTrace();} //Sleep for 10ms between redraws
    }
}

Any help would be greatly appreciated, thanks!

martinez314
  • 12,162
  • 5
  • 36
  • 63
David Chan
  • 383
  • 1
  • 2
  • 9
  • 1
    Too many ways for this to go wrong for an answer, but [this](http://stackoverflow.com/q/7213178/230513) and [this](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html) are common. – trashgod Apr 04 '14 at 17:15
  • You're not showing enough code to really understand what's going on, but it looks like your drawing origin is different between Windows and OS X. Output some coordinates where you're drawing and I bet it will start making sense. – martinez314 Apr 04 '14 at 18:51

0 Answers0