DudeshootMankill Posted December 19, 2016 Share Posted December 19, 2016 Heya, i'm making a sidescroller with ladders. When the player is over a ladder, which is a seperate layer this runs: this._map.setTileIndexCallback([33, 43, 51, 61], this.player.setOnLadder, this.player, this._ladder_layer); I use this to call the ladderfunction, disabling gravity. It works just fine. My question is, can i resize the bounding box that calls the setTileIndexCallback? The tiles are 64x64, and i need the player to be in the middle of the sprite before setOnLadder is fired. Could i resize the bounding box so its something like x = 4 and y = 64? Or if you have some clever way of doing this, i'd like to hear it. Thank you for your time Link to comment Share on other sites More sharing options...
squilibob Posted December 21, 2016 Share Posted December 21, 2016 If your tiles are all the same size then you can use the mod % to work out if they are in the middle of a tile. Say your tiles are all width of 64, you could do in your this.player.setOnLadder function something like if (this.x % 64 > 28 && this.x % 64 < 36) { // player is in the middle 8 pixels of the tile } DudeshootMankill 1 Link to comment Share on other sites More sharing options...
DudeshootMankill Posted December 22, 2016 Author Share Posted December 22, 2016 Perfect. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts