-
-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: Move Forge2DGame
to use CameraComponent
#2728
Conversation
…o-cameracomponent
…o-cameracomponent
…o-cameracomponent
…o-cameracomponent
…o-cameracomponent
@@ -102,15 +102,15 @@ class Car extends BodyComponent<PadRacingGame> { | |||
final isLeftTire = i.isEven; | |||
return Tire( | |||
car: this, | |||
pressedKeys: gameRef.pressedKeySets[playerNumber], | |||
pressedKeys: game.pressedKeySets[playerNumber], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the rename from gameRef to game?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is from the really old Pasha PR where we are moving from the HasGameRef
mixin to HasGameReference
.
@@ -58,13 +57,13 @@ class PadRacingGame extends Forge2DGame with KeyboardEvents { | |||
|
|||
@override | |||
Future<void> onLoad() async { | |||
super.onLoad(); | |||
cameraComponent.removeFromParent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine this is because it gets re-added later and you want to call onLoad to reset the game? just curious what breaks if you just leave the camera there as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This camera isn't used, it uses several other cameras later instead.
|
||
final Vector2 position; | ||
final Vector2 _position; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imagine things like this and initialPosition are to avoid conflict with a position defined on BodyComponent.
but why can't we just use that position for everything? where do components need to keep a separate track of a second position?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because position
is a read-only on BodyComponent
since it is a getter from the Body
.
examples/lib/stories/bridge_libraries/flame_forge2d/animated_body_example.dart
Outdated
Show resolved
Hide resolved
examples/lib/stories/bridge_libraries/flame_forge2d/joints/weld_joint.dart
Outdated
Show resolved
Hide resolved
…o-cameracomponent
Description
This enables flame_forge2d to work with the
CameraComponent
and the new event system.Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?
Migration instructions
Forge2DGame.world
instead of directly to the root of the game.Forge2DGame.cameraComponent
instead of fromForge2DGame.camera
.Related Issues
Closes #2547
Closes #2606
Closes #2587
Closes #2491