У меня есть общий пул, который я создаю здесь:
public class FruitPool extends GenericPool<Sprite> {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private final TextureRegion mTextureRegion;
private Scene mScene;
// ===========================================================
// Constructors
// ===========================================================
public FruitPool(final TextureRegion pFruitTextureRegion, Scene mScene2) {
this.mTextureRegion = pFruitTextureRegion;
this.mScene = mScene2;
}
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
protected Sprite onAllocatePoolItem() {
Random rand = new Random();
//I want to get the Screens Display metrics here...
Sprite fruit = new Sprite(0, 0, this.mTextureRegion);
mScene.attachChild(fruit);
return fruit;
}
Я пытаюсь получить такие метрики на экранах ..
final Display display = getWindowManager().getDefaultDisplay();
CAMERA_WIDTH = display.getWidth();
CAMERA_HEIGHT = display.getHeight();
Единственный проблема в том, что я не могу понять, как это сделать вне Activity ..
Возможно ли это вообще? Или мне придется использовать SharedPreference или что-то в этом роде?