This site requires JavaScript, please enable it in your browser!
Greenfoot back
putuardi@smkn1klk.sch.id
putuardi@smkn1klk.sch.id wrote ...

2016/10/25

How to (shoot misil from plane when mouse click) ?

How to (shoot misil from plane when mouse click) Like Demonstar Game
danpost danpost

2016/10/25

#
putuardi@smkn1klk.sch.id wrote...
How to (shoot misil from plane when mouse click) Like Demonstar Game
Condition for shooting is that the mouse is clicked (anywhere). Actor object creates projectile, places it in world (at location of self, with possible adjustments, and sets its rotation to that of self:
// possible method called by act of class of plane
private void shootMissile()
{
    if (Greenfoot.mouseClicked(null))
    {
        Missile missile = new Missile();
        getWorld().addObject(missile, getX(), getY());
        missile.setRotation(getRotation());
    }
}
This may not be like Demonstar, as I am not familiar with it. You will have to explain what you want for possible corrections in behavior.
You need to login to post a reply.