How do I solve my scaling issue?

0 favourites
  • 10 posts
  • Hi,

    I’ve been searching the forum and attempting to resolve an issue I have for a couple of days now with no joy.

    I have a dilemma regarding Window/Layout size and scaling. I’m a total newbie and hopefully I’m being an idiot and there’s an easy solution.

    Basically, I want my game to look professional on iPad to iPhone 5. I have an object which reacts with the edge of the screen. To achieve this I’ve used a sprite placed off the edge of the layout for the object to collide with.

    However, if I use aspect ratio whereby the layout size is greater than the window size the edge sprite on different screen ratios will not be placed in the correct position (screen edge) for the object to collide with. I want the object to be able to move off the top of the screen but react with the edges.

    Please can anyone help or provide some insight?

    Much appreciated.

  • A better way to achieve this would be to check the objects coordinates.

    If objects X<=object.width the object is on the left side

    If objects X>=layout width - object.width // the object is on the right side

    If objects Y>=object.height // the object is on the top side

    If objects Y>=layout height - object.height // the object is on the bottom side

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply.

    I haven't checked but aren't the co-ordinates based on screen size anyway? So I would have the same issue as the coordinates on 16:9 ratio would differ from 4:3?

  • You have to use the viewport. But I don't exactly now how to do this. Or maybe the window width/height operators.

  • Thanks I'll look into this I'm just hoping someone can tell me a way so that when using aspect ratio and the sides are cropped on 4:3 the object can recognise the edge of the screen.

  • I searched for viewport an found this: https://www.scirra.com/manual/28/layer

    layer.viewLeft

    layer.viewRight

    layer.viewTop

    layer.viewBottom

    This are the commands. So I assume instead of layout width it would be layer.viewRight .

  • Thanks again. However, do you know if there is a screen/window command? As for 4:3 I don't believe you would see the full layout and this may not work. I will try this though. Thanks

    I won't get a chance to test this until tomorrow but I'll post again as soon as I've tested it. Many Thanks.

  • This would be window.width.

  • Hi just to let you know I've managed to sort it using:

    ViewportLeft(layer)

    ViewportRight(layer)

    Thanks for your help.

  • No problem. Good to know, thanks.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)