This site requires JavaScript, please enable it in your browser!
Greenfoot back
ScratchMan
ScratchMan wrote ...

2013/2/25

How do you get a bullet to fire in the direction that the gun is pointing?

1
2
davmac davmac

2013/3/4

#
I agree. Spitfire should not be a subclass of Bullet and should not extend Bullet.
DylMan62 DylMan62

2015/3/11

#
forteddyt wrote...
Found it! After about 15 min of trying to get the same error as you, I think I've figured it out. This SHOULD be whats wrong : In the 'Gun' class under the " public void act() " in the code : if(Greenfoot.isKeyDown("space") ) { getWorld().addObject(new Bullet(getRotation()), getX(), getY()); } Your : getWorld().addObject(new Bullet(getRotation()), getX(), getY()); is probably missing the " getRotation() " in the " (new Bullet(getRotation()), getX(), getY()); " Without the " getRotation() " you get that error message. Hope this fixes it! :D I have that but it comes up with the same error, but different, if you are still following. The error message is: constructor Bullet in class Bullet cannot be applied to given types; required: no arguments; found: int; reason: actual and formal argument lists differ in length PLEASE HELP!!!!!!!!!!!!!!!!
HiItsMe HiItsMe

2015/9/25

#
DylMan62 wrote...
forteddyt wrote... Found it! After about 15 min of trying to get the same error as you, I think I've figured it out. This SHOULD be whats wrong : In the 'Gun' class under the " public void act() " in the code : if(Greenfoot.isKeyDown("space") ) { getWorld().addObject(new Bullet(getRotation()), getX(), getY()); } Your : getWorld().addObject(new Bullet(getRotation()), getX(), getY()); is probably missing the " getRotation() " in the " (new Bullet(getRotation()), getX(), getY()); " Without the " getRotation() " you get that error message. Hope this fixes it! :D I have that but it comes up with the same error, but different, if you are still following. The error message is: constructor Bullet in class Bullet cannot be applied to given types; required: no arguments; found: int; reason: actual and formal argument lists differ in length PLEASE HELP!!!!!!!!!!!!!!!!
I got the same error by defining the bullet function with a "void" in it. Did you accidentally write void in the function definition? It should be public Bullet(int dir), not public void Bullet(int dir).
davmac davmac

2015/9/26

#
HiltsMe: please check the dates on the posts. This discussion ended years ago (other than a single post several months ago).
has anyone figured it out yet
davmac davmac

2016/1/26

#
Apocalypse_Auxillitrax wrote...
has anyone figured it out yet
Please open a new thread with details of the problem you're facing instead of reviving this very old discussion thread.
handfive handfive

2016/8/14

#
Hello How do i make the man to shoot out a strawberry?
danpost danpost

2016/8/14

#
handfive wrote...
Hello How do i make the man to shoot out a strawberry?
As previously requested in this discussion thread:
davmac wrote...
< Quote Omitted > Please open a new thread with details of the problem you're facing instead of reviving this very old discussion thread.
Also, follow the general rules about posing a question within the discussion thread. Show attempted code and explain in detail what you are trying to do and what issue you are having with it.
handfive handfive

2016/8/15

#
OK, sorry i just got my account yesterday 14/08/2016.
handfive handfive

2016/8/15

#
Sorry, i am from china and i don't really understand
Super_Hippo Super_Hippo

2016/8/15

#
Click on "Discuss" and write a text into the "Start a Discussion" field (and the field below) to start a new discussion.
You need to login to post a reply.
1
2