Hi guys I need some help with some code, I need to make it so that every time a bullet is created it waits some time before creating another one. At the moment it will create loads per second, even if i just touch a key for a split second. Here is the code, anyone know how to do what I want? Or is it not possible?
{
public void act()
{
move(7);
disappear();
if (getWorld() == null)return;
collisionDetection();
//colision detection and point awarding
//create bullet object
}
public void collisionDetection()
{
Actor Key = getOneIntersectingObject(Key.class);
if (Key != null)
{ // We've hit an asteroid!
hitObject();
getWorld().removeObject(Key);
getWorld().removeObject(this);
}
} //make bullet disappear
public void disappear()
{
if( getX() <= 4 || getX() >= getWorld().getWidth()-2)
{
getWorld().removeObject(this);
return;
}
if( getY() <= 4 || getY() >= getWorld().getHeight()-2)
{
getWorld().removeObject(this);
return;
}
}
public void hitObject()
{
menu menuWorld = (menu) getWorld();
Counter counter = menuWorld.getCounter();
counter.scoreCount(5);
}
}
