forked from flame-engine/flame
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flame): Set a default negative priority on the world for general…
… use (flame-engine#2572)
- Loading branch information
1 parent
3cdef95
commit 390e970
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flame/camera.dart'; | ||
import 'package:flame/components.dart'; | ||
import 'package:flame_test/flame_test.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('World', () { | ||
testWithFlameGame( | ||
'by default it has a negative max 32bit int priority', | ||
(game) async { | ||
final world = World()..addToParent(game); | ||
final camera = CameraComponent(world: world)..addToParent(game); | ||
await game.ready(); | ||
|
||
expect(world.priority, equals(-0x7fffffff)); | ||
expect(game.children, equals([world, camera])); | ||
}, | ||
); | ||
|
||
testWithFlameGame( | ||
'with a custom priority putting it in front of the camera in the tree', | ||
(game) async { | ||
final world = World(priority: 4)..addToParent(game); | ||
final camera = CameraComponent(world: world)..addToParent(game); | ||
await game.ready(); | ||
|
||
expect(world.priority, equals(4)); | ||
expect(game.children, equals([camera, world])); | ||
}, | ||
); | ||
}); | ||
} |