OLD | NEW |
| (Empty) |
1 part of game; | |
2 | |
3 const double _steeringThreshold = 0.0; | |
4 const double _steeringMax = 150.0; | |
5 | |
6 class GameDemoBox extends SpriteBox { | |
7 | |
8 GameDemoBox(GameDemoWorld game) : super(game, SpriteBoxTransformMode.letterbox
); | |
9 | |
10 GameDemoWorld get _gameWorld => this.rootNode; | |
11 | |
12 // Handle pointers | |
13 int _firstPointer = -1; | |
14 int _secondPointer = -1; | |
15 Point _firstPointerDownPos; | |
16 | |
17 // void handleEvent(Event event, BoxHitTestEntry entry) { | |
18 // if (event is PointerEvent) { | |
19 // Point pointerPos = new Point(event.x, event.y); | |
20 // int pointer = event.pointer; | |
21 // | |
22 // switch (event.type) { | |
23 // case 'pointerdown': | |
24 // if (_firstPointer == -1) { | |
25 // // Assign the first pointer | |
26 // _firstPointer = pointer; | |
27 // _firstPointerDownPos = pointerPos; | |
28 // } | |
29 // else if (_secondPointer == -1) { | |
30 // // Assign second pointer | |
31 // _secondPointer = pointer; | |
32 // _gameWorld.controlFire(); | |
33 // } | |
34 // else { | |
35 // // There is a pointer used for steering, let's fire instead | |
36 // _gameWorld.controlFire(); | |
37 // } | |
38 // break; | |
39 // case 'pointermove': | |
40 // if (pointer == _firstPointer) { | |
41 // // Handle turning control | |
42 // double joystickX = 0.0; | |
43 // double deltaX = pointerPos.x - _firstPointerDownPos.x; | |
44 // if (deltaX > _steeringThreshold || deltaX < -_steeringThreshold) { | |
45 // joystickX = (deltaX - _steeringThreshold)/(_steeringMax - _steer
ingThreshold); | |
46 // if (joystickX > 1.0) joystickX = 1.0; | |
47 // if (joystickX < -1.0) joystickX = -1.0; | |
48 // } | |
49 // | |
50 // double joystickY = 0.0; | |
51 // double deltaY = pointerPos.y - _firstPointerDownPos.y; | |
52 // if (deltaY > _steeringThreshold || deltaY < -_steeringThreshold) { | |
53 // joystickY = (deltaY - _steeringThreshold)/(_steeringMax - _steer
ingThreshold); | |
54 // if (joystickY > 1.0) joystickY = 1.0; | |
55 // if (joystickY < -1.0) joystickY = -1.0; | |
56 // } | |
57 // | |
58 // _gameWorld.controlSteering(joystickX, joystickY); | |
59 // } | |
60 // break; | |
61 // case 'pointerup': | |
62 // case 'pointercancel': | |
63 // if (pointer == _firstPointer) { | |
64 // // Un-assign the first pointer | |
65 // _firstPointer = -1; | |
66 // _firstPointerDownPos = null; | |
67 // _gameWorld.controlSteering(0.0, 0.0); | |
68 // } | |
69 // else if (pointer == _secondPointer) { | |
70 // _secondPointer = -1; | |
71 // } | |
72 // break; | |
73 // default: | |
74 // break; | |
75 // } | |
76 // } | |
77 // } | |
78 | |
79 } | |
OLD | NEW |