v0.8.1: adjusted logic and added alpha settings for buttons
This commit is contained in:
parent
a77de584dd
commit
ee260a2559
|
@ -30,45 +30,15 @@ import com.watabou.noosa.Image;
|
|||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
|
||||
public class ExitButton extends Button {
|
||||
|
||||
protected Image image;
|
||||
public class ExitButton extends IconButton {
|
||||
|
||||
public ExitButton() {
|
||||
super();
|
||||
super(Icons.EXIT.get());
|
||||
|
||||
width = 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
|
||||
protected void onClick() {
|
||||
if (Game.scene() instanceof TitleScene) {
|
||||
|
|
|
@ -123,6 +123,12 @@ public class StyledButton extends Button {
|
|||
public Image 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() {
|
||||
float reqWidth = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user