bump.lua
bump.lua copied to clipboard
How do we know if the thing we are touching is, say, a coin?
In the readme there is an example as follows:
local playerFilter = function(item, other) if other.isCoin then return 'cross' elseif other.isWall then return 'slide' elseif other.isExit then return 'touch' elseif other.isSpring then return 'bounce' end -- else return nil end
But how do we KNOW that other is, say, a wall or a coin? I'm trying to implement the same thing in my own game, where I have ground tiles called 'tile', all lower case. How would I check that other is a tile?
The other is just a table. You can put variables/properties there before (or even after) adding to the bump world. isCoin and such are just examples, you put other variables in the table as definitions before using with filter
How would Id o that?
The
otheris just a table. You can put variables/properties there before (or even after) adding to the bump world. isCoin and such are just examples, you put other variables in the table as definitions before using with filter
How would I add those variables to the world?
local PlayerTable = {
name="player",
--you can add more properties
isPlayer = true,
isCoin = false,
}
world:add(PlayerTable, 0, 0, 64, 256) -- x,y, width, height