Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 296
Registered: ‎12-07-2008
My Device: Not Specified

Re: Is this possible?

 


JCarty wrote:

Try using paintBackground instead  of paint to draw your bitmap and see how it works out. Usually works for me too. I can't see what's wrong with your code.


 

I just tried that and it doesn't paint the image. It's just a blank screen, but the field shows just fine.

 

Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: Is this possible?

[ Edited ]

 

    public void paintBackground(Graphics g)
{
g.drawBitmap(0,0, _backgroundBM.getWidth(), _backgroundBM.getHeight(), _backgroundBM , 0, 0);
}

 

 

Actual code from one of my games that is out right now.

 

In the paint method, all I have are the elements that move.

 

 

public void paint(Graphics g)
{
super.paint(g);

for( int i=0; i<_pieceTotal; i += 6 ) {
_piece[i].draw(g);
_piece[i+1].draw(g);
_piece[i+2].draw(g);
_piece[i+3].draw(g);
_piece[i+4].draw(g);
_piece[i+5].draw(g);
}
}

 

These pieces are painted on top of the background and the elements that I've added to the screen via the standard add.

 

The only difference is I don't have a vertical manager sitting in between them. So maybe you need to add your paint to your HorizontalFieldManager.

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Highlighted
Developer
Posts: 296
Registered: ‎12-07-2008
My Device: Not Specified

Re: Is this possible?

I figured it out, but it was more trial and error then anything.

 

I created a vfm and put the background image in there. I then created a new vfm and added it to the first vfm. After playing around with the paint methods it now works. Thanks for your help.