Coordinates on a full screen NO BORDER

  • efares
    Likes 0

    Problem Description

    Hi, I am using Cocos2d-JS v3.7 and building a Cocos game for mobile only. I have set my ResolutionPolicy to NO_BORDER.

    I have a button positioned cc.p(10, 10) and anchor set to (0, 0) so the button shows in the bottom left corner of the screen. With SHOW_ALL policy, the buttons has exactly 10 point spacing/padding from the edges however with NO_BORDER the button gets moved to outside the screen boundaries. This is expected because NO_BORDER expands the windowSize to fill in the entire screen space.

    So my question is how do I get the bottom left corner coordinates of the physical screen space of the phone that the game is running on? I would like to know how to position my button 10 points from the bottom/left edges of the physical screen.
    I have tried using getVisibilitySize() instead of getWindowSize() which I think works but then the Android buttons (back/home/running apps) offset the entire screen of the game. Is there a way with Cocos to make my game truly full screen?


  • Sonar Systems admin
    Likes 0

    You want to use Immersive mode which we will be adding very soon to our Cocos Helper http://sonarsystems.co.uk/cocoshelper.php as a simple function call


    This reply has been verified.
  • efares
    Likes 0

    Wow looks good! yes

    And in terms of getting the coordinates of the physical screen, is getVisibilitySize() the right way?
    Also when using NO_BORDER, is (0, 0) still the bottom left corner of the screen?


  • Sonar Systems admin
    Likes 0

    is it getVisibleSize()?


    This reply has been verified.
  • efares
    Likes 0

    Yes, you’re right. it is getVisibleSize()
    And I solved my coordinate system issue with NO_BORDER policy. I wasn’t using getVisibleOrigin() to get the bottom left corner of the physical screen.

    So when I set a position to cc.p(0, 0) my button was showing outside of the screen but when I used cc.p(cc.getVisibleOrigin().x, cc.getVisibleOrigin().y) it set my buttom to the bottom left corner of the physical screen.


  • Sonar Systems admin
    Likes 0

    Great to hear its all fixed :D


    This reply has been verified.

Login to reply