Jump to content

Phaser Scale Tilemap Collisions


Seanw265
 Share

Recommended Posts

Hello all,

I'm new to HTML5 and JS game programming.  I come from an Obj-c/cocos2d background.  I've been struggling to get the Arcade physics to recognize the scaling of a Tilemap layer.

The layer is created as follows:

this.map = this.game.add.tilemap('level');this.map.addTilesetImage('tileset','tiles');this.map.setCollisionBetween(44, 50);this.layer = this.map.createLayer('Tile Layer 1');this.layer.scale.x = 2;this.layer.scale.y = 2;this.layer.debug = true;this.layer.fixedToCamera = false;

The layer displays perfectly fine(along with the debug drawing), but the collisions do not scale at all.

 

I have tried altering the collisionWidth and collisionHeight of the TilemapLayer and it doesn't seem to have the desired effect.

 

I am checking for collisions in an update method by this function:

game.physics.arcade.collide(sprite,layer);

This was posted in regard to Phaser 1.1:

 

You can now also scale the layers and the collision system recognises this and uses the new scaled size for all collision.

 

 

I should point out that I am running Phaser 2.0.4

 

Any help is greatly appreciated!

Link to comment
Share on other sites

  • 3 weeks later...

@Doodlemeat you're probably right. There was another forum post where the conclusion was the same. The tilemap scaling doesn't work well with the physics systems (or atleast arcade).

 

You could also try a more indirect approach and reduce the game resolution to half and then scale other objects of the game to 0.5, so that the tilemap appears twice the size. Then you can let the game resize itself to bigger size and get almost the same end result. Of course it won't be exactly the same (gameplay won't be as smooth), but should work for the time being. Remember to set antialiasing off if you're using pixel art :)

Link to comment
Share on other sites

  • 11 months later...
 Share

  • Recently Browsing   0 members

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