[engine] fix tank position
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user