flutterdartflame

How to make the origin (0,0) point in flame engine in the bottom


I want to make the origin point in the bottom-left corner instead of the top-left corner


Solution

  • You can easily set the origin of the World to the bottom corner by moving the camera so that 0,0 of the World is in the bottom corner of the viewport, two different ways to do so are:

    camera.position = Vector2(
      camera.viewport.size.x / 2,
      -camera.viewport.size.y / 2,
    );
    

    Or if you don't care about where the viewfinder anchor is, you can simply do this (if you are using the follow method, you probably don't want to do this):

    camera.viewfinder.anchor = Anchor.bottomLeft;
    

    Even though you're not stating it in your question, I'm guessing that you also want the flip the coordinate system, so that Y grows upwards instead of shrinks, this is much harder to achieve.