You Are Here:

Community: Developer Discussion Boards

#1 Old Lightbulb Problem class GameCanvas for Nokia 6260!!!! - 2005-09-21, 03:54

Join Date: Sep 2005
Posts: 17
rubicita's Avatar
rubicita
Offline
Registered User
Hi,
I tested some applications that extends the GameCanvas, when I tested on simulator J2ME Wireless Toolkit it hasn't problem when I download the application on phone (Nokia 6260) the program show screen and it work ok but when i try go out the application send the two errors

"Buffer closed java.lang.RunTimeException
0 java.lang.NullPointerException"

It's possible that phone not support the class javax.microedition.lcdui.game.GameCanvas? or what's the problem?
Help me please,
Thanks
P.S Below put the code, maybe this way is easer.

// A simple example of a game canvas that displays
// a scrolling star field. The UP and DOWN keys
// speed up or slow down the rate of scrolling.

public class StarField extends GameCanvas implements Runnable{

private static final int SLEEP_INCREMENT = 10;
private static final int SLEEP_INITIAL = 150;
private static final int SLEEP_MAX = 300;

private Graphics graphics;
private Random random;
private int sleepTime = SLEEP_INITIAL;
private volatile Thread thread;
private Command salir = null;

public StarField(){
super( true );

graphics = getGraphics();
graphics.setColor( 0, 0, 0 );
graphics.fillRect( 0, 0, getWidth(), getHeight() );
}

// When the game canvas is hidden, stop the thread.
protected void hideNotify(){
thread = null;
}

// The game loop.
public void run(){
int w = getWidth();
int h = getHeight() - 1;
while( thread == Thread.currentThread() ){
// Increment or decrement the scrolling interval
// based on key presses
int state = getKeyStates();
if( ( state & DOWN_PRESSED ) != 0 ){
sleepTime += SLEEP_INCREMENT;
if( sleepTime > SLEEP_MAX )
sleepTime = SLEEP_MAX;
} else if( ( state & UP_PRESSED ) != 0 ){
sleepTime -= SLEEP_INCREMENT;
if( sleepTime < 0 ) sleepTime = 0;
}
// Repaint the screen by first scrolling the
// existing starfield down one and painting in
// new stars...
graphics.copyArea( 0, 0, w, h, 0, 1,
Graphics.TOP | Graphics.LEFT );
graphics.setColor( 0, 0, 0 );
graphics.drawLine( 0, 0, w, 1 );
graphics.setColor( 255, 255, 255 );
for( int i = 0; i < w; ++i ){
int test = Math.abs( random.nextInt() ) % 10;
if( test < 4 ){
graphics.drawLine( i, 0, i, 0 );
}
}

flushGraphics();
// Now wait...
try {
Thread.currentThread().sleep( sleepTime );
}
catch( InterruptedException e ){
}
}
}

// When the canvas is shown, start a thread to
// run the game loop.
protected void showNotify(){
random = new Random();
thread = new Thread( this );
thread.start();
}
}

Thanks, see you
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Bluetooth app - DiscoverConnect, btspp problem on 7610 and 6260 rogerpang Mobile Java Networking & Messaging & Security 5 2007-01-24 08:02
2 Newbie Questions: Class GameCanvas is missing KiwiChriss Mobile Java General 2 2005-01-20 16:19
MAJOR PROBLEM - Nokia 6260 nanisk1 General Discussion 0 2004-12-11 22:46
Exceptions while loading application avinash_rs Mobile Java General 0 2003-06-09 11:53
Problem with the Alert class activo Mobile Java General 0 2002-10-22 10:05

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ