small improvements
|
@ -15,13 +15,16 @@ public class MainActivity extends AppCompatActivity implements JoyStick.JoyStick
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
gameView = (GameView) findViewById(R.id.game);
|
||||
((JoyStick)findViewById(R.id.joy1)).setListener(this);
|
||||
((JoyStick)findViewById(R.id.joy1)).setPadColor(Color.parseColor("#55ffffff"));
|
||||
((JoyStick)findViewById(R.id.joy1)).setButtonColor(Color.parseColor("#55ff0000"));
|
||||
((JoyStick)findViewById(R.id.joy2)).setListener(this);
|
||||
((JoyStick)findViewById(R.id.joy2)).enableStayPut(true);
|
||||
((JoyStick)findViewById(R.id.joy2)).setButtonSize(50);
|
||||
((JoyStick)findViewById(R.id.joy2)).setButtonDrawable(R.drawable.droid);
|
||||
JoyStick joy1 = (JoyStick) findViewById(R.id.joy1);
|
||||
joy1.setListener(this);
|
||||
joy1.setPadColor(Color.parseColor("#55ffffff"));
|
||||
joy1.setButtonColor(Color.parseColor("#55ff0000"));
|
||||
|
||||
JoyStick joy2 = (JoyStick) findViewById(R.id.joy2);
|
||||
joy2.setListener(this);
|
||||
joy2.enableStayPut(true);
|
||||
joy2.setPadBackground(R.drawable.pad);
|
||||
joy2.setButtonDrawable(R.drawable.button);
|
||||
}
|
||||
|
||||
@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);
|
||||
canvas.drawCircle(centerX, centerY, radius, paint);
|
||||
} 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);
|
||||
}
|
||||
if (buttonBitmap == null) {
|
||||
|
@ -219,8 +219,8 @@ public class JoyStick extends View {
|
|||
|
||||
//size of button is a percentage of the minimum(width, height)
|
||||
//percentage must be between 25 - 50
|
||||
public void setButtonSize(int p) {
|
||||
percentage = p;
|
||||
public void setButtonRadiusScale(int scale) {
|
||||
percentage = scale;
|
||||
if (percentage > 50) percentage = 50;
|
||||
if (percentage < 25) percentage = 25;
|
||||
}
|
||||
|
|