small improvements
|
@ -15,13 +15,16 @@ public class MainActivity extends AppCompatActivity implements JoyStick.JoyStick
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
gameView = (GameView) findViewById(R.id.game);
|
gameView = (GameView) findViewById(R.id.game);
|
||||||
((JoyStick)findViewById(R.id.joy1)).setListener(this);
|
JoyStick joy1 = (JoyStick) findViewById(R.id.joy1);
|
||||||
((JoyStick)findViewById(R.id.joy1)).setPadColor(Color.parseColor("#55ffffff"));
|
joy1.setListener(this);
|
||||||
((JoyStick)findViewById(R.id.joy1)).setButtonColor(Color.parseColor("#55ff0000"));
|
joy1.setPadColor(Color.parseColor("#55ffffff"));
|
||||||
((JoyStick)findViewById(R.id.joy2)).setListener(this);
|
joy1.setButtonColor(Color.parseColor("#55ff0000"));
|
||||||
((JoyStick)findViewById(R.id.joy2)).enableStayPut(true);
|
|
||||||
((JoyStick)findViewById(R.id.joy2)).setButtonSize(50);
|
JoyStick joy2 = (JoyStick) findViewById(R.id.joy2);
|
||||||
((JoyStick)findViewById(R.id.joy2)).setButtonDrawable(R.drawable.droid);
|
joy2.setListener(this);
|
||||||
|
joy2.enableStayPut(true);
|
||||||
|
joy2.setPadBackground(R.drawable.pad);
|
||||||
|
joy2.setButtonDrawable(R.drawable.button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
BIN
app/src/main/res/drawable-hdpi/button.png
Executable file
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/drawable-hdpi/pad.png
Executable file
After Width: | Height: | Size: 4.3 KiB |
BIN
app/src/main/res/drawable-mdpi/button.png
Executable file
After Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-mdpi/pad.png
Executable file
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/drawable-xhdpi/button.png
Executable file
After Width: | Height: | Size: 2.7 KiB |
BIN
app/src/main/res/drawable-xhdpi/pad.png
Executable file
After Width: | Height: | Size: 6.4 KiB |
BIN
app/src/main/res/drawable-xxhdpi/button.png
Executable file
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/drawable-xxhdpi/pad.png
Executable file
After Width: | Height: | Size: 11 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/button.png
Executable file
After Width: | Height: | Size: 7.9 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/pad.png
Executable file
After Width: | Height: | Size: 14 KiB |
|
@ -137,7 +137,7 @@ public class JoyStick extends View {
|
||||||
paint.setColor(padColor);
|
paint.setColor(padColor);
|
||||||
canvas.drawCircle(centerX, centerY, radius, paint);
|
canvas.drawCircle(centerX, centerY, radius, paint);
|
||||||
} else {
|
} else {
|
||||||
temp.set(posX - radius, posY - radius, posX + radius, posY + radius);
|
temp.set(centerX - radius, centerY - radius, centerX + radius, centerY + radius);
|
||||||
canvas.drawBitmap(padBGBitmap, null, temp, paint);
|
canvas.drawBitmap(padBGBitmap, null, temp, paint);
|
||||||
}
|
}
|
||||||
if (buttonBitmap == null) {
|
if (buttonBitmap == null) {
|
||||||
|
@ -219,8 +219,8 @@ public class JoyStick extends View {
|
||||||
|
|
||||||
//size of button is a percentage of the minimum(width, height)
|
//size of button is a percentage of the minimum(width, height)
|
||||||
//percentage must be between 25 - 50
|
//percentage must be between 25 - 50
|
||||||
public void setButtonSize(int p) {
|
public void setButtonRadiusScale(int scale) {
|
||||||
percentage = p;
|
percentage = scale;
|
||||||
if (percentage > 50) percentage = 50;
|
if (percentage > 50) percentage = 50;
|
||||||
if (percentage < 25) percentage = 25;
|
if (percentage < 25) percentage = 25;
|
||||||
}
|
}
|
||||||
|
|