1 decade ago
by Aitor
I've been logging this values to see how they work, and I've seen that the variable that changes between two sloped tiles (with the same angle) that point to different directions in the x axis is y ,(I thought it would be x) and the variable that changes between two sloped tiles wich point to the same direction in the x axis but a different direction in the y axis is x, and not y. So i wanted to know, how do this variables work?
1 decade ago
by dominic
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 },
tile: { x: 0, y: 0 }
}
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 :)
Page 1 of 1
« first
« previous
next ›
last »