0 Favourites

scale globals and locals

  • When setting scale mode on everything gets scaled to fit the browser window. Very nice! But what happens to nummeric variables?

    Suppose I have an action which adds 80 pixels to the Y coordinate of a sprite. In scale mode I will have to use a variable to calculate the amount (80 * layoutscale). Can this be done on start of layout or should it be done on every tick?

    Would it be possible to introduce a scaling nummeric variable to avoid the event sheet getting cluttered with recalculations?

    Regards,

    Jeroen

  • You don't need to use layoutscale in your movement calculations! The scaling only affects the display - how existing movements are shown. You do not need to change how you move objects!

  • Sorry, but I do not understand this. When I move an object 100 pixels on a screen which is 1000 pixels heigh, the amount of movement is 10 percent. When screen height is 500 then 100 pixels movement is 20 percent. I never was any good at math, but it seems to me the result would look different on the screen even when the sprite itself has been scaled to half its original size.

    Suppose the original sprite is 100 X 100 pixels at y 800 (80%). Moving it 100 pixels, it is still visible at y 900. Scaling the layout by half would result in a sprite 50 x 50 at 400 (still 80%) Moving this 100 pixels the sprite would go off screen. Or do I make a logical mistake?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • You're just not quite thinking about this right. There's a big difference between game co-ordinates and screen co-ordinates. When you change an object's position you change its position in game co-ordinates. These are not the same as pixels on the monitor! All the scaling feature does is stretch what's in the game.

    So for example: moving an object by 100 moves it in the game by 100 pixels. On a monitor 1000 pixels tall, this is 10% of the screen. On a monitor 500 pixels tall, the scale would be 50% due to the scaling feature, so it moves 50 pixels on-screen, which is still 10% of the screen.

    The game happens independently of how it is drawn. Imagine you have no monitor at all! The game is still happening invisibly, and objects moving around in the computer's memory. Attaching monitors which display different parts of the game at different sizes does not affect those objects moving around in memory. So you don't need to worry about the scale at all when moving objects, or in fact in any of the game logic.

  • Thank you Ashley for explaining this. Indeed I assumed game coordinates to be screen coordinates using pixels as unit. Well, this makes it a lot easier to develop games for different screen resolutions.

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