|
|
@ -50,8 +50,8 @@ public class Joystick extends SurfaceView implements SurfaceHolder.Callback, Vie
|
|
|
|
{
|
|
|
|
{
|
|
|
|
centerX = getWidth() / 2;
|
|
|
|
centerX = getWidth() / 2;
|
|
|
|
centerY = getHeight() / 2;
|
|
|
|
centerY = getHeight() / 2;
|
|
|
|
baseRadius = Math.min(getWidth(), getHeight()) / 3;
|
|
|
|
baseRadius = Math.min(getWidth(), getHeight()) / 4;
|
|
|
|
hatRadius = Math.min(getWidth(), getHeight()) / 5;
|
|
|
|
hatRadius = Math.min(getWidth(), getHeight()) / 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//method to be called when Joystick surface is created
|
|
|
|
//method to be called when Joystick surface is created
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -71,7 +71,7 @@ public class Joystick extends SurfaceView implements SurfaceHolder.Callback, Vie
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void surfaceDestroyed(SurfaceHolder surfaceHolder)
|
|
|
|
public void surfaceDestroyed(SurfaceHolder surfaceHolder)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
UserHandler.getInstance().disconnect();
|
|
|
|
//nothing...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*when Joystick is touched, method will be called and will compute values to be sent as
|
|
|
|
/*when Joystick is touched, method will be called and will compute values to be sent as
|
|
|
|
* arguments to the JoystickCallBack onJoystickMoved even handler*/
|
|
|
|
* arguments to the JoystickCallBack onJoystickMoved even handler*/
|
|
|
@ -112,10 +112,10 @@ public class Joystick extends SurfaceView implements SurfaceHolder.Callback, Vie
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Canvas drawCanvas = this.getHolder().lockCanvas();
|
|
|
|
Canvas drawCanvas = this.getHolder().lockCanvas();
|
|
|
|
Paint colors = new Paint();
|
|
|
|
Paint colors = new Paint();
|
|
|
|
drawCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
|
|
|
drawCanvas.drawColor(Color.WHITE);
|
|
|
|
colors.setARGB(255, 50, 50, 50);
|
|
|
|
colors.setARGB(175, 50, 50, 50);
|
|
|
|
drawCanvas.drawCircle(centerX, centerY, baseRadius, colors);
|
|
|
|
drawCanvas.drawCircle(centerX, centerY, baseRadius, colors);
|
|
|
|
colors.setARGB(255, 0, 0, 255);
|
|
|
|
colors.setARGB(200, 50, 50, 200);
|
|
|
|
drawCanvas.drawCircle(x, y, hatRadius, colors);
|
|
|
|
drawCanvas.drawCircle(x, y, hatRadius, colors);
|
|
|
|
getHolder().unlockCanvasAndPost(drawCanvas);
|
|
|
|
getHolder().unlockCanvasAndPost(drawCanvas);
|
|
|
|
}
|
|
|
|
}
|
|
|
|