Edit sprite’s alpha per-camera view?

Discussion in 'Programming' started by Joe B-W, Jan 13, 2019.

  1. Joe B-W

    Joe B-W Member

    Joined:
    Jan 13, 2019
    Posts:
    4
    Hi all,

    I’m making my first split-screen couch multiplayer game; I’m currently looking to have some trees which obscure the players’ visions of characters go transparent *only* for the relevant pkayer’s camera.

    So, for example:
    Player 1 views the game through a viewport that takes up the top left corner. When their character is touching a tree and character.y < tree.y, I want to be able to set the tree’s alpha to 0.5 while keeping it at 1 in cameras 2-4.

    Is there a simple way of doing this? I’ve gotten to grips with cameras fairly well but I’m not too familiar with surfaces or anything like that yet.
     
  2. Danei

    Danei Member

    Joined:
    Mar 23, 2018
    Posts:
    278
    The draw event is run once for each view, so you should be able to use the built-in variable view_current in the draw event to check which view it's currently drawing, and adjust the alpha accordingly.
     
    HayManMarc likes this.
  3. Joe B-W

    Joe B-W Member

    Joined:
    Jan 13, 2019
    Posts:
    4
    Superb; I’ll give it a go. That seems simpler than I’d even hoped for.
     
  4. Joe B-W

    Joe B-W Member

    Joined:
    Jan 13, 2019
    Posts:
    4
    Nailed it - thanks @Danei

    Just had to make sure the draw sprite function was called after all the per-view jiggery-pokery.

    Where's-Wally-Meets-Bomberman is a tiny step closer to completion :D
     
    Danei likes this.

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