Jump to content

Jump through tiles


Gerben
 Share

Recommended Posts

I'm making a platformer and for certain indices I want to be able to jump up, i.e. no collision from the bottom.

I have seen this work for sprite on sprite collision, but not sprite on tilemap collision.

 

How can you set collision data on specific tiles in a tilemap?

 

Link to comment
Share on other sites

I've tried to get a specific tile so I could apply that method, but nothing seems to work.

map.setCollision([1,2,3]);var water = map.searchTileIndex(2);water.collideDown();

Line 2 will give me an 'undefined is not a function'. My thought process was the Tilemap (var map) contains all the tile data, so I could ask that object to give me the Tile object of index 2 (var water).

Link to comment
Share on other sites

Tile.collideDown is not a function, just as the error says. It is a boolean value.

water.collideDown = falsewater.collideUp = truewater.collideLeft = truewater.collideRight = true

That will allow people to pass through from the bottom but not in any other direction.

Link to comment
Share on other sites

I see. I'm getting the error on the searchTileIndex() function.

 

Is that the way to get a tile type? It was the function that looked the most promising. 

There's also getTile() but that returns just a number and requires x,y coords.

 

Edit: Oh wow.. Apparently I was still running 2.0.4 instead of 2.0.7. It works now. Thanks!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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