MCPcopy Create free account
hub / github.com/eva-engine/eva.js / createGameObjectAddGraphicsRect

Function createGameObjectAddGraphicsRect

examples/src/matter.ts:389–415  ·  view source on GitHub ↗
(x, y, width, height, color)

Source from the content-addressed store, hash-verified

387 window.game.scene.addChild(rightWall);
388 }
389 function createGameObjectAddGraphicsRect(x, y, width, height, color) {
390 const gameObject = new GameObject('gameObject', {
391 position: {
392 x,
393 y,
394 },
395 size: {
396 width,
397 height,
398 },
399 origin: {
400 x: 0.5,
401 y: 0.5,
402 },
403 });
404 const { graphics } = gameObject.addComponent(new Graphics());
405 graphics.rect(0, 0, gameObject.transform.size.width, gameObject.transform.size.height).fill(color);
406 gameObject.addComponent(
407 new Physics({
408 type: PhysicsType.RECTANGLE,
409 bodyOptions: {
410 isStatic: true,
411 },
412 }),
413 );
414 return gameObject;
415 }
416
417 function buildFruit(name, x, y, radius, type) {
418 const gameObject = new GameObject(name, {

Callers 1

buildWallFunction · 0.85

Calls 1

addComponentMethod · 0.95

Tested by

no test coverage detected