Avoid internal getters/setters - Game
<p>I working on a Game. The View, Thread and the Engine are done. Now I going into how to, for example, set Coordinates to my Bitmap. </p>

<p>I have successfully done that using getters/setters-method. I've been reading around the web there the most of the good game developers say that "make your member variable public" and all that stuff.</p>

<p>Since I read the Avoid Internal Getters/Setters section at <a href="http://developer.android.com/guide/practices/design/performance.html" rel="nofollow">http://developer.android.com/guide/practices/design/performance.html</a>, I started to wonder: How I can change my Coordinates-class to achieve this without "setters" for example?</p>

<p>Now my Coordinates-class look like:</p>

<pre><code>package com.mygame.mygame;

public class Coordinates {
    int x;
    int y;
    Coordinates instance = null;

 public Coordinates getInstance(){
  if(instance == null){
   instance = new Coordinates();  
  }
  return instance;
 }

    public Coordinates() {    
    }

    public int getX() {
        return x;
    }

    public void setX(int value) { 
        x = value;
    }

    public int getY() {
        return y;
    }
    public void setY(int value) {
        y = value;
    } 

}
</code></pre>

<p>How should I change my code to achieve this? Method calls are expensive, but I still have no idea how to restructure my current code without getters and setters.</p>

<p><strong>UPDATED</strong></p>

<pre><code> public GameEngine getInstance(){
 if(instance == null){
  instance = new GameEngine(resources,view);  
  }
  return instance;
  }
</code></pre>

<p><strong>UPDATE 2</strong></p>

<p>GameEngine</p>

<pre><code>    static Resources res;

static GameView view;

static GameEngine instance = null;

public static GameEngine getInstance(Resources localResources, GameView localView){
    view = localView;
    res = localResources;
    if(instance == null){
        instance = new GameEngine(); //Init-stuff in the GameEngine
    }
    return instance;
}
</code></pre>

<p>and my GameView</p>

<pre><code>static GameEngine engine;
public GameView(Context localContext) {
   //Other stuff
   engine = GameEngine.getInstance(context.getResources(), this);
   //Other stuff
}
</code></pre>

<p>Thanks in advance!</p>
