v0.8.1: adjusted logic and added alpha settings for buttons

This commit is contained in:
Evan Debenham 2020-06-07 17:34:50 -04:00
parent a77de584dd
commit ee260a2559
2 changed files with 8 additions and 32 deletions

View File

@ -30,45 +30,15 @@ import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.ui.Button; import com.watabou.noosa.ui.Button;
public class ExitButton extends Button { public class ExitButton extends IconButton {
protected Image image;
public ExitButton() { public ExitButton() {
super(); super(Icons.EXIT.get());
width = 20; width = 20;
height = 20; height = 20;
} }
@Override
protected void createChildren() {
super.createChildren();
image = Icons.EXIT.get();
add( image );
}
@Override
protected void layout() {
super.layout();
image.x = x + (width - image.width)/2f;
image.y = y + (height - image.height)/2f;
PixelScene.align(image);
}
@Override
protected void onPointerDown() {
image.brightness( 1.5f );
Sample.INSTANCE.play( Assets.Sounds.CLICK );
}
@Override
protected void onPointerUp() {
image.resetColor();
}
@Override @Override
protected void onClick() { protected void onClick() {
if (Game.scene() instanceof TitleScene) { if (Game.scene() instanceof TitleScene) {

View File

@ -124,6 +124,12 @@ public class StyledButton extends Button {
return icon; return icon;
} }
public void alpha(float value){
if (icon != null) icon.alpha(value);
if (bg != null) bg.alpha(value);
if (text != null) text.alpha(value);
}
public float reqWidth() { public float reqWidth() {
float reqWidth = 0; float reqWidth = 0;
if (icon != null){ if (icon != null){