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); 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

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