• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using metods in a keylistener

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok...i have this method in my file "fighter.java"



ok, now in the key listener when i press 'A', i want it to call that
method so it will infact draw the fireball if and only if i press 'A'

example:



please help me, i'm really stuck on this'n..

thanks,
Monk
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're going to have to call that method through paint.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so instead of "drawFireball(g);"

i need to put

paint.drawFireball(g);

???

Help?!
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. I mean that the parameter list of the drawFireBall method is a Graphics reference. The only place you're going to get the Graphics reference is in the paint method. You'll have to call drawFileBall from paint and send the Graphics context of the Applet or Frame.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic