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

2019/5/1

I think its called "access to another class??" idk

Khypex Khypex

2019/5/1

#
Hello everyone. Im very new and i have a problem.. I wanted to make a project where my rover can throw strawberrys which doesnt works... Heres my implementation: public void erdbeereWerfen() { if(anzahlErdbeere>0); {Erdbeere wurfErdbeere = new Erdbeere(); if(Greenfoot.isKeyDown("e")) wurfErdbeere.setLocation(getX(), getY()-2); if(Greenfoot.isKeyDown("f")) wurfErdbeere.setLocation(getX(), getY()+2); if(Greenfoot.isKeyDown("r")) wurfErdbeere.setLocation(getX()+2, getY()); if(Greenfoot.isKeyDown("q")) wurfErdbeere.setLocation(getX()-2, getY()); } } so the other class is called "Erdbeere". and as you can see the problem is my access to the other class. so i wrote: wurfErdbeere.setLocation(getX(), getY()-2); i rewrote the keyword "this" to "wurfErdbeere which is wrong.. so can anyone help me please?
danpost danpost

2019/5/1

#
You cannot set the location of an object before it is placed into a world. Nowhere do I see the actor created on your 4th line added into a world.
Khypex Khypex

2019/5/1

#
so its impossible creating an object from another, while the game is running?
danpost danpost

2019/5/1

#
Khypex wrote...
so its impossible creating an object from another, while the game is running?
I did not say that. In fact you did create one. You just did not add it into the world.
You need to login to post a reply.