[engine] fix tank position

This commit is contained in:
2019-03-28 12:18:40 +03:00
parent a86c4fc447
commit 2eb606aa21

View File

@@ -231,6 +231,16 @@ class Engine extends EngineDispatcher implements ControlHandler {
var with = EntityTypeResolver.of(cell);
collisionSignal.emit(entityType, with);
isStop = true;
// fix position
if (cells.length == 1) {
if (entity.mx != 0) {
var d = entity.rect.center.y - cell.rect.center.y;
entity.rect.y += d / Math.abs(d);
} else if (entity.my != 0) {
var d = entity.rect.center.x - cell.rect.center.x;
entity.rect.x += d / Math.abs(d);
}
}
break;
}
}