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

2017/4/2

Call Method in other class

iban iban

2017/4/2

#
example i have two class, robot class and bullet class. in robot class i have method run. the problem, how i can call the method run for bullet class??
danpost danpost

2017/4/2

#
Maybe you are not aware that to get anything to work during gameplay (while the scenario is in a running state),, you need to put some code in an 'act' method. All subclasses of World and Actor have one and you can have the robot shoot (in Robot class):
public void act()
{
    shoot();
}
or a bullet move (in Bullet class):
public void act()
{
    move(5);
}
The act method of the active world and the act method of every actor in that world are each called every act cycle to run the simulation.
iban iban

2017/4/2

#
mr. whay this not work? public void jalan() { if (Greenfoot.mousePressed(buttonshoot.class)) { getWorld().addObject(bullet.class); } } i want make game for control use button. (mouseclicked / mousePressed) not isKeyDown(). the prolem that code not work please help me :)
iban iban

2017/4/2

#
give me example program all control use button or mousePressed for move, shoot or any .. pleaseeeeee
danpost danpost

2017/4/2

#
iban wrote...
give me example program all control use button or mousePressed for move, shoot or any .. pleaseeeeee
I explained this here.
You need to login to post a reply.