Quote:
Originally Posted by jfisher
getMainManager();
anyone know how you'd then override the paint method of this manager?
|
You can't override it except in a derived class. So you need to create your own class that extends one of the Manager classes.
The problem then is that you can not set a new MainManager for the MainScreen. That's annoying. The solution I came up with was to create a derived MainScreen class that creates it's own new Manager and adds Fields to that Manager instead of the default one already created by the MainScreen.
It's a bit tricky, but it works. Any fields you add are painted over the top of the background bitmap. Here's some sample code...
First the new Manager class:
Code:
class NewVerticalFieldManager extends VerticalFieldManager {
Bitmap bkgrndBmp = Bitmap.getBitmapResource("background.png");
NewVerticalFieldManager() {
super();
}
protected void paintBackground(Graphics g){
if(bkgrndBmp != null){
g.rop(Graphics.ROP_SRC_ALPHA_GLOBALALPHA,
(this.getWidth() / 2) - (bkgrndBmp .getWidth() /2),
(this.getHeight() / 2) - (bkgrndBmp .getHeight() /2),
bkgrndBmp .getWidth(),
bkgrndBmp .getHeight(),
bkgrndBmp ,0,0);
}
}
}
Now the new MainScreen class.
Code:
class NewMainScreen extends MainScreen {
NewVerticalFieldManager manager = new NewVerticalFieldManager();
NewMainScreen() {
super();
super.add(manager);
}
public void add(Field field){
manager.add(field);
}
}