Join Our 3 MILLION+ Members Today! Register Here | Login
Go Back   BlackBerry Forums at CrackBerry.com > BlackBerry Professionals > App Developers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
    Thread Author   #1  
Old 01-29-2010, 06:32 PM
CrackBerry Newbie
Device(s): 8900 (Curve)
Carrier: T-Mobile
 
Join Date: Jan 2010
Posts: 3
Likes Received: 0
Thanked 0 Times in 0 Posts
Default Main game loop not updating?

Hey guys, I read forums.crackberry.com/f9/help-new-guy-making-game-264468/#post3072053 and am using that as a template for a game. The problem is in


Code:
public void paint(Graphics g) {
     g.setColor(_random.nextInt();); // _random being a Random object already created
     g.drawEllipse(25, 25, 25 + 10, 25, 25, 25 + 10, 0, 0); 
}
I basically just set a diff color for the ellipse each time paint is called, but it seems paint is only called once, so I was wondering if I'm doing it wrong. I basically copied everything from daveinsurgent's post, which is a great starting pt btw.
Reply With Quote Tip this Post
  #2  
Old 01-30-2010, 03:20 AM
QuiteSimple
Device(s): 9000 (Bold)
Carrier: Verizon
 
Join Date: Sep 2009
Posts: 168
Likes Received: 0
Thanked 1 Time in 1 Post
Default

you need to call invalidate() in a loop (invalidate() forces the screen to repaint itself)

I guess you need to implement that part of the sample code:

Code:
  private class Logic extends Thread {
    pulic Logic() {
      start();
    }

    public void run() {
      while (_active) {
        update();
        invalidate();
      }
    }
As you can see invalidate() is called in the Logic thread
__________________
www.quite-simple.com
Software that works.
Reply With Quote Tip this Post
    Thread Author   #3  
Old 01-30-2010, 04:12 AM
CrackBerry Newbie
Device(s): 8900 (Curve)
Carrier: T-Mobile
 
Join Date: Jan 2010
Posts: 3
Likes Received: 0
Thanked 0 Times in 0 Posts
Default

well i copyed it word for word i just changed the drawing.
and it included that.

Posted from my CrackBerry at wapforums.crackberry.com
Reply With Quote Tip this Post
  #4  
Old 01-30-2010, 04:48 AM
CrackBerry Addict
Device(s): 9780 and Playbook
Carrier: Orange
 
Location: Up North...UK
Join Date: Sep 2008
Posts: 597
Likes Received: 8
Thanked 2 Times in 2 Posts
Default

If I were writing a Blackberry game, I would start with Tony Westbrook's excellent blog post which Toni Westbrook dot Com » Creating a Blackberry Game - Part 1
__________________
Personal website and blog | Flickr photostream
We are what we repeatedly do. Excellence, therefore, is not an act but a habit - Aristotle
Reply With Quote Tip this Post
    Thread Author   #5  
Old 01-30-2010, 06:19 PM
CrackBerry Newbie
Device(s): 8900 (Curve)
Carrier: T-Mobile
 
Join Date: Jan 2010
Posts: 3
Likes Received: 0
Thanked 0 Times in 0 Posts
Default

Thanks, I'm actually using that tut as well. And it seems the problem was because the member _logic is declared as type Thread when it should've been type Logic, which explains why it didn't looped.
Reply With Quote Tip this Post
  #6  
Old 01-31-2010, 11:59 AM
CrackBerry Addict
Device(s): 9780 and Playbook
Carrier: Orange
 
Location: Up North...UK
Join Date: Sep 2008
Posts: 597
Likes Received: 8
Thanked 2 Times in 2 Posts
Default

No problem - glad you got it sorted. The most active forum for Blackberry development seems to be the official RIM Java Development forum over at Java Development - BlackBerry Support Community Forums

Worth a look if you havent already seen it.
__________________
Personal website and blog | Flickr photostream
We are what we repeatedly do. Excellence, therefore, is not an act but a habit - Aristotle
Reply With Quote Tip this Post
Reply
BlackBerry Forums at CrackBerry.com > > BlackBerry Professionals > App Developers   Main game loop not updating?

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes