Ninja'd by cip, but posting my reply anyway.
Lets assume you have a player object like the following:
Code: Select all
local player = {
x = 0,
y = 0,
w = 16,
h = 16,
isPlayer = true
}
-- insert the object into the world:
world:add (player, player.x, player.y, player.w, player.h)
Just a single table, as an example. As you see, we have "isPlayer" boolean in our player object, and that'll be used by our filters later.
Now, lets assume we create some bullet, perhaps with the following structure:
Code: Select all
local bullet = {
x = 0,
y = 0,
w = 8,
h = 8,
isBullet = true,
}
-- insert again like before
world:add (bullet, bullet.x, bullet.y, bullet.w, bullet.h)
Now, when you want to update the bullet, and want to check it colliding against the player, you'd create a filter like the following:
Code: Select all
-- 'item' is the object we're currently updating, 'other' is the object we're colliding with
local function bulletFilter (item, other)
if other.isPlayer then return 'touch' end
-- add any other conditions here if desired, like checking for "isWall" or "isBullet"
end
You'd pass this function into world:move (or world:check) when updating your bullet object. If the bullet object collides with the player object, the collision will be returned, otherwise nothing happens.
Code: Select all
local newX, newY, cols, len = world:move (bullet, targetX, targetY, bulletFilter)
for i = 1, len do
local other = cols[i].other
if other.isPlayer then
print("collided with player!")
end
end
As such, to answer your question simply: the 'types' are just any arbitrary fields you might put into the objects you insert into the bump world. They could be numbers, booleans, strings or even tables. It's up to you what fields the filter functions might check.
Do note, that when using functions like world:queryRect, the filter functions use a simpler form:
Code: Select all
-- here, 'item' is whatever item in the world that the query'd area happened to touch
-- with these query filters, you simply need to return a truthy or falsy value
local function bulletQuery ( item )
-- add others as desired
return item.isPlayer
end