T.b.h. the whole collision and tracing stuff is one of the things that have grown quite messy. I hope to be able to clean this up for 2.0.
From the
documentation:
{
collision: { x: false, y: false, slope: false },
pos: { x: 0, y: 0 }, // Resulting object position
tile: { x: 0, y: 0 } // Tile for the collision
}
collision.x
and
collision.y
will be set to true if there was a collision on either axis with a fully solid tile. So if an entity collides with a wall,
collision.x
will be true, for floor/ceiling collisions,
collision.y
will be true. Note that both,
x
and
y
may be true for the trace, when a fast moving object collides with a corner.
The
collision.slope
property is either false (if there was no slope collision) or an object with the properties
x, y
- the slope direction - and
nx, ny
- the slope normal.
Assume a tilesize of 8. For a slope that goes from the upper left corner to the lower right,
x, y
will be
8, 8
. A slope from the lower right corner to the upper left, will have
-8, -8
.
tile.x
and
tile.y
will hold the tile number in case of a collision with a fully solid tile. This is made more sense before slopes where introduced in 1.19, in case you had some custom tiles. Now, it&
039;s either #0
(no collision) or
1
(fully solid tile).
I hope that helps a bit :)