Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Tile callback function undefined


Heppell08
 Share

Recommended Posts

I've been working away and eventually got myself stuck again. I'm trying to fire a function when the player collides with a specific tile in my game. I've searched the source code and looked at examples and used the same logic but still getting an undefined error in console. 

I'm using phaser 1.1.5.

Heres what i'm doing...

map.setTileIndexCallback([146, 147], emitBlock, this);// tile 146 amd 147 are the functioned tiles in my index

Then for testing:

emitBlock: function()    {       console.log('Blocks Emitted!');    },

but all i get is an undefined error. Now looking at the phaser source it says this about tile callbacks:

setTileIndexCallback: function (indexes, callback, callbackContext, layer)

so the index is my tiles [146,147], my callback is the function emitBlock, the context is this. I've also replaced 'this' with player for testing but no difference is made. 

 

Anyone know what i am doing wrong here to be getting an undefined error for a tile callback function?

 

The layer in the callback in phaser says if not defined it just uses the current tilemap layer so i shouldnt need to define considering im using 1 tilemap for my game.

 

Thanks :)

Link to comment
Share on other sites

This doesn't work either. I tried to set is as player.emitBlock and map.emitBlock but it then says can't call something or other. I'll have to look deeper but in the examples its as simple as setting the index of the tile which I've done. Setting the function, which I've done. Looked at the JSON for the index to be 100% sure and it works like it should. Only issue is when the player touches the tile I want to callback on I get the can't call 'call' error. Says something about context being false or something. I'll have to edit this post with the error exactly as I'm on my phone right now. I've tried every which way In the examples and using some of my own initiative to get this working like it does in examples and it still is giving my an issue. All I want is:

Player collides with tile I.D.

After hitting the tile, do a function.

That is it! Any ideas what is going on here?

Thanks :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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