Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
StarrKiss opened this issue Jul 27, 2021 · 4 comments
Open

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

StarrKiss opened this issue Jul 27, 2021 · 4 comments

Comments

@StarrKiss
Copy link

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?

@flamendless
Copy link

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

@StarrKiss
Copy link
Author

StarrKiss commented Jul 27, 2021

How would Id o that?

@StarrKiss
Copy link
Author

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?

@flamendless
Copy link

local PlayerTable = {
  name="player",

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants