How do I recalculate positions, depending on window size

0 favourites
  • 4 posts
From the Asset Store
Get Ready for the New Wave of "Bottom Screen" Games!
  • Hey there!

    I got a question about responsive design. So i got a fix screen size and i got a puzzle game, where the tiles will be sortet around the center of the screen. If the player changes the window size (brower window) would it be possible to recalc the position of the tiles, depending on the new window size? (The tiles should move to the right position)

    i dont want to scale down the game canvas, the tiles should be new calculated.

    I would need a behaviour which recognizes, if there is a new window size or something.

    Thank you very much.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could look into the Anchor behavior.

    Otherwise, WindowWidth and WindowHeight are system expressions you will want to use in the calculation of your tile's positions.

    The exact calculation depends on how many tiles you have and how you have set them already (through code or not ?)

    Provide your capx to get a more accurate answer in regards to how it is set up.

    Otherwise, check the How do I FAQ to see how to make a grid of tiles through events. This could help out.

  • Kyatric

    Thanks for your fast answer. Iam currently using the anchor behaviour, but this isnt working pretty well with litetween (if its activated, there is no tweening possible - because of the anchor behaviour). I disalbed, and enabled the anchor behaviour to tween the sprite, but i get an offset after activating the anchor again. And iam not sure why - so this combo isnt a good solution.

    Is there an option to run a function, if the window size is changed? I could code to reposition the sprites by myself. Do you know the best method to code the anchor behaviour?

    I would share the capx, but i cant, because its a project fo a customer.

  • So basically a solution where i could set the size of my objects depending on the ratio of the viewport size...

    That would be helpful...

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