How Can you check, if the mouse has been scrolled?
import greenfoot.core.WorldHandler;
import java.awt.event.*;
public class world extends World
{
ScrollingListener scroll=new ScrollingListener();
int Scroll = 0;
public world()
{
super(500, 400, 1,false);
WorldHandler.getInstance().getWorldCanvas().addMouseWheelListener(scroll);
}
public void act()
{
Scroll+=scroll.getScroll();
}
}
class ScrollingListener implements MouseWheelListener
{
int scroll = 0;
public void mouseWheelMoved(MouseWheelEvent MWE)
{
scroll+=MWE.getWheelRotation();
MWE.consume();
}
public int getScroll()
{
int a=scroll;
scroll=0;
return a;
}
}int a=scroll; scroll=0; return a;
if(scroll.getScroll()!=0)
{
System.out.println(scroll.getScroll());
}int s=scroll.getScroll();
if(s!=0)
{
System.out.println(s);
}private int scrollValue;
private int scrollHiLimit = 15;
private int scrollLoLimit = 0;
//
public void act()
{
scrollValue += scroll.getScroll();
if (scrollValue > scrollHiLimit) { scrollValue = scrollHiLimit; }
if (scrollValue < scrollLoLimit) { scrollValue = scrollLoLimit; }
}class ScrollingListener implements MouseWheelListener
{
int scroll = 0;
public synchronized void mouseWheelMoved(MouseWheelEvent MWE)
{
scroll+=MWE.getWheelRotation();
MWE.consume();
}
public synchronized int getScroll()
{
int a=scroll;
scroll=0;
return a;
}
}