Jump to content

tilemap need help


dianxiangan32
 Share

Recommended Posts

I check the example for the whole morning http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=mario.js&t=mario

 

But one thing I don't know why. When I change

map.addTilesetImage('SuperMarioBros-World1-1', 'tiles');

to

map.addTilesetImage('SuperMarioBros-World1-1');

It doesn't work! I put the image exactly in the server root. The phaser give me the warning:

Phaser.Tilemap.addTilesetImage: Invalid image key given: "SuperMarioBros-World1-1"

 

So does it mean that I must user the 2nd paremeter?

Link to comment
Share on other sites

If you don't pass the second argument, Phaser uses the first argument as the key to look up the image.

 

In the example, the image is in the cache with a key of 'tiles', so when you remove that argument, Phaser tries to lookup an image with the key 'SuperMarioBros-World1-1' instead, and fails.

 

The first argument is the name of a tileset, which can sometimes share a name with the image (hence the optional argument), but in this case is rendered using the image 'tiles'.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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