Java Reference
In-Depth Information
}
return hit;
}
// We have to have this method to fulfill the MouseListener contract
@Override
public void mouseClicked(MouseEvent e) {
}
// We have to have this method to fulfill the MouseListener contract
@Override
public void mouseEntered(MouseEvent e) {
}
// We have to have this method to fulfill the MouseListener contract
@Override
public void mouseExited(MouseEvent e) {
}
// We have to have this method to fulfill the MouseListener contract
@Override
public void mousePressed(MouseEvent e) {
}
// Here's where we check for mouse clicks
@Override
public void mouseReleased(MouseEvent e) {
if(readyToShoot){
// If ready to shoot, process the shot
setReadyToShoot(false);
analyzeShot(e.getY());
}
// If not ready to shoot, do nothing
}
// We have to have this method to fulfill the MouseMotionListener contract
@Override
public void mouseDragged(MouseEvent e) {
}
// Here's where we listen for mouse movement and use
// the setY method to update the cursor's position
@Override
public void mouseMoved(MouseEvent e) {
setY(e.getY());
}
// process a tick from the timer (in ShootingGalleryPanel)
public void tick() {
if (currentStep < maxSteps) {
// If we're still drawing the cursor after a shot, then increment
// the step counter and ensure that the player can't shoot yet
Search WWH ::




Custom Search