Is this the right way?

  • Direee
    Likes 0

    Problem Description

    Hi, I just followed your recent tutorial for multi device. I was wondering, let’s say in the image above, (A) is the background and (B) is a button. I tried positioning it using visiblesize and origin but as expected it would not work because different aspect ratio would produce different position. I then tried hardcoding the position, it works but i am not sure if it is the right way to do it or is there a better way?

  • Sonar Systems admin
    Likes 0

    What code are you using for positioning?


    This reply has been verified.
  • Direee
    Likes 0

    Basically it’s just btn->setPosition(Vec2(150.0f, visibleSize.height / 2 + origin.y));

  • Sonar Systems admin
    Likes 0

    You said it would not work as expected, why did you expect it not to work?


    This reply has been verified.
  • Direee
    Likes 0

    Well using visibleSize and origin would position items according to the device screen size. But because my background (A) has sort of a menu border (Yellow Area), I would like to position it at the side of the menu border (like the image i have posted). If i position the button for an iphone 5, it would be fine for other 16:9 ratio device. But if i test it on an ipad, the position of the button would not be at the side of the menu border.


  • Sonar Systems admin
    Likes 0

    Can you post an image from an iPad.


    This reply has been verified.
  • Direee
    Likes 0

    Haha i think it’s okay, I’ve figure that this is the best way and looks the same on all devices

  • Sonar Systems admin
    Likes 0

    Great :D

Login to reply