ButtonAction select = ButtonAction.create( MouseButton.create( MouseButton.LEFT_BUTTON ) );
@Override
public void init() {
cursor = new Sprite(){
SpriteCollisionHandler handler = new SpriteCollisionHandler() {
@Override
public void handleCollision( Sprite sprite1, Sprite sprite2 ) {
selected = sprite2;
}
};
@Override
public void act() {
setMouseCoords();
if( select.wasPressed() ) {
selected = null;
collisionsWith( Layer, handler );
}
}
};
for( int n = 1; n <= spritesQuantity; n++ ) {
Sprite sprite = new Sprite( ShapeType.oval, Service.random( -15, 15 ), Service.random( -11, 11 ), 0d, 0d, 1d, Service.random( 360 ) );
sprite.setDiameter( Service.random( 1, 3 ) );
sprite.visualizer.setRandomColor();
sprite.visualizer.image = spriteImage;
Layer.addLast( sprite );
}