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

2014/3/5

add an Object with an other class' X-Y Coordinations.

enspired enspired

2014/3/5

#
We use Greenfoot to learn Java in school.(Germany) What i want to do: There is a ship and when i press the spacebar the ship shots an laser forward. But i can't create the Laser shot there, where my Ship was as i pressed the spacebar. My code looks like this, and it is in the Lasershot.class if(Greenfoot.isKeyDown("space")){ Schuss Schuss1 = new Schuss(); addObject(Schuss1,getX(),getY()+50); }
danpost danpost

2014/3/5

#
If 'getX' and 'getY' are for the coordinates of the ship, then should not this code go in the class of the ship??
Pointifix Pointifix

2014/3/5

#
am i allowed to ask which school in germany? im learning at an austrian school at the border to germany, but we only learn c/c++ at the moment, we wont go to java until 12th school level.
danpost danpost

2014/3/5

#
@Pointifix, I had occasioned to ski into Salzburg from Germany (back in 1983 -- while in US Army -- 'Adventure Training'). That should not be far from where you are at.
Pointifix Pointifix

2014/3/6

#
thats just a stone“s throw from me jeah ;) 1983, i was not yet on this world at that time ;) but nice, i love skiing, but it got really expensive last years
You need to login to post a reply.