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

2024/3/7

How can i spawn a actor like a bullet spawn on another actor

Thijn Thijn

2024/3/7

#
I tried spawning a bullet in a spaceship everytime you press space but it did not work i dont know how to spawn a bullet on a moving spaceship so maybe you guys can help me out
danpost danpost

2024/3/9

#
Thijn wrote...
I tried spawning a bullet in a spaceship everytime you press space but it did not work i dont know how to spawn a bullet on a moving spaceship so maybe you guys can help me out
In the class of the spaceship, use something like the following:
Actor bullet = new Bullet();
getWorld().addObject(bullet, getX(), getY());
You may also need the following:
bullet.setRotation(getRotation());
You need to login to post a reply.