You Are Here:

Community: Developer Discussion Boards

#1 Old What's wrong? - 2004-06-01, 08:54

Join Date: Dec 2003
Posts: 32
Location: Thailand
kdermpan
Offline
Registered User
Hello,
I developing a game for N6600 and all is ok until
I try to fire bullet from my ship.

I try to do as example from java.sun.com inorder to make a thread
and loop to show animation on phone's game.

Here are some part of my program,

public class GameEngine extends Canvas implements Runnable{
boolean done = false;
public CBullet bullet;
...

public GameEngine(){
bullet = new CBullet;
bullet.show = 0;
}

public void paint(Graphics g){
... grahics initialzation is ok ...
}

public void onKeyPress(Command cmd, Display d){
switch(cmd){
case: Canvas.KEY_NUM5
bullet.show = 1;
break;

case Canvas.KEY_NUM4
done = true;
break;
}

repaint();
}

public void run(){
while(!done){
if(bullet.show == 1) bullet.x = bullet x + 1;
}

repaint();
}
...
}

for other key such as KEY_NUM7 = move left is work well.
bullet.show in run() is still 0 although KEY_NUM5 is pressed
while done is true when press KEY_NUM4.

What's wrong in my code?
Reply With Quote

#2 Old 2004-06-01, 09:18

Join Date: Mar 2003
Posts: 2,280
Location: Israel
shmoove
Offline
Forum Nokia Champion
What is this:
Code:
public void onKeyPress(Command cmd, Display d){
?

Don't you mean:
Code:
void keyPressed(int keyCode) {
?

shmoove
Reply With Quote

#3 Old 2004-06-01, 11:39

Join Date: Dec 2003
Posts: 32
Location: Thailand
kdermpan
Offline
Registered User
Sorry I just wrong typed, it is keyPressed ;P

However, I right typed this in my program.
I can compiled but it didn't run as I want as I told.
Reply With Quote

#4 Old 2004-06-03, 18:33

Join Date: Dec 2003
Posts: 32
Location: Thailand
kdermpan
Offline
Registered User
Aaak! sorry, I lost "break;" in my switch().
Now every thing is well :)
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

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