bump.lua icon indicating copy to clipboard operation
bump.lua copied to clipboard

How do we know if the thing we are touching is, say, a coin?

Open StarrKiss opened this issue 4 years ago • 4 comments

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?

StarrKiss avatar Jul 27 '21 17:07 StarrKiss

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

flamendless avatar Jul 27 '21 17:07 flamendless

How would Id o that?

StarrKiss avatar Jul 27 '21 18:07 StarrKiss

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 I add those variables to the world?

StarrKiss avatar Jul 28 '21 03:07 StarrKiss

local PlayerTable = {
  name="player",

  --you can add more properties
  isPlayer = true,
  isCoin = false,
}

world:add(PlayerTable,   0, 0,    64, 256) -- x,y, width, height

flamendless avatar Jul 28 '21 03:07 flamendless