Is it possible to make one single tile a physics object and detect collision with it?
In corona examples, we have something like this:
local function collisionDetect( self, event ) if ( event.phase == "began" ) then print( self.myName .. ": collision began with " .. event.other.myName ) elseif ( event.phase == "ended" ) then print( self.myName .. ": collision ended with " )--.. event.other.myName ) end end box.collision = collisionDetect; box:addEventListener( "collision" );
Hey @Azmar, by set a new variable to the tile like: object.name = “wall”, you meant in the spritesheet in tiled? Like physics = true? Or in the code? If is in the code, where do i set that?
And when you say “inside your normal collisionDetect”… how can i add an event listener to my tile?
I saw mte.addPropertyListener(), but that only run one time when the map is loaded. I want to one of the tiles to be: “isSensor = true” in the collision. Is this possible to set? How?
I think I set you down the wrong track, you could create objects on your map and easily call them in to give them all the properties you want or set all the properties in tiled to them by looking at the MTE documentation. And that all works fine, but with my experience on MTE it is very amazing but has a few minor bugs, and you will come across this bug and there are some threads in the history on it. It happens when creating objects and using them for all these properties while loading/changing maps through MTE etc…hard to describe. Just saving you a huge headache that doesn’t make sense just do what I’m gonna suggest next.
If you want a wall that is just a physics object sure do it in tiled but if it has any specific properties or special collision rules just create it in corona and do the normal add sprite functions and after do what you want.
To handle most my collisions, as there are so many to handle when you get further in the project…that may be incorrect if anyone wants to correct me on that. And I use the above code now to handle everything.
Hey @Azmar, by set a new variable to the tile like: object.name = “wall”, you meant in the spritesheet in tiled? Like physics = true? Or in the code? If is in the code, where do i set that?
And when you say “inside your normal collisionDetect”… how can i add an event listener to my tile?
I saw mte.addPropertyListener(), but that only run one time when the map is loaded. I want to one of the tiles to be: “isSensor = true” in the collision. Is this possible to set? How?
I think I set you down the wrong track, you could create objects on your map and easily call them in to give them all the properties you want or set all the properties in tiled to them by looking at the MTE documentation. And that all works fine, but with my experience on MTE it is very amazing but has a few minor bugs, and you will come across this bug and there are some threads in the history on it. It happens when creating objects and using them for all these properties while loading/changing maps through MTE etc…hard to describe. Just saving you a huge headache that doesn’t make sense just do what I’m gonna suggest next.
If you want a wall that is just a physics object sure do it in tiled but if it has any specific properties or special collision rules just create it in corona and do the normal add sprite functions and after do what you want.
To handle most my collisions, as there are so many to handle when you get further in the project…that may be incorrect if anyone wants to correct me on that. And I use the above code now to handle everything.