Jump to content

Scaling the game down


Recommended Posts

Hello, first post here! Phaser's been great so far and this is the first hangup I've really had.


The Problem


I have a number of (tile)maps of varying sizes made from 128 x 128px tiles. At this size, especially on particular devices, the whole game is way too big. The player can drag the camera around the map, but beyond 10x10 tiles it's really not ideal.


I'd like to be able to scale the whole game down to a smaller size. Ideally the user could zoom in and out at will but doing it as the game is created is acceptable.


My Question


...is there a recommended approach to solving this particular type of problem?


What I've tried


It looks like there are a few ideas out there about how to achieve this type of thing. I'm not against sprinkling a common scaling factor throughout my code if that's what it takes, as it doesn't seem like there's an easy way to do this at the top level yet.


So far, I've set my game size to match the dimensions of the visible window. Then I'm scaling the map layer, as well as sprites and their corresponding movement logic. For starters:

var gameScale = 0.5;...layer = map.createLayer('Tile Layer 1');layer.scale = {x: gameScale, y: gameScale};layer.resizeWorld();

The first thing I notice is that the layer is resized but it is clipped to only show what you could first see at 100% scale. It is drawn from the top left corner, with a bunch of empty space around it filling out the rest of the window.


The second thing I notice is that as I change the camera (x, y) coordinates, the sprites on the stage move.


Lastly, I don't see collisions occurring. I think others have encountered this already. I suspect that the tiles themselves aren't really scaled with the layer, or something to that effect?

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...