我正在尝试从随机生成的矩阵中绘制代表我的级别的小地图。
为此,我逐一绘制黑色或白色的小方块来直观地表示矩阵(我不知道这是否是使用移相器实现这一点的最佳方法,实际上,我是这个框架的初学者)。
地图绘制正确,但它的位置绑定到世界而不是相机,所以当我移动时它不再可见。
这是我用来绘制地图的代码:
generate() {
let wallsGraphics = this._scene.add.graphics({fillStyle : {color : LabyrinthConfig.MAPS.MINI_MAP.WALLS_COLOR}});
let pathGraphics = this._scene.add.graphics({fillStyle : {color : LabyrinthConfig.MAPS.MINI_MAP.PATH_COLOR}});
// Draw the map
let y = 0;
for (let line of this._matrix) {
let x = 0;
for (let cell of line) {
let rect = new Phaser.Geom.Rectangle();
rect.width = LabyrinthConfig.MAPS.MINI_MAP.CELL_WIDTH;
rect.height = LabyrinthConfig.MAPS.MINI_MAP.CELL_HEIGHT;
rect.x = LabyrinthConfig.MAPS.MINI_MAP.POSITION_X + x * LabyrinthConfig.MAPS.MINI_MAP.CELL_WIDTH;
rect.y = LabyrinthConfig.MAPS.MINI_MAP.POSITION_Y + y * LabyrinthConfig.MAPS.MINI_MAP.CELL_HEIGHT;
cell === 0 ? wallsGraphics.fillRectShape(rect) : pathGraphics.fillRectShape(rect);
x++;
} …
Run Code Online (Sandbox Code Playgroud) 我有 3 个表 'users'、'teams' 和 'teams_users'(一个数据透视表)。数据透视表包含一个布尔字段“踢”。我没有找到获取用户未被踢出的团队列表的方法。我的代码如下所示:
$teams = Team::withCount('users')
->where($params)
->orderBy(DB::raw('users_count / max_members'), 'desc')
->orderBy('team_id', 'desc')
->has('users', '<', DB::raw('max_members'));
$user = app('auth')->user();
if (isset($user)) {
// Here add the condition to exclude teams the user has been kicked from
}
Run Code Online (Sandbox Code Playgroud)