Checking collision on WallSprites/CollisionRects


I'm making a platform game with a tilemap, and I've set up the wall sprites with addWallSprites.

How can I check on collisions with them?

I was thinking if I could assign them a sprite class I could use if collision['other']:isa(Wall) , but I'm not sure how to assign them to a class without assigning the whole tilemap.

I need to check for collisions to tell when the player is on ground (for example) and when a projectile his a wall etc.

How does the Level 1-1 example go about it?

To be honest I have a real hard time understanding Level 1-1's code. I learn better following tutorials than dissecting other games.

I can see it does class-based collision checking for coins and enemies. Walls I believe are on their own tilemap layer (which is different to how I'm set up). It seems to for loop through the tilemap and sets a variable (isWall=true) to each tile.

I don't know how to reference the table where addWallSprites adds the list of collidable tiles.

I managed to work this out!. I contained the collisionrects in a table called walls which looks like this..

        [_sprite] = 000001DD91A6B8F8,
        [height] = 32.0,
        [width] = 32.0,
        [x] = 16.0,
        [y] = 16.0,
        [_sprite] = 000001DD91A6BA38,
        [height] = 32.0,
        [width] = 32.0,
        [x] = 240.0,
        [y] = 80.0,

I've written this code to check if player is standing on a wall. It's in the Player:update function.

local onGround = false   
for index, _sprite in ipairs (walls) do
  if self.y+(self.height/2) == _sprite.y - (_sprite.height/2) and self.x >= _sprite.x-(_sprite.width/2) and self.x <= _sprite.x+(_sprite.width/2) then
     onGround = true