Objects in the draw gui layer are rotating with camera view.

Discussion in 'Programming' started by evildead9000, Jul 10, 2019 at 10:05 PM.

  1. evildead9000

    evildead9000 Member

    Joined:
    Nov 20, 2017
    Posts:
    57
    I have an object in my game room, which was created in the draw gui Layer. I also have a camera view.
    However, the object rotates with the camera, which to my understanding should not. I though the gui layer wasn't affected by the camera view. Text drawn on the gui layer (like my score ) does not rotate, and is fine as is.

    Additionally, if I draw a sprite to the gui layer it does not rotate with the camera, but then my collisions are messed up.

    Is there a way to stop the object from rotation with the camera? Do I need to set-up another camera? Is there a simple way to detect collisions with the sprite if I go that route?

    I'm not quite sure how to move forward. Sprites and text are fine, but I would like to use an object, which will not rotate with the camera. Any advice would be much appreciated.

    Thanks!
     
  2. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    616
    You don't create objects (or better, instances) in the gui layer, you just draw them. Not sure what you mean by creating in this context. Everything that is drawn in the draw gui event is not affected by the camera either, so if one of your instances moves or rotates with it, you are doing something wrong.

    First of all I'd check that everything you want to draw in the gui layer does that in its own draw gui event. If so, ensure that you also have an empty regular draw event (otherwise you are drawing the object twice, one normally and affected by the camera, and one in the gui layer).

    Collision detection for instances in the gui layer is a bit tricky, but keep in mind that how and where you draw the sprite in the gui layer has no impact on your collisions. Collisions are computed based on the instance position and sprite in the room, not in the gui. If you want to interact with an instance based on its gui position, you will need to use device_mouse_x_to_gui and device_mouse_y_to_gui . Pixelated Pope has an awesome tutorial on youtube that shows, among other things, how you can handle this:
     
    evildead9000 and Amon like this.
  3. evildead9000

    evildead9000 Member

    Joined:
    Nov 20, 2017
    Posts:
    57
    It is an awesome tutorial and clarifies a lot. Thanks Catan!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice