OLD | NEW |
1 part of game; | 1 part of game; |
2 | 2 |
3 const double _steeringThreshold = 20.0; | 3 const double _steeringThreshold = 20.0; |
4 const double _steeringMax = 50.0; | 4 const double _steeringMax = 50.0; |
5 | 5 |
6 class GameBox extends SpriteBox { | 6 class GameBox extends SpriteBox { |
7 | 7 |
8 GameBox(GameWorld game) : super(game, SpriteBoxTransformMode.letterbox); | 8 GameBox(GameWorld game) : super(game, SpriteBoxTransformMode.letterbox); |
9 | 9 |
10 GameWorld get _gameWorld => this.rootNode; | 10 GameWorld get _gameWorld => this.rootNode; |
11 | 11 |
12 // Handle pointers | 12 // Handle pointers |
13 int _firstPointer = -1; | 13 int _firstPointer = -1; |
14 int _secondPointer = -1; | 14 int _secondPointer = -1; |
15 Vector2 _firstPointerDownPos; | 15 Vector2 _firstPointerDownPos; |
16 | 16 |
17 void handleEvent(Event event) { | 17 void handleEvent(Event event, BoxHitTestData data) { |
18 if (event is PointerEvent) { | 18 if (event is PointerEvent) { |
19 Vector2 pointerPos = new Vector2(event.x, event.y); | 19 Vector2 pointerPos = new Vector2(event.x, event.y); |
20 int pointer = event.pointer; | 20 int pointer = event.pointer; |
21 | 21 |
22 switch (event.type) { | 22 switch (event.type) { |
23 case 'pointerdown': | 23 case 'pointerdown': |
24 if (_firstPointer == -1) { | 24 if (_firstPointer == -1) { |
25 // Assign the first pointer | 25 // Assign the first pointer |
26 _firstPointer = pointer; | 26 _firstPointer = pointer; |
27 _firstPointerDownPos = pointerPos; | 27 _firstPointerDownPos = pointerPos; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 _gameWorld.controlThrust(null); | 62 _gameWorld.controlThrust(null); |
63 } | 63 } |
64 break; | 64 break; |
65 default: | 65 default: |
66 break; | 66 break; |
67 } | 67 } |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 } | 71 } |
OLD | NEW |