[client] gamepad: update SmartActionAreaBuilder
This commit is contained in:
@@ -50,6 +50,7 @@ class SettingsStorage extends SharedObjectStorage {
|
||||
MOVE(Direction.RIGHT) => null,
|
||||
SHOT(0) => null,
|
||||
SHOT(1) => null,
|
||||
SHOT(2) => null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ views:
|
||||
- $type: haxework.view.form.ButtonView
|
||||
style: button.close
|
||||
geometry.position: absolute
|
||||
geometry.hAlign: right
|
||||
geometry.vAlign: bottom
|
||||
geometry.hAlign: left
|
||||
geometry.vAlign: top
|
||||
geometry.margin: 10
|
||||
+onPress: ~close()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.m.tankz.view.gamepad;
|
||||
|
||||
import haxework.view.geometry.Box;
|
||||
import ru.m.control.DeviceAction;
|
||||
import ru.m.geom.Circle;
|
||||
import ru.m.geom.Direction;
|
||||
@@ -12,36 +13,36 @@ class SmartActionAreaBuilder implements IActionAreaBuilder {
|
||||
public function build(width:Float, height:Float):Array<IActionArea> {
|
||||
var areas:Array<IActionArea> = [];
|
||||
var size = Math.min(width, height) / 5;
|
||||
var padding = size / 3;
|
||||
var padding = Box.fromArray([size / 4, size / 3]);
|
||||
// top
|
||||
areas.push(new RhombusActionArea(
|
||||
DIRECTION(Direction.TOP),
|
||||
new Rectangle(padding + size * 0.5, height - size * 2 - padding, size, size )
|
||||
new Rectangle(padding.left + size * 0.5, height - size * 2 - padding.bottom, size, size )
|
||||
));
|
||||
// left
|
||||
areas.push(new RhombusActionArea(
|
||||
DIRECTION(Direction.LEFT),
|
||||
new Rectangle(padding, height - size * 1.5 - padding, size, size)
|
||||
new Rectangle(padding.left, height - size * 1.5 - padding.bottom, size, size)
|
||||
));
|
||||
// bottom
|
||||
areas.push(new RhombusActionArea(
|
||||
DIRECTION(Direction.BOTTOM),
|
||||
new Rectangle(padding + size * 0.5, height - size - padding, size, size)
|
||||
new Rectangle(padding.left + size * 0.5, height - size - padding.bottom, size, size)
|
||||
));
|
||||
// right
|
||||
areas.push(new RhombusActionArea(
|
||||
DIRECTION(Direction.RIGHT),
|
||||
new Rectangle(padding + size, height - size * 1.5 - padding, size, size)
|
||||
new Rectangle(padding.left + size, height - size * 1.5 - padding.bottom, size, size)
|
||||
));
|
||||
// key 0
|
||||
areas.push(new CircleActionArea(
|
||||
KEY(0),
|
||||
new Circle(width - size * 1 - padding, height - size * 0.5 - padding, size / 2)
|
||||
new Circle(width - size * 0.5 - padding.right, height - size * 0.5 - padding.bottom, size / 2)
|
||||
));
|
||||
// key 1
|
||||
areas.push(new CircleActionArea(
|
||||
KEY(1),
|
||||
new Circle(width - size * 1 - padding, height - size * 1.5 - padding, size / 2)
|
||||
new Circle(width - size * 0.5 - padding.right, height - size * 1.5 - padding.bottom, size / 2)
|
||||
));
|
||||
return areas;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user