feat(view): В функцию createGameView добавлен параметр container и добавление созданных отображений в этот контейнер
This commit is contained in:
+13
-4
@@ -1,4 +1,4 @@
|
|||||||
import { Graphics } from 'pixi.js';
|
import { Container, Graphics } from 'pixi.js';
|
||||||
import { Ball } from './entities/ball/ball';
|
import { Ball } from './entities/ball/ball';
|
||||||
import { Brick } from './entities/brick/brick';
|
import { Brick } from './entities/brick/brick';
|
||||||
import { Paddle } from './entities/paddle/paddle';
|
import { Paddle } from './entities/paddle/paddle';
|
||||||
@@ -29,16 +29,25 @@ function createBrickView(brick) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Создает визуальное отображение всех сущностей в игре с помощью Pixi.js
|
* Создает визуальное отображение всех сущностей в игре с помощью Pixi.js и добавляет в контейнер
|
||||||
* @param {Game} game экземпляр класса игра
|
* @param {Game} game экземпляр класса игра
|
||||||
|
* @param {Container} container контейнер Pixi.js
|
||||||
*/
|
*/
|
||||||
export function createGameView(game) {
|
export function createGameView(game, container) {
|
||||||
try {
|
try {
|
||||||
const ball = createBallView(game.ball);
|
const ball = createBallView(game.ball);
|
||||||
|
container.addChild(ball);
|
||||||
|
|
||||||
const paddle = createPaddleView(game.paddle);
|
const paddle = createPaddleView(game.paddle);
|
||||||
|
container.addChild(paddle);
|
||||||
|
|
||||||
const bricks = game.bricks.map((row) => row.map((brick) => createBrickView(brick)));
|
const bricks = game.bricks.map((row) =>
|
||||||
|
row.map((brick) => {
|
||||||
|
const brickView = createBrickView(brick);
|
||||||
|
container.addChild(brickView);
|
||||||
|
return brickView;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ball,
|
ball,
|
||||||
|
|||||||
Reference in New Issue
Block a user