small improvements

This commit is contained in:
edgar 2015-11-02 18:05:00 -08:00
parent 80e0dca5f8
commit 6505465c00
12 changed files with 13 additions and 10 deletions

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -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;
}